Flaky test: channels::tests::health::classify_health_timeout races real time under CI load
Summary
channels::tests::health::classify_health_timeout (crates/openhuman-core/src/channels/tests/health.rs:21) is timing-dependent and fails under CI load:
thread 'channels::tests::health::classify_health_timeout' panicked at crates/openhuman-core/src/channels/tests/health.rs:28:5:
assertion `left == right` failed
left: Healthy
right: TimeoutSeen in run 36446758988 (Lanes / CI Fast (EX63) → rust-core-coverage, nextest: 11119 passed, 1 failed; the lane peaked at 16.8 GiB) on #6746. The same lane passed all 11120 tests at the previous head, and the only change between the two was one line in crates/openhuman-app/Cargo.lock.
Cause
The test races real time:
let result = tokio::time::timeout(Duration::from_millis(1), async {
tokio::time::sleep(Duration::from_millis(20)).await;
true
})
.await;tokio::time::Timeout::poll polls the inner future before checking its deadline (tokio 1.53.1, src/time/timeout.rs:216: "First, try polling the future"). If the runtime thread stalls for more than 20 ms before the timeout is next polled, both deadlines have passed. The inner sleep then completes first, the result is Ok(true), and it classifies as Healthy.
Suggested fix (not done here)
Make the test independent of wall-clock scheduling. For example:
#[tokio::test(start_paused = true)](paused clock; auto-advance fires the 1 ms timeout deterministically); or- time out a future that never completes, e.g.
std::future::pending::<bool>(), so only the deadline can resolve it.
Source: tinyhumansai/openhuman