mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-10-29 15:02:30 +00:00
test: Wait for children to exit before finishing an integration test
Some integration tests start servers on predictable ports, and then the servers are killed at exit. However, we currently don't want for them to die. This can cause races where the next test starts while the previous daemons are still in the process of exiting, causing flakiness. This patch fixes the problem by waiting for the child processes to exit before exiting the test.
This commit is contained in:
+5
-1
@@ -26,7 +26,11 @@ function init() {
|
||||
# Set traps to kill our subprocesses when we exit (for any reason).
|
||||
trap ":" TERM # Avoid the EXIT handler from killing bash.
|
||||
trap "exit 2" INT # Ctrl-C, make sure we fail in that case.
|
||||
trap "kill 0" EXIT # Kill children on exit.
|
||||
# Kill children on exit, and wait for them to finish, so they don't
|
||||
# interfere with the next test (e.g. by still listening on a port).
|
||||
# "wait" returns early (and with an error) if we get a signal while
|
||||
# waiting, so we loop until it completes.
|
||||
trap "kill 0; until wait; do :; done" EXIT
|
||||
}
|
||||
|
||||
function chasquid() {
|
||||
|
||||
Reference in New Issue
Block a user