Ref: #217
The current tests in crates/spurctld/src/metrics_server.rs (leader_returns_slurm_content_type, leader_returns_openmetrics_content_type, stub_nodes_endpoint_returns_200_on_leader, follower_returns_503) test a #[cfg(test)]-only helper function leader_metrics_response that doesn't exist in production code. They verify that axum's tuple-to-response conversion returns the status code and content-type it was given, e.g.:
let response = leader_metrics_response(true, format, body);
assert_eq!(response.status(), StatusCode::OK);
This is testing axum, not Spur. The leader_metrics_response helper is just:
fn leader_metrics_response(is_leader: bool, format: MetricsExpositionFormat, body: String) -> Response {
if !is_leader { return not_leader_response(); }
metrics_exposition_response(format, body)
}
Both not_leader_response and metrics_exposition_response are trivial one-liner tuple constructions. There's no Spur logic under test.
What to do
- Remove
leader_metrics_response and the four tests that use it.
- Replace with tests that exercise the actual axum handlers (
metrics_jobs, metrics_nodes, etc.) using axum::test::TestClient or by constructing a Router with test state. These would cover the real flow: Raft leader check, snapshot collection, encoding, and correct response format.
- If full handler tests are too heavy for this PR, even just removing the current tests and the dead helper is a net improvement since they add maintenance cost without catching real bugs.
Ref: #217
The current tests in
crates/spurctld/src/metrics_server.rs(leader_returns_slurm_content_type,leader_returns_openmetrics_content_type,stub_nodes_endpoint_returns_200_on_leader,follower_returns_503) test a#[cfg(test)]-only helper functionleader_metrics_responsethat doesn't exist in production code. They verify that axum's tuple-to-response conversion returns the status code and content-type it was given, e.g.:This is testing axum, not Spur. The
leader_metrics_responsehelper is just:Both
not_leader_responseandmetrics_exposition_responseare trivial one-liner tuple constructions. There's no Spur logic under test.What to do
leader_metrics_responseand the four tests that use it.metrics_jobs,metrics_nodes, etc.) usingaxum::test::TestClientor by constructing aRouterwith test state. These would cover the real flow: Raft leader check, snapshot collection, encoding, and correct response format.