Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generalize slow-timeout.grace-period to all shutdown events #1039

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions nextest-runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@
// attempt to terminate the slow test.
// as there is a race between shutting down a slow test and its own completion
// we silently ignore errors to avoid printing false warnings.
imp::terminate_child(&mut child, TerminateMode::Timeout(slow_timeout.grace_period), forward_receiver, job.as_ref()).await;
imp::terminate_child(&mut child, TerminateMode::Timeout, forward_receiver, job.as_ref(), slow_timeout.grace_period).await;
status = Some(ExecutionResult::Timeout);
if slow_timeout.grace_period.is_zero() {
break child.wait().await;
Expand All @@ -821,6 +821,7 @@
interval_sleep.as_mut(),
forward_receiver,
job.as_ref(),
slow_timeout.grace_period
).await;
}
}
Expand Down Expand Up @@ -1024,7 +1025,7 @@
// attempt to terminate the slow test.
// as there is a race between shutting down a slow test and its own completion
// we silently ignore errors to avoid printing false warnings.
imp::terminate_child(&mut child, TerminateMode::Timeout(slow_timeout.grace_period), forward_receiver, job.as_ref()).await;
imp::terminate_child(&mut child, TerminateMode::Timeout, forward_receiver, job.as_ref(), slow_timeout.grace_period).await;
status = Some(ExecutionResult::Timeout);
if slow_timeout.grace_period.is_zero() {
break child.wait().await;
Expand All @@ -1042,6 +1043,7 @@
interval_sleep.as_mut(),
forward_receiver,
job.as_ref(),
slow_timeout.grace_period
).await;
}
};
Expand Down Expand Up @@ -1114,6 +1116,7 @@
#[allow(unused_mut, unused_variables)] mut interval_sleep: Pin<&mut PausableSleep>,
forward_receiver: &mut broadcast::Receiver<SignalForwardEvent>,
job: Option<&imp::Job>,
grace_period: Duration,

Check warning on line 1119 in nextest-runner/src/runner.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/runner.rs#L1119

Added line #L1119 was not covered by tests
) {
// The sender stays open longer than the whole loop, and the buffer is big
// enough for all messages ever sent through this channel, so a RecvError
Expand Down Expand Up @@ -1143,7 +1146,14 @@
}
}
SignalForwardEvent::Shutdown(event) => {
imp::terminate_child(child, TerminateMode::Signal(event), forward_receiver, job).await;
imp::terminate_child(
child,
TerminateMode::Signal(event),
forward_receiver,
job,
grace_period,
)
.await;

Check warning on line 1156 in nextest-runner/src/runner.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/runner.rs#L1149-L1156

Added lines #L1149 - L1156 were not covered by tests
}
}
}
Expand Down Expand Up @@ -2177,10 +2187,11 @@
mode: TerminateMode,
_forward_receiver: &mut broadcast::Receiver<SignalForwardEvent>,
job: Option<&Job>,
_grace_period: Duration,
) {
// Ignore signal events since Windows propagates them to child processes (this may change if
// we start assigning processes to groups on Windows).
if !matches!(mode, TerminateMode::Timeout(_)) {
if !matches!(mode, TerminateMode::Timeout) {
return;
}
if let Some(job) = job {
Expand Down Expand Up @@ -2262,19 +2273,13 @@
mode: TerminateMode,
forward_receiver: &mut broadcast::Receiver<SignalForwardEvent>,
_job: Option<&Job>,
grace_period: Duration,
) {
if let Some(pid) = child.id() {
let pid = pid as i32;
let mut grace_period = Duration::from_secs(10);
let term_signal = match mode {
TerminateMode::Timeout(grace) => {
grace_period = grace;
if grace.is_zero() {
SIGKILL
} else {
SIGTERM
}
}
_ if grace_period.is_zero() => SIGKILL,
TerminateMode::Timeout => SIGTERM,
TerminateMode::Signal(ShutdownForwardEvent::Once(ShutdownEvent::Hangup)) => SIGHUP,
TerminateMode::Signal(ShutdownForwardEvent::Once(ShutdownEvent::Term)) => SIGTERM,
TerminateMode::Signal(ShutdownForwardEvent::Once(ShutdownEvent::Interrupt)) => {
Expand Down Expand Up @@ -2347,7 +2352,7 @@

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum TerminateMode {
Timeout(Duration),
Timeout,
Signal(ShutdownForwardEvent),
}

Expand Down