The project is supports scalable load testing, automation, API validation, and reporting. The multi-tool approach (K6 + Artillery) makes it flexible, and the modular structure (POM) ensures reusability.
This repository contains a framework for running performance tests using K6, alongside a reusable test suite setup. It is designed to be easily scalable, making it suitable for various projects that need performance testing integrated into CI/CD pipelines.
The framework is equipped with scripts to run K6 tests, generate reports, and integrate with other tools like Artillery. This is ideal for teams looking to automate load testing and incorporate it into their development lifecycle. Technologies Used
- K6 (https://k6.io/) - For load and performance testing
- Artillery (https://artillery.io/) - For API testing and load testing
- Node.js (https://nodejs.org/) - For managing test scripts and dependencies
- CI/CD Tools (https://www.jenkins.io/), GitHub Actions (https://github.com/features/actions) - To automate the testing process in CI/CD pipelines
Follow these steps to get the project up and running on your local machine. Prerequisites Before you begin, ensure you have the following installed on your machine:
- Node.js (v14.0 or higher)
- Git
- K6
- Artillery
- Clone the repository:
git clone https://github.com/QA-Tanushree/K6-scalable-performance-testing-framework.git
cd K6-scalable-performance-testing-framework- Install project dependencies:
npm install- Install K6 globally (if not already installed):
npm install -g k6- Install Artillery globally (if not already installed):
npm install -g artillery- Scalable Load Testing
- Multi-Tool Integration (K6 & Artillery)
- Comprehensive API Testing
- Automated Reporting & Analytics
- Reusable & Modular Test Structure
- CI/CD & Automation Ready
- Flexible Test Scenarios
- Security & Reliability Testing
- Uses K6 for high-concurrency performance testing.
- Uses Artillery to simulate realistic user behavior.
- Supports ramp-up scenarios via phases in Artillery.
🔹 Example from tests/userScenarioTest.yml
phases:
- duration: 60 # Run the test for 60 seconds
arrivalRate: 5 # 5 new virtual users per second✅ In 60 seconds, 300 users (5 * 60) will be simulated, testing system scalability.
- K6: Focuses on performance with detailed metrics.
- Artillery: Supports complex test flows and distributed load testing.
🔹 Example from package.json (Script Execution)
"scripts": {
"test:k6": "npx k6 run tests/apiTest --out json=reports/k6-results.json",
"test:artillery": "artillery run tests/userScenarioTest.yml"
}✅ npm run test:k6 runs performance tests. ✅ npm run test:artillery runs scenario-based load tests.
-
Covers the entire API lifecycle (Register, Login, CRUD operations).
-
Uses parameterized testing (e.g., userData.json, loginData.json).
🔹 Example from tests/apiTest.js
let registerResponse = registerUser(registerData);
let createResponse = createUser(randomUser);
let updateResponse = updateUser(userId, updatedUser);
let deleteResponse = deleteUser(userId);✅ Each function tests an API endpoint with assertions (e.g., check(response, { 'Status is 200': (r) => r.status === 200 })).
-
K6 Reports → JSON (reports/k6-results.json).
-
Artillery Reports → HTML (reports/artillery-report.html).
Can integrate into Grafana for real-time monitoring.
🔹 Example from package.json
"scripts": {
"report:k6": "k6 stats reports/k6-results.json",
"report:artillery": "artillery report --output reports/artillery-report.html reports/artillery-results.json"
}✅ After running tests, reports can be viewed/analyzed easily.
- Implements Page Object Model (POM) for API requests.
- Uses a configuration-driven approach.
🔹 Example from config/config.js
export const config = {
baseUrl: 'https://reqres.in/api',
headers: {
'Content-Type': 'application/json'
}
};✅ APIs can be reused across tests by importing a single config file.
The framework is designed to be integrated into a CI/CD pipeline. You can easily integrate the test scripts with CI tools like Jenkins, GitHub Actions, or GitLab CI.
- Create a
.github/workflows/test.ymlfile in your repository with the following content:
name: Run K6 and Artillery tests
on: [push]
jobs:
k6-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js (Upgrade to v18)
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Install k6 (via Snap)
run: sudo snap install k6
- name: Run K6 tests
run: npm run test:k6
- name: Run Artillery tests
run: npm run test:artillery🔹 Example GitHub Actions Workflow (Future Integration)
✅ Tests automatically run whenever code is pushed.
-
Supports dynamic load profiles.
-
Supports different authentication methods.
🔹 Example: Using Bearer Token
headers:
Authorization: "Bearer {{ loginToken }}"✅ Different auth methods (Basic Auth, JWT) can be tested dynamically.
-
Simulates high-traffic spikes.
-
Tests session handling & API resilience.
🔹 Example: Artillery Load Testing
arrivalRate: 5 # 5 new users per second
duration: 60 # Simulating 60 seconds of high traffic✅ Can simulate thousands of concurrent users.
Welcome contributions to this project! To contribute, please fork the repository, create a feature branch, and submit a pull request with your changes.
Ensure that your changes are well-tested and follow the project's coding style.
