Compare commits

...

1 Commits

Author SHA1 Message Date
Brennen Herbruck 6298a09327 Control server test: wait for the stopped listener's port to be free instead of checking at one instant
a_stopped_listener_closes_its_port_and_its_connections re-bound the port straight after stop() returned. The listener thread closes its socket when it notices the stop, which on a loaded machine can be a moment later, so the bind failed ('the port is free again') and failed a queue batch. It now retries the bind for up to two seconds. With the whole control test binary at 16 threads, the test failed in 18 of 200 runs before and 0 of 200 after.

Changes a default: no

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 05:39:43 -05:00
+9 -1
View File
@@ -1417,6 +1417,14 @@ mod tests {
}
}
assert!(started.elapsed() < Duration::from_secs(3), "before the token wait runs out");
assert!(TcpListener::bind(("127.0.0.1", port)).is_ok(), "the port is free again");
// The listener thread closes its socket when it notices the stop; on a loaded machine that can
// take a moment after `stop()` returns. Wait for the port to be free, not for one instant.
let freed = Instant::now();
let mut bound = TcpListener::bind(("127.0.0.1", port));
while bound.is_err() && freed.elapsed() < Duration::from_secs(2) {
std::thread::sleep(Duration::from_millis(10));
bound = TcpListener::bind(("127.0.0.1", port));
}
assert!(bound.is_ok(), "the port is free again: {:?}", bound.err());
}
}