Skip to content

Commit

Permalink
[tests] kill child processes on exit
Browse files Browse the repository at this point in the history
It looks like some child processes weren't being killed at the end of
tests, leaving them hanging forever. Fix that by killing them at the end
of the test.

Detected by the new test runner I'm writing.

Closes: aptos-labs#7970
  • Loading branch information
sunshowers authored and bors-libra committed Mar 18, 2021
1 parent 0db3759 commit 5ab0e10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 10 additions & 2 deletions consensus/safety-rules/tests/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ fn test_consensus_state() {
.stdin(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit());
command.spawn().unwrap();
let mut child = command.spawn().unwrap();

let safety_rules_manager = SafetyRulesManager::new(&config);
let mut safety_rules = safety_rules_manager.client();
safety_rules.consensus_state().unwrap();
let consensus_state = safety_rules.consensus_state();

// Ensure the safety-rules subprocess is killed whether the test passes or fails.
// Not doing this would result in a zombie process.
child.kill().expect("could not kill safety-rules process");
child
.wait()
.expect("could not wait on safety-rules process");
consensus_state.unwrap();
}
17 changes: 12 additions & 5 deletions execution/execution-correctness/tests/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ fn test_rest() {
.stdin(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit());
command.spawn().unwrap();
let mut child = command.spawn().unwrap();

// Run a command as a client to verify the service is running
ExecutionCorrectnessManager::new(&config)
.client()
.reset()
.unwrap();
let res = ExecutionCorrectnessManager::new(&config).client().reset();

// Ensure the safety-rules subprocess is killed whether the test passes or fails.
// Not doing this would result in a zombie process.
child
.kill()
.expect("could not kill execution-correctness process");
child
.wait()
.expect("could not wait on execution-correctness process");
res.unwrap();
}

0 comments on commit 5ab0e10

Please sign in to comment.