Comprehensive k6 load testing suite with smoke, load, stress, and spike test scenarios. Thresholds, custom metrics, and CI integration.
## Task k6 load testing suite with multiple test scenarios and CI integration. ## Requirements - Tool: k6 (Grafana) - Language: JavaScript (k6 scripting) - Scenarios: smoke, load, stress, spike, soak ## Test Suite ```javascript // Generate a comprehensive k6 test file with: // Scenarios: export const options = { scenarios: { smoke: { executor: "constant-vus", vus: 1, duration: "1m", tags: { test_type: "smoke" }, }, load: { executor: "ramping-vus", startVUs: 0, stages: [ { duration: "2m", target: 50 }, // ramp up { duration: "5m", target: 50 }, // hold { duration: "2m", target: 0 }, // ramp down ], tags: { test_type: "load" }, }, stress: { executor: "ramping-vus", stages: [ { duration: "2m", target: 100 }, { duration: "5m", target: 100 }, { duration: "2m", target: 200 }, // beyond expected capacity { duration: "5m", target: 200 }, { duration: "2m", target: 0 }, ], tags: { test_type: "stress" }, }, spike: { executor: "ramping-vus", stages: [ { duration: "10s", target: 500 }, // sudden spike { duration: "1m", target: 500 }, { duration: "10s", target: 0 }, // sudden drop ], tags: { test_type: "spike" }, }, }, thresholds: { http_req_duration: ["p(95)<500", "p(99)<1000"], http_req_failed: ["rate<0.01"], // <1% errors "http_req_duration{name:login}": ["p(95)<1000"], }, }; // Test flow: realistic user journey export default function () { // 1. Homepage // 2. Search // 3. View product // 4. Add to cart // 5. Checkout // With think time between steps } ``` ## Implementation Notes 1. Use groups and tags for per-endpoint analysis 2. Add custom metrics: Trend for business operations, Counter for errors 3. Think time: randomized sleep(1-3) between requests (realistic) 4. Data: use SharedArray for test data (users, products) 5. CI integration: run smoke test on every PR, full suite nightly 6. Output: JSON summary for CI threshold checks, InfluxDB for Grafana dashboards
No gallery images yet.