From 1e23343506ebcb4116ce83ad04d64cecd7c3260c Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 1 Nov 2024 18:37:57 +0000 Subject: [PATCH] testsuite: add test that ensures the IMP waits for an empty cgroup Problem: No test ensures that imp exec waits for the job cgroup to be empty before exiting. Add a test that sends SIGTERM to an IMP managing a process tree. This kills the immediate child of the IMP, and the IMP must wait until SIGUSR1 is sent, which terminates the cgroup with SIGKILL. --- t/t2000-imp-exec.t | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/t2000-imp-exec.t b/t/t2000-imp-exec.t index 98a5435..0cfd3a4 100755 --- a/t/t2000-imp-exec.t +++ b/t/t2000-imp-exec.t @@ -329,6 +329,22 @@ test_expect_success SUDO,CGROUPFS,NO_CHAIN_LINT \ test_must_be_empty ${CGROUP_PATH}/cgroup.procs ' +test_expect_success SUDO,CGROUPFS,NO_CHAIN_LINT \ + 'flux-imp exec: SIGUSR1 waits for cgroup to be empty' ' + fake_input_sign_none | \ + $SUDO FLUX_IMP_CONFIG_PATTERN=sign-none.toml \ + ./run-in-cgroup.sh "$CGROUP_PATH" \ + $flux_imp exec $(pwd)/sleeper.sh 15 & + imp_pid=$! && + test_when_finished "rm -f sleeper.pid" && + wait_for_file sleeper.pid && + kill -TERM $(cat sleeper.pid) && + sleep .5 && + kill -USR1 $(cat sleeper.pid) && + test_expect_code 143 wait $imp_pid && + test_must_be_empty ${CGROUP_PATH}/cgroup.procs +' + $flux_imp version | grep -q pam || test_set_prereq NO_PAM test_expect_success NO_PAM,SUDO 'flux-imp exec: fails if not built with PAM but pam-support=true' ' ( export FLUX_IMP_CONFIG_PATTERN=pam-test.toml &&