Skip to content

Fix #2998: deterministic /health JSON body + shared readiness helper#934

Open
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2998-health-readiness-endpoint
Open

Fix #2998: deterministic /health JSON body + shared readiness helper#934
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2998-health-readiness-endpoint

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Resolves #2998. The GET /health route already existed (lib.rs:194 -> api.rs:28) but returned free-form "OK" text; AC requires {"status":"ok"} JSON. The named flaky test test_default_role_ripgrep_integration hardcoded sleep(3s) + port 8085 (#2947, #2998).

Changes (4 files +143/-11, single clean commit 4344dbd95 on origin/main, zero contamination):

  • terraphim_server/src/api.rs: health() -> Json<HealthResponse> = {"status":"ok"} + 2 unit tests
  • terraphim_server/tests/common/mod.rs (new): wait_for_health() shared readiness poller
  • terraphim_server/tests/default_role_integration_test.rs: ephemeral port + wait_for_health + JSON body assert
  • terraphim_server/README.md: document /health contract

Fast gates green: cargo check --tests, cargo fmt --check, cargo clippy --all-targets -- -D warnings, 2 health unit tests pass.

Deferred to next agent (runtime budget): full default_role_integration_test run + 10x consecutive flake check (AC #2998).

Refs #2998, #2947

Co-Authored-By: Claude noreply@anthropic.com

…r (#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant