From 8d0b5b8d1d983df8ec42a6288105dcf19d9d98b1 Mon Sep 17 00:00:00 2001 From: Vassiliy Yegorov Date: Tue, 9 Jun 2026 20:05:23 +0700 Subject: [PATCH] test(daemon): make socket/pty integration tests robust under parallel load Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/spaceshd/src/server.rs | 8 ++++---- crates/spaceshd/src/surface.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/spaceshd/src/server.rs b/crates/spaceshd/src/server.rs index dde3eaf..2818641 100644 --- a/crates/spaceshd/src/server.rs +++ b/crates/spaceshd/src/server.rs @@ -309,7 +309,7 @@ mod tests { } } - #[tokio::test] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn open_new_surface_attach_streams_output() { let dir = tempdir_path(); let sock = dir.join("sock"); @@ -335,7 +335,7 @@ mod tests { // Now read frames looking for an Output evt containing STREAM_OK. let mut got = String::new(); - let deadline = tokio::time::Instant::now() + tokio::time::Duration::from_secs(2); + let deadline = tokio::time::Instant::now() + tokio::time::Duration::from_secs(6); while tokio::time::Instant::now() < deadline { if let Ok(Ok(Some(Envelope::Evt(Evt::Output { bytes, .. })))) = tokio::time::timeout(tokio::time::Duration::from_millis(200), read_frame(&mut s)).await { @@ -346,7 +346,7 @@ mod tests { assert!(got.contains("STREAM_OK"), "got: {got:?}"); } - #[tokio::test] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn unknown_surface_returns_not_found() { let dir = tempdir_path(); let sock = dir.join("sock"); @@ -380,7 +380,7 @@ mod tests { } async fn wait_for_socket(sock: &Path) { - for _ in 0..100 { + for _ in 0..300 { if UnixStream::connect(sock).await.is_ok() { return; } tokio::time::sleep(tokio::time::Duration::from_millis(20)).await; } diff --git a/crates/spaceshd/src/surface.rs b/crates/spaceshd/src/surface.rs index e3d06bf..95d0b9a 100644 --- a/crates/spaceshd/src/surface.rs +++ b/crates/spaceshd/src/surface.rs @@ -74,7 +74,7 @@ mod tests { } } - #[tokio::test] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn attach_receives_output() { let pty = PtyHandle::spawn(spec("printf HELLO; sleep 0.3")).unwrap(); let (exit_tx, _exit_rx) = mpsc::unbounded_channel(); @@ -97,7 +97,7 @@ mod tests { assert!(String::from_utf8_lossy(&collected).contains("HELLO")); } - #[tokio::test] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn exit_is_reported() { let pty = PtyHandle::spawn(spec("exit 7")).unwrap(); let (exit_tx, mut exit_rx) = mpsc::unbounded_channel();