NextDigital Docs
Guides 2 min read

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

  1. HTTP Load Test with Stages — Ramp up/down virtual users, measure response times
  2. API Stress Test — POST requests with authentication, custom metrics
  3. WebSocket Testing — Connection lifecycle, message throughput
  4. Thresholds & Custom Metrics — Define pass/fail criteria, track business metrics
  5. gRPC Performance — Unary call load testing
  6. Multi-Scenario Executors — Parallel test scenarios with different VU patterns
  7. Browser Module — Real browser performance testing
  8. 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 stages
  • tests/api-stress-test.js — POST requests with auth tokens
  • tests/websocket-test.js — WebSocket connection testing
  • tests/threshold-test.js — Custom thresholds and metrics
  • tests/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-check before 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/k6 to send metrics to InfluxDB manually
  • The Ctrl+Shift+B keyboard 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.