test(daemon): make socket/pty integration tests robust under parallel load
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -309,7 +309,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn open_new_surface_attach_streams_output() {
|
async fn open_new_surface_attach_streams_output() {
|
||||||
let dir = tempdir_path();
|
let dir = tempdir_path();
|
||||||
let sock = dir.join("sock");
|
let sock = dir.join("sock");
|
||||||
@@ -335,7 +335,7 @@ mod tests {
|
|||||||
|
|
||||||
// Now read frames looking for an Output evt containing STREAM_OK.
|
// Now read frames looking for an Output evt containing STREAM_OK.
|
||||||
let mut got = String::new();
|
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 {
|
while tokio::time::Instant::now() < deadline {
|
||||||
if let Ok(Ok(Some(Envelope::Evt(Evt::Output { bytes, .. })))) =
|
if let Ok(Ok(Some(Envelope::Evt(Evt::Output { bytes, .. })))) =
|
||||||
tokio::time::timeout(tokio::time::Duration::from_millis(200), read_frame(&mut s)).await {
|
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:?}");
|
assert!(got.contains("STREAM_OK"), "got: {got:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn unknown_surface_returns_not_found() {
|
async fn unknown_surface_returns_not_found() {
|
||||||
let dir = tempdir_path();
|
let dir = tempdir_path();
|
||||||
let sock = dir.join("sock");
|
let sock = dir.join("sock");
|
||||||
@@ -380,7 +380,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_for_socket(sock: &Path) {
|
async fn wait_for_socket(sock: &Path) {
|
||||||
for _ in 0..100 {
|
for _ in 0..300 {
|
||||||
if UnixStream::connect(sock).await.is_ok() { return; }
|
if UnixStream::connect(sock).await.is_ok() { return; }
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(20)).await;
|
tokio::time::sleep(tokio::time::Duration::from_millis(20)).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn attach_receives_output() {
|
async fn attach_receives_output() {
|
||||||
let pty = PtyHandle::spawn(spec("printf HELLO; sleep 0.3")).unwrap();
|
let pty = PtyHandle::spawn(spec("printf HELLO; sleep 0.3")).unwrap();
|
||||||
let (exit_tx, _exit_rx) = mpsc::unbounded_channel();
|
let (exit_tx, _exit_rx) = mpsc::unbounded_channel();
|
||||||
@@ -97,7 +97,7 @@ mod tests {
|
|||||||
assert!(String::from_utf8_lossy(&collected).contains("HELLO"));
|
assert!(String::from_utf8_lossy(&collected).contains("HELLO"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn exit_is_reported() {
|
async fn exit_is_reported() {
|
||||||
let pty = PtyHandle::spawn(spec("exit 7")).unwrap();
|
let pty = PtyHandle::spawn(spec("exit 7")).unwrap();
|
||||||
let (exit_tx, mut exit_rx) = mpsc::unbounded_channel();
|
let (exit_tx, mut exit_rx) = mpsc::unbounded_channel();
|
||||||
|
|||||||
Reference in New Issue
Block a user