From 3790044931565e3636941182f03ae74da93a0190 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 07:10:09 +0300 Subject: [PATCH] Media: the window-reread test times its wait from before the stop's sleep (#1382) the_window_reread_waits_for_the_outgoing_stop_within_its_bound started its clock inside the spawned reader thread, while the 250 ms sleep before stop.finish() runs on the test thread right after the spawn. A reader scheduled late began timing after the sleep had started, so a read that correctly waited for the stop measured under 250 ms. CI's hostsim job failed on it on 2026-11-12 and 2026-11-14 ("it waited for the stop: 249.3ms"). The clock now starts before std::thread::scope, so a correct wait always measures at least 250 ms. The bound, the assertion and the window_reads() checks are unchanged. A 50 ms delay injected at the start of the reader fails the old code (204 ms) and passes the new one. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit a3ea02c1f2609d24b4001a432c11c3b8580ee532) --- .../media/src/route/decision_queue_predecessor_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust-modules/media/src/route/decision_queue_predecessor_tests.rs b/rust-modules/media/src/route/decision_queue_predecessor_tests.rs index 5c885e707f..a2664201b4 100644 --- a/rust-modules/media/src/route/decision_queue_predecessor_tests.rs +++ b/rust-modules/media/src/route/decision_queue_predecessor_tests.rs @@ -301,9 +301,13 @@ fn the_window_reread_waits_for_the_outgoing_stop_within_its_bound() { // The outgoing episode's stop is announced and still on its way. let stop = TIMELINE_STOP_FENCE.announce(); let waiting = continuation.clone().awaiting(TIMELINE_STOP_FENCE.announced()); + // The clock starts HERE, before the reader exists and so before the sleep below can begin: a + // reader the scheduler starts late (a loaded runner) must not shorten what this measures. Taken + // inside the reader, a late start put its clock after the sleep's, and a read that did wait for + // the stop measured under 250 ms. + let started = std::time::Instant::now(); let read = std::thread::scope(|scope| { let reader = scope.spawn(|| { - let started = std::time::Instant::now(); let _ = waiting.refreshed_within(client, Duration::from_secs(20)); started.elapsed() });