// Background load of experiment design 5.5: constant-arrival-rate 20 rps, /api/orders 70% and /api/price/{item} 30%. // Thresholds mirror the SLO (p95 < 500ms, failures < 1%); a breach makes k6 exit non-zero at the end of the run // (the SLO verdict itself is the harness judge's Mimir query, design 4.2). import http from 'k6/http'; import { check } from 'k6'; const base = __ENV.ALB_URL; const items = ['apple', 'banana', 'cherry']; export const options = { scenarios: { background: { executor: 'constant-arrival-rate', rate: 20, timeUnit: '1s', duration: __ENV.K6_DURATION || '12h', preAllocatedVUs: 20, maxVUs: 50, }, }, thresholds: { http_req_duration: ['p(95)<500'], http_req_failed: ['rate<0.01'], }, }; export default function () { const r = Math.random(); let res; if (r < 0.7) { res = http.get(`${base}/api/orders`, { tags: { route: 'orders' } }); } else { const item = items[Math.floor(Math.random() * items.length)]; res = http.get(`${base}/api/price/${item}`, { tags: { route: 'price' } }); } check(res, { 'status 200': (x) => x.status === 200 }); }