mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-25 10:43:15 +00:00
tests/nydus: refactor the teardown()
This refactor the teardown() of tests/integration/nydus/nydus_tests.sh: * Moved boilerplate code that kill process to a loop; * Doesn't leave teardown() if a process failed to get killed, so that other clean up routines are ran; * Check if the pid exist then attempt to kill the process, so avoid this misleading message: ``` Usage: kill [options] <pid> [...] Options: <pid> [...] send signal to every <pid> listed -<signal>, -s, --signal <signal> specify the <signal> to be sent -q, --queue <value> integer value to be sent with the signal -l, --list=[<signal>] list all signal names, or convert one to a name -L, --table list all signal names in a nice table -h, --help display this help and exit -V, --version output version information and exit For more details see kill(1). ``` Fixes #8948 Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
@@ -156,15 +156,21 @@ function run_test() {
|
|||||||
|
|
||||||
function teardown() {
|
function teardown() {
|
||||||
echo "Running teardown"
|
echo "Running teardown"
|
||||||
|
local rc=0
|
||||||
|
|
||||||
# kill nydus-snapshotter
|
local pid
|
||||||
bin=containerd-nydus-grpc
|
for bin in containerd-nydus-grpc nydusd; do
|
||||||
sudo -E kill -9 $(pidof $bin) || true
|
pid=$(pidof $bin)
|
||||||
[ "$(pidof $bin)" == "" ] || die "$bin is running"
|
if [ -n "$pid" ]; then
|
||||||
|
echo "Killing $bin processes"
|
||||||
bin=nydusd
|
# shellcheck disable=SC2086
|
||||||
sudo -E kill -9 $(pidof $bin) || true
|
sudo -E kill -9 $pid || true
|
||||||
[ "$(pidof $bin)" == "" ] || die "$bin is running"
|
if [ -n "$(pidof $bin)" ]; then
|
||||||
|
echo "$bin is still running ($pid) but it should not"
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# restore kata configuratiom.toml if needed
|
# restore kata configuratiom.toml if needed
|
||||||
if [ "${need_restore_kata_config}" == "true" ]; then
|
if [ "${need_restore_kata_config}" == "true" ]; then
|
||||||
@@ -180,8 +186,9 @@ function teardown() {
|
|||||||
sudo rm "$containerd_config"
|
sudo rm "$containerd_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean_env_ctr
|
clean_env_ctr || rc=1
|
||||||
check_processes
|
check_processes
|
||||||
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
trap teardown EXIT
|
trap teardown EXIT
|
||||||
|
Reference in New Issue
Block a user