Fix #2998: deterministic /health JSON body + shared readiness helper#934
Open
AlexMikhalev wants to merge 1 commit into
Open
Fix #2998: deterministic /health JSON body + shared readiness helper#934AlexMikhalev wants to merge 1 commit into
AlexMikhalev wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #2998. The
GET /healthroute already existed (lib.rs:194->api.rs:28) but returned free-form"OK"text; AC requires{"status":"ok"}JSON. The named flaky testtest_default_role_ripgrep_integrationhardcodedsleep(3s)+ port8085(#2947, #2998).Changes (4 files +143/-11, single clean commit
4344dbd95on origin/main, zero contamination):terraphim_server/src/api.rs:health()->Json<HealthResponse>={"status":"ok"}+ 2 unit teststerraphim_server/tests/common/mod.rs(new):wait_for_health()shared readiness pollerterraphim_server/tests/default_role_integration_test.rs: ephemeral port +wait_for_health+ JSON body assertterraphim_server/README.md: document/healthcontractFast 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_testrun + 10x consecutive flake check (AC #2998).Refs #2998, #2947
Co-Authored-By: Claude noreply@anthropic.com