GRI-1856: real-TCP integration harness for server HTTP tests #92

Merged
vivy merged 1 commit from test/GRI-1856-server-integration-harness into dev 2026-11-09 20:39:30 +00:00
Member

Summary

Adds a real-TCP integration test harness for the server's HTTP surface, as the base every later route's integration test reuses. The existing #[cfg(test)] unit tests in crates/server/src/http.rs use tower::ServiceExt::oneshot, which never opens a socket and never drives axum::serve. These tests do: a real TcpListener, the real server::http::router(), and the same axum::serve(...).with_graceful_shutdown(...) wiring main.rs uses.

  • crates/server/tests/support/mod.rs — TestServer (spawn/trigger-shutdown/shut-down), a minimal raw HTTP/1.1 client over TcpStream, and gated_health_server(), which wraps the real router in test-only middleware that signals when a request has started being handled and waits to be released — so a shutdown test needs no sleep, only a Notify.
  • crates/server/tests/http_integration.rs:
    • health_check_over_real_tcp_returns_ok
    • graceful_shutdown_finishes_an_in_flight_request
    • unknown_route_after_shutdown_signal_on_open_connection_is_not_found (unhappy-path pairing)

Only non-test change: tokio dev-dependency features sync and io-util added to crates/server/Cargo.toml (needed for oneshot/Notify and AsyncRead/WriteExt; production code needs neither).

Fail-first check: temporarily removed the /health route from router() and reran — 2 of 3 tests failed (left: 404, right: 200). Reverted; all 3 pass.

Test plan

  • cargo test -p server --test http_integration — 3/3 pass
  • Fail-first: tests fail against a router with the route removed, pass once restored
  • ./scripts/local-gates.sh — full suite green
## Summary Adds a real-TCP integration test harness for the server's HTTP surface, as the base every later route's integration test reuses. The existing `#[cfg(test)]` unit tests in `crates/server/src/http.rs` use `tower::ServiceExt::oneshot`, which never opens a socket and never drives `axum::serve`. These tests do: a real `TcpListener`, the real `server::http::router()`, and the same `axum::serve(...).with_graceful_shutdown(...)` wiring `main.rs` uses. - `crates/server/tests/support/mod.rs` — `TestServer` (spawn/trigger-shutdown/shut-down), a minimal raw HTTP/1.1 client over `TcpStream`, and `gated_health_server()`, which wraps the real router in test-only middleware that signals when a request has started being handled and waits to be released — so a shutdown test needs no sleep, only a `Notify`. - `crates/server/tests/http_integration.rs`: - `health_check_over_real_tcp_returns_ok` - `graceful_shutdown_finishes_an_in_flight_request` - `unknown_route_after_shutdown_signal_on_open_connection_is_not_found` (unhappy-path pairing) Only non-test change: `tokio` dev-dependency features `sync` and `io-util` added to `crates/server/Cargo.toml` (needed for `oneshot`/`Notify` and `AsyncRead`/`WriteExt`; production code needs neither). Fail-first check: temporarily removed the `/health` route from `router()` and reran — 2 of 3 tests failed (`left: 404, right: 200`). Reverted; all 3 pass. ## Test plan - [x] `cargo test -p server --test http_integration` — 3/3 pass - [x] Fail-first: tests fail against a router with the route removed, pass once restored - [x] `./scripts/local-gates.sh` — full suite green
GRI-1856: real-TCP integration harness for the server's HTTP surface
Some checks failed
CI / the pre-push hook (pull_request) Successful in 24s
CI / cargo fmt (pull_request) Successful in 21s
CI / cargo deny (pull_request) Successful in 47s
CI / cargo deny advisories (pull_request) Failing after 1m1s
CI / repository boundary (pull_request) Successful in 18s
CI / cargo clippy (pull_request) Successful in 10m3s
CI / cargo test (pull_request) Successful in 10m8s
CI / frontend-web (pull_request) Successful in 9m45s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 6s
79e9503fd9
Adds crates/server/tests/support/mod.rs (binds server::http::router() on
127.0.0.1:0, drives it with axum::serve + graceful shutdown the way main.rs
does, and a minimal raw HTTP/1.1 client over a real TcpStream) and
crates/server/tests/http_integration.rs with the first tests built on it:
the /health route over a real socket, graceful shutdown finishing a request
already in flight, and the matching unhappy-path case for an unknown route.

This is the base every later route's integration test reuses as routes land.
vivy merged commit 1d48aa0edb into dev 2026-11-09 20:39:30 +00:00
vivy deleted branch test/GRI-1856-server-integration-harness 2026-11-09 20:39:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!92
No description provided.