Structured k6 performance testing framework covering smoke, load, stress, spike, and soak test scenarios. Targets the public DummyJSON API by default with shared SLO thresholds, reusable HTTP helpers, and HTML report generation.
| Type | VUs | Duration | Purpose |
|---|---|---|---|
| Smoke | 1 | 30s | Verify endpoints work before heavier tests |
| Load | 50 | ~17 min | Validate performance under expected traffic |
| Stress | 200 | ~20 min | Find the breaking point |
| Spike | 250 | ~9 min | Handle sudden traffic bursts |
| Soak | 50 | 2 hours | Detect memory leaks over time |
# Install k6 (macOS)
brew install k6
# Clone
git clone https://github.com/mustafaautomation/performance-testing-k6.git
cd performance-testing-k6
# Configure
cp .env.example .env
# Run smoke test
npm run test:smoke
# Run load test
npm run test:load┌─────────────────────────────────────────────────────┐
│ Test Suites │
│ smoke │ load │ stress │ spike │ soak │
├─────────────────────────────────────────────────────┤
│ Shared Layer │
│ Thresholds │ HTTP Helpers │ Auth │ Test Data │
├─────────────────────────────────────────────────────┤
│ k6 Engine │
│ VU scheduling + metrics + checks │
├─────────────────────────────────────────────────────┤
│ Reporting │
│ k6-reporter (HTML) + text summary │
└─────────────────────────────────────────────────────┘
| Metric | Target |
|---|---|
| p(95) response time | < 500ms |
| p(99) response time | < 1000ms |
| Error rate | < 1% |
| Login p(95) | < 300ms |
Stress and spike tests use relaxed thresholds (2–3s p95, 10–15% error tolerance).
| Command | Description |
|---|---|
npm run validate |
Static check of the k6 scripts (Node 22+, no k6 needed) |
npm run test:smoke |
1 VU, 30s — sanity check |
npm run test:load |
50 VUs, steady state |
npm run test:stress |
Ramp to 200 VUs — find limits |
npm run test:spike |
Instant spike to 250 VUs |
npm run test:soak |
50 VUs for 2 hours |
docker build -t k6-perf .
docker run --rm -v $(pwd)/reports:/app/reports k6-perf
docker run --rm -v $(pwd)/reports:/app/reports k6-perf tests/load.test.jsMount -v $(pwd)/reports:/app/reports to persist HTML reports on the host.
The GitHub Actions workflow supports:
- Script validation (
npm run validateon Node 24) before any k6 run - Smoke on push and on pull requests to main, using k6 2.3
- Nightly smoke tests at 2 AM UTC
- Manual dispatch — select any test type from the Actions UI
- HTML report artifacts uploaded on every run
performance-testing-k6/
├── .github/
│ ├── workflows/performance.yml
│ ├── dependabot.yml
│ ├── CODEOWNERS
│ └── pull_request_template.md
├── src/
│ ├── config/
│ │ └── thresholds.js # Shared SLO thresholds + BASE_URL
│ ├── helpers/
│ │ ├── auth.js # Login with failure guard + tagged metrics
│ │ └── http.js # HTTP wrappers with 5xx error tracking
│ └── data/
│ └── users.js # Test data constants
├── tests/
│ ├── smoke.test.js # 1 VU, 30s sanity check
│ ├── load.test.js # 50 VU steady state
│ ├── stress.test.js # 200 VU breaking point
│ ├── spike.test.js # 250 VU instant spike
│ └── soak.test.js # 50 VU endurance (2h / 10min CI)
├── Dockerfile
└── .dockerignore
MIT
Built by Quvantic