72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
// k6 composite suite — runs login, read, and mutating scenarios in one go.
|
|
//
|
|
// Each scenario re-uses the per-script default function so individual scripts
|
|
// remain runnable on their own. Thresholds are unioned: the composite must
|
|
// satisfy every per-suite p(99) and failure-rate budget.
|
|
//
|
|
// Run:
|
|
// K6_TARGET_URL=http://localhost:3000 \
|
|
// LOAD_TENANT_API_KEY=tnk_live_xxx \
|
|
// k6 run tests/load/scenarios.js
|
|
//
|
|
// The composite is the full-suite production-rehearsal entrypoint invoked by
|
|
// `scripts/run-load-tests.mjs`. For ad-hoc stress runs, scale the per-script
|
|
// VUs via env vars rather than editing this file (see README.md).
|
|
|
|
import loginScenario from "./login.js";
|
|
import apiReadScenario from "./api-read.js";
|
|
import apiMutatingScenario from "./api-mutating.js";
|
|
|
|
export const options = {
|
|
scenarios: {
|
|
login: {
|
|
executor: "ramping-vus",
|
|
exec: "login",
|
|
startVUs: 0,
|
|
stages: [
|
|
{ duration: "30s", target: 50 },
|
|
{ duration: "30s", target: 50 },
|
|
{ duration: "10s", target: 0 },
|
|
],
|
|
gracefulRampDown: "10s",
|
|
tags: { suite: "login" },
|
|
},
|
|
api_read: {
|
|
executor: "constant-vus",
|
|
exec: "apiRead",
|
|
vus: 100,
|
|
duration: "60s",
|
|
startTime: "1m20s",
|
|
tags: { suite: "api-read" },
|
|
},
|
|
api_mutating: {
|
|
executor: "constant-vus",
|
|
exec: "apiMutating",
|
|
vus: 30,
|
|
duration: "30s",
|
|
startTime: "2m25s",
|
|
tags: { suite: "api-mutating" },
|
|
},
|
|
},
|
|
thresholds: {
|
|
http_req_failed: ["rate<0.05"],
|
|
"http_req_duration{name:login}": ["p(95)<400"],
|
|
"http_req_duration{name:api-read}": ["p(99)<300"],
|
|
"http_req_duration{name:api-mutating}": ["p(99)<600"],
|
|
"http_reqs{name:api-read}": ["rate>200"],
|
|
},
|
|
discardResponseBodies: true,
|
|
};
|
|
|
|
export function login() {
|
|
loginScenario();
|
|
}
|
|
|
|
export function apiRead() {
|
|
apiReadScenario();
|
|
}
|
|
|
|
export function apiMutating() {
|
|
apiMutatingScenario();
|
|
}
|