This project is a scalable, enterprise-grade performance testing framework built using:
- k6 for load testing
- TypeScript for maintainability and type safety
- Docker for containerization
- Kubernetes for distributed execution
- Jenkins for CI/CD orchestration
The framework is designed with clean architecture principles to ensure:
- Scalability
- Reusability
- Maintainability
- Minimal impact on test scripts during upgrades
tests
│
▼
services (business flows)
│
▼
api client
│
▼
auth manager (token handling)
│
▼
http client
│
▼
k6 engine
k6-performance-framework
│
├── src
│ ├── config
│ │ └── env.ts
│ │
│ ├── auth
│ │ └── tokenManager.ts
│ │
│ ├── clients
│ │ └── apiClient.ts
│ │
│ ├── services
│ │ └── orderService.ts
│ │
│ ├── scenarios
│ │ ├── loadScenario.ts
│ │ ├── stressScenario.ts
│ │ └── scenarioManager.ts
│ │
│ ├── tests
│ │ └── orderLoadTest.ts
│
├── data
│ └── users.json
│
├── docker
│ └── Dockerfile
│
├── k8s
│ └── k6-job.yaml
│
├── jenkins
│ └── Jenkinsfile
│
├── dist
└── package.json
- ✅ TypeScript-based framework
- ✅ Environment-based execution (dev / qa / preprod)
- ✅ Token-based authentication with auto-refresh
- ✅ Scenario-driven execution (load, stress, spike)
- ✅ Service-layer abstraction (business workflows)
- ✅ Dockerized execution
- ✅ Kubernetes distributed load generation
- ✅ CI/CD ready (Jenkins pipeline)
- Test scripts contain only business logic
- No authentication or HTTP handling in tests
- Fully decoupled architecture
import { getScenario } from "../scenarios/scenarioManager"
import { createOrder } from "../services/orderService"
export const options = getScenario()
export default function () {
createOrder()
}Run tests for different environments using:
k6 run -e ENV=qa dist/tests/orderLoadTest.jsSupported environments:
dev
qa
preprod
Control test type dynamically:
k6 run -e SCENARIO=load
k6 run -e SCENARIO=stressSupported scenarios:
- load
- stress
- spike
docker build -t k6-framework -f docker/Dockerfile .docker run k6-framework run /app/tests/orderLoadTest.jskubectl apply -f k8s/k6-job.yamlkubectl get podskubectl logs <pod-name>- Multiple pods act as independent load generators
- Each pod runs a k6 instance
- Total load = sum of all pods
Pipeline supports parameters:
ENV
SCENARIO
TEST_SCRIPT
Example:
ENV = qa
SCENARIO = load
TEST_SCRIPT = orderLoadTest.js
Tests can be scheduled using Jenkins cron:
0 2 * * *
Example: Run test every day at 2 AM
- Test → business flow
- Service → API logic
- Client → HTTP handling
- Auth → token management
- Tokens are generated and refreshed automatically
- No dependency on test scripts
- Supports long-running distributed tests
Framework supports:
- Easy migration to cloud Kubernetes
- Switching authentication methods
- Adding observability tools
- Scaling to high load
| Setup | Capability |
|---|---|
| Local (Minikube) | Framework validation |
| Distributed cl |