test: repeatable integration harness and 120-client SSE load tool

Add scripts/integration.sh, which starts the real FastAPI and Go API,
trains small and forecast through POST /api/train, checks SSE scenario
propagation, heartbeat, reconnect, then kills FastAPI to verify snapshot
and last-good forecast fallback before restarting it for recovery.

Add scripts/sse-load, a standard-library load generator that holds 120
concurrent SSE streams for five minutes, posts scenario changes, records
p50/p95/p99 event latency, drops and heartbeat cadence, and exits
non-zero when a contract threshold is missed. Add unit tests, make
targets and README documentation.
This commit is contained in:
Noel Sabia committed 2026-11-14 06:33:29 +01:00
1 parent e9f80b9ce7
commit ac7ceca7ec
5 files changed
+1273 -1

No files matched your search

+14 -1
View File
@@ -1,6 +1,6 @@
GO ?= go
.PHONY: check vet test build
.PHONY: check vet test build integration integration-load load
# Local equivalent of the Gitea Actions CI job.
check: vet test build
@@ -13,3 +13,16 @@ test:
build:
$(GO) build ./...
# End-to-end: real FastAPI on :18000, Go on :18080, train small+forecast,
# SSE scenario/heartbeat/reconnect, FastAPI kill + cache fallback + recovery.
integration:
scripts/integration.sh
# The same run plus the 120-client, 5-minute SSE load test.
integration-load:
scripts/integration.sh --load
# Load-only against an already-running API (CONTROL_USER/CONTROL_PASS from env).
load:
$(GO) run ./scripts/sse-load -base http://127.0.0.1:18080 -clients 120 -duration 5m