From 728ef19a4288ac5a6d2ab6ba45aa572aac205366 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 25 Oct 2026 15:47:55 -0700 Subject: [PATCH] Tests: two control server line-deadline tests pass on a loaded machine buffered_partial_control_line_also_expires and stalled_control_line_is_refused_with_the_reason used short_timeouts(), which gives a connection 150 ms before its first byte and 150 ms to write a reply. When a test thread pauses longer than that, the server closes the connection without a reply, the client reads end of stream, and the test fails parsing an empty line (CI run 40212833958 on #4152). The two tests now use line_timeouts(): the same 120 ms line deadline, with idle and write budgets of 10 s. The other short_timeouts() tests are unchanged. --- apps/vectorcraft/src/control_server.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/vectorcraft/src/control_server.rs b/apps/vectorcraft/src/control_server.rs index e163ffb95..c7886df3e 100644 --- a/apps/vectorcraft/src/control_server.rs +++ b/apps/vectorcraft/src/control_server.rs @@ -296,6 +296,14 @@ mod tests { ConnectionTimeouts { idle: Duration::from_millis(150), line: Duration::from_millis(120), write: Duration::from_millis(150) } } + /// The short line deadline, with idle and reply budgets longer than the tests' 3 s waits. On a + /// busy machine either thread can pause for more than 150 ms between connecting and sending, or + /// between starting a reply and writing it, and a short budget then closes the connection with no + /// reply. + fn line_timeouts() -> ConnectionTimeouts { + ConnectionTimeouts { idle: Duration::from_secs(10), write: Duration::from_secs(10), ..short_timeouts() } + } + fn socket_fixture( timeouts: ConnectionTimeouts, handle: impl FnMut(String, Value) -> Option + Send + 'static, @@ -344,7 +352,7 @@ mod tests { /// A line that stalls is refused in words a client's author can act on, not the system's. #[test] fn stalled_control_line_is_refused_with_the_reason() { - let (mut client, done, worker) = socket_fixture(short_timeouts(), |_, _| panic!("incomplete requests must not execute")); + let (mut client, done, worker) = socket_fixture(line_timeouts(), |_, _| panic!("incomplete requests must not execute")); client.write_all(b"{\"method\":").unwrap(); let mut line = String::new(); BufReader::new(client.try_clone().unwrap()).read_line(&mut line).unwrap(); @@ -419,7 +427,7 @@ mod tests { #[test] fn buffered_partial_control_line_also_expires() { - let (mut client, done, worker) = socket_fixture(short_timeouts(), |_, _| Some(json!({"ok": true}))); + let (mut client, done, worker) = socket_fixture(line_timeouts(), |_, _| Some(json!({"ok": true}))); client.write_all(b"{\"id\":1,\"method\":\"inspect\"}\n{").unwrap(); let mut line = String::new(); BufReader::new(client.try_clone().unwrap()).read_line(&mut line).unwrap();