H: dedupe integration test block
This commit is contained in:
1 parent
33a49533a3
commit
7252b0c966
1 file changed
+33
-36
+33
-36
@@ -403,6 +403,29 @@ fn sigterm_with_open_sse_client_exits_promptly() {
|
|||||||
assert!(started, "server did not stay up on any of three ports");
|
assert!(started, "server did not stay up on any of three ports");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Signals the child and waits for a successful exit. Anything still running
|
||||||
|
/// after `bound` is killed and the test fails with `panic_msg`.
|
||||||
|
fn sigterm_and_wait(child: &mut std::process::Child, bound: Duration, panic_msg: &str) {
|
||||||
|
let pid = child.id().to_string();
|
||||||
|
assert!(std::process::Command::new("kill")
|
||||||
|
.args(["-TERM", &pid])
|
||||||
|
.status()
|
||||||
|
.unwrap()
|
||||||
|
.success());
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
loop {
|
||||||
|
if let Some(st) = child.try_wait().unwrap() {
|
||||||
|
assert!(st.success(), "exit status {st}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if start.elapsed() > bound {
|
||||||
|
let _ = child.kill();
|
||||||
|
panic!("{panic_msg}");
|
||||||
|
}
|
||||||
|
std::thread::sleep(Duration::from_millis(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// One attempt on a fresh port. `false` means the child exited before it
|
/// One attempt on a fresh port. `false` means the child exited before it
|
||||||
/// served, which only happens when the probed port was taken by someone else.
|
/// served, which only happens when the probed port was taken by someone else.
|
||||||
fn sse_stream_then_sigterm() -> bool {
|
fn sse_stream_then_sigterm() -> bool {
|
||||||
@@ -456,24 +479,11 @@ fn sse_stream_then_sigterm_on(port: u16) -> bool {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let mut buf = [0u8; 512];
|
let mut buf = [0u8; 512];
|
||||||
let _ = conn.read(&mut buf);
|
let _ = conn.read(&mut buf);
|
||||||
let pid = child.id().to_string();
|
sigterm_and_wait(
|
||||||
assert!(std::process::Command::new("kill")
|
&mut child,
|
||||||
.args(["-TERM", &pid])
|
Duration::from_secs(10),
|
||||||
.status()
|
"process did not exit within 10s of SIGTERM",
|
||||||
.unwrap()
|
);
|
||||||
.success());
|
|
||||||
let start = std::time::Instant::now();
|
|
||||||
loop {
|
|
||||||
if let Some(st) = child.try_wait().unwrap() {
|
|
||||||
assert!(st.success(), "exit status {st}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if start.elapsed() > Duration::from_secs(10) {
|
|
||||||
let _ = child.kill();
|
|
||||||
panic!("process did not exit within 10s of SIGTERM");
|
|
||||||
}
|
|
||||||
std::thread::sleep(Duration::from_millis(50));
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,22 +589,9 @@ fn sigterm_with_inflight_mcp_tail_exits_within_bound() {
|
|||||||
Some(&sid),
|
Some(&sid),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let pid = child.id().to_string();
|
sigterm_and_wait(
|
||||||
assert!(std::process::Command::new("kill")
|
&mut child,
|
||||||
.args(["-TERM", &pid])
|
Duration::from_secs(25),
|
||||||
.status()
|
"process did not exit within the shutdown bound",
|
||||||
.unwrap()
|
);
|
||||||
.success());
|
|
||||||
let start = std::time::Instant::now();
|
|
||||||
loop {
|
|
||||||
if let Some(st) = child.try_wait().unwrap() {
|
|
||||||
assert!(st.success(), "exit status {st}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if start.elapsed() > Duration::from_secs(25) {
|
|
||||||
let _ = child.kill();
|
|
||||||
panic!("process did not exit within the shutdown bound");
|
|
||||||
}
|
|
||||||
std::thread::sleep(Duration::from_millis(50));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user