You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(server): deterministic /health JSON body + shared readiness helper (#2998)
Resolves #2998. The /health route already existed (lib.rs:194 -> api.rs:28)
but returned free-form "OK" text; the named flaky test
test_default_role_ripgrep_integration hardcoded sleep(3s) + port 8085, which
was the documented root cause of the flake (#2947, #2998).
Changes (4 files):
- api.rs: health() now returns Json<HealthResponse> = {"status":"ok"}
(deterministic contract for JSON-parsing harnesses). Added 2 unit tests
locking the body serialisation and handler output.
- tests/common/mod.rs (new): wait_for_health(addr, max_attempts) shared
readiness poller (250ms interval), replacing per-test sleep heuristics.
- tests/default_role_integration_test.rs: bind ephemeral port via
TcpListener("127.0.0.1:0"); replace sleep(3s) with wait_for_health();
assert the JSON body contract (not just status code).
- README.md: document the /health endpoint and its contract.
Verification:
- cargo test -p terraphim_server --lib health: 2 passed
- cargo clippy -p terraphim_server --all-targets -- -D warnings: exit 0
- cargo fmt -p terraphim_server -- --check: exit 0
- cargo check -p terraphim_server --tests: exit 0
No new dependencies (issue constraint). Other tests' port hardcoding left
untouched (each tracks its own flake issue, e.g. #2947).
Partial: full integration test run + 10x consecutive flake check deferred to
next agent (runtime budget). See handover envelope.
Refs #2998
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments