import http from 'k6/http'; import { check, sleep } from 'k6'; /** * ST-GW-01 — Gateway health liveness bajo carga. * * k6 run -e BASE_URL=http://127.0.0.1:8189 -e PROFILE=shared8g k6_gateway_health.js * k6 run -e PROFILE=lab k6_gateway_health.js * * Perfiles: * shared8g (default) — host Ubuntu 8GiB compartido (MLflow/Airflow/etc.) * lab — Docker dedicado a IPS */ const PROFILE = __ENV.PROFILE || 'shared8g'; const profiles = { shared8g: { stages: [ { duration: '20s', target: 5 }, { duration: '40s', target: 15 }, { duration: '40s', target: 25 }, { duration: '20s', target: 0 }, ], thresholds: { http_req_failed: ['rate<0.01'], http_req_duration: ['p(95)<500'], }, }, lab: { stages: [ { duration: '30s', target: 20 }, { duration: '1m', target: 50 }, { duration: '1m', target: 100 }, { duration: '30s', target: 0 }, ], thresholds: { http_req_failed: ['rate<0.001'], http_req_duration: ['p(95)<300'], }, }, }; const cfg = profiles[PROFILE] || profiles.shared8g; export const options = { stages: cfg.stages, thresholds: cfg.thresholds, tags: { profile: PROFILE, host: 'ubuntu-shared-8g' }, }; const BASE_URL = __ENV.BASE_URL || 'http://127.0.0.1:8189'; export default function () { const res = http.get(`${BASE_URL}/health/live`); check(res, { 'status is 200': (r) => r.status === 200, 'body ok': (r) => String(r.body).includes('ok'), }); sleep(0.2); }