Files
sisi/verifiers/real-world/load-test-k6.md
T
swaitsandClaude Fable 5.2 2fc1fe9c2d
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
sisi 0.1.0: a shared rulebook and verification tool for AI coding agents
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and
shared lessons, time-to-delivery measurement, a library of 140 verification
techniques and 20 recipes, personal data kept outside the clone, and
releases with rollback. Standard library only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:29:02 -07:00

2.4 KiB

id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
id title answers rung section languages kinds cost detect ran_here verified
load-test-k6 Load tests with pass/fail thresholds (k6) Does the service stay fast and correct under the load it must handle? 3 real-world any general medium k6 version no docs

Use when

  • You changed a query, cache, index, lock or request path and need to show it holds under concurrency.
  • A latency or error-rate promise exists (a service level objective).

Do not use when

  • The service has no stated target; invent none. Ask for one, or compare before and after instead.
  • You would point it at a production system or one you do not own. Test a copy.

Set up

Install k6 (https://grafana.com/docs/k6/latest/set-up/install-k6/). Run the system under test locally or in a staging copy with realistic data volume.

Minimal example

load.js

import http from 'k6/http';
import { check } from 'k6';
export const options = {
  vus: 20, duration: '30s',
  thresholds: {
    http_req_failed:   ['rate<0.01'],        // under 1 % errors
    http_req_duration: ['p(95)<300'],        // 95 % of requests under 300 ms
  },
};
export default function () {
  const res = http.get('http://localhost:3000/api/items');
  check(res, { 'status is 200': (r) => r.status === 200, 'has items': (r) => r.json().length > 0 });
}

Thresholds are what make this a check: if any is crossed, k6 exits nonzero. Checks (check) alone only count and do not fail the run, so also put checks: ['rate>0.99'] in thresholds. Run once against the unchanged system first and record the numbers.

Run

k6 run load.js

Passing looks like: every threshold line marked with a tick (✓) and exit 0. Failure marks the threshold ✗ and exits with code 99.

As a contract check

{"id": "load", "claim": "p95 latency under 300 ms and under 1% errors at 20 users", "kind": "general", "rung": 3,
 "cmd": "k6 run load.js", "expect": {"exit": 0}, "tier": "deep", "timeout_s": 300}

What a pass does not prove

  • Only the traffic mix you scripted. Real users behave differently.
  • The load generator and the system share a machine in a local test; results are optimistic. Record where it ran.
  • Not run here (k6 is not installed). Thresholds and their behaviour come from the k6 documentation; the exit code 99 is from memory.
  • Passing latency does not show the responses were right; keep the check calls and a threshold on them.
  • Check the check: set p(95)<1 and confirm the run fails.