Testing & Load
Pixelflux is tested at several levels — unit tests (in-memory), integration tests against a real Redis via Testcontainers, API contract tests (Hurl + OpenAPI), and load/benchmark tests (k6):
| Level | Command |
|---|---|
| Unit | task test |
| Integration (real Redis) | task test:integration |
| API contract | task test:api |
| Load / benchmark | task bench |
Load tests (k6)
health.js is a k6 load test for the HTTP
server. It ramps virtual users up and down while reading the canvas and painting
random pixels, and asserts latency and error-rate thresholds.
What it does
- Stages: 0→20 VUs over 10s, 20→50 VUs over 20s, 50→0 over 10s.
- Per iteration:
GET /api/canvas, thenPOST /api/pixelwith randomx/y/color. - Thresholds (the test fails if breached):
http_req_failed< 1% (error rate)http_req_durationp95 < 200 ms
Run it
task bench
The task builds the release binary, boots the server, runs k6 against it, and stops the server afterwards.
To run it against an already-running server (local or remote), set BASE_URL:
BASE_URL=http://localhost:3000 k6 run load/health.js
# or against the deployed instance:
BASE_URL=https://your.domain.com k6 run load/health.js
Tuning
Adjust the stages (load profile) and thresholds (pass/fail criteria) at the
top of health.js. Keep the thresholds realistic for the environment you test
against — a remote cluster will have higher latency than localhost.