k6 Performance Testing Environment
Enterprise-grade load testing with k6, Grafana dashboards, and InfluxDB metrics.
What's Inside
| Tool | Version | Purpose |
|---|---|---|
| k6 | Latest | Load testing framework by Grafana Labs |
| Node.js | 20 LTS | JavaScript runtime for scripting |
| Grafana | Latest OSS | Real-time metrics dashboards |
| InfluxDB | 1.x | Time-series metrics storage |
| Allure CLI | Latest | Test reporting |
| jq / yq | Latest | JSON and YAML processing |
Quick Start
# Run a load test
k6-run tests/http-load-test.js
# Start Grafana + InfluxDB for real-time dashboards
k6-grafana
# Run tests with Allure report
k6-allure
# Check test syntax without running
k6-check tests/http-load-test.js
Helper Commands
| Command | What it does |
|---|---|
k6-run <script> |
Execute a k6 test script |
k6-check <script> |
Validate test syntax |
k6-allure |
Run tests + generate Allure report |
k6-report |
Serve existing Allure report |
k6-tag <group> |
Run tests filtered by tag |
k6-grafana |
Start Grafana + InfluxDB stack |
k6-help |
Show all available commands |
Exercises
- HTTP Load Test with Stages — Ramp up/down virtual users, measure response times
- API Stress Test — POST requests with authentication, custom metrics
- WebSocket Testing — Connection lifecycle, message throughput
- Thresholds & Custom Metrics — Define pass/fail criteria, track business metrics
- gRPC Performance — Unary call load testing
- Multi-Scenario Executors — Parallel test scenarios with different VU patterns
- Browser Module — Real browser performance testing
- Chaos & Resilience — 4-phase degradation simulation
Sample Test Scripts
The workspace comes pre-loaded with:
tests/http-load-test.js— Basic HTTP load test with stagestests/api-stress-test.js— POST requests with auth tokenstests/websocket-test.js— WebSocket connection testingtests/threshold-test.js— Custom thresholds and metricstests/lib/helpers.js— Shared utility functions
Grafana Dashboard
After running k6-grafana, open the Grafana URL to see:
- Virtual Users over time
- Requests per second
- Response time percentiles (p50, p90, p95, p99)
- Error rate
- Custom business metrics
Tips
- Use
k6-checkbefore running to catch syntax errors early - Grafana dashboards update in real-time during test execution
- InfluxDB stores all metrics — you can query historical data
- Use
--out influxdb=http://localhost:8086/k6to send metrics to InfluxDB manually - The
Ctrl+Shift+Bkeyboard shortcut runs the default k6 test
Security
- Root access is restricted. Use
sudo apt install <package>for system packages. - k6, npm, and apt are whitelisted for sudo access.