From d3ed331e6d17f4ce6189a1c0c1d79ea189e4582b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 27 Oct 2020 11:13:17 -0700 Subject: [PATCH] tests/int: simplify teardown_running_container In its current form, it is complicated, unreliable, and error prone. Using runc delete -f will kill and remove any container, running or not, and it won't error if a container with a given name does not exist. Signed-off-by: Kir Kolyshkin --- tests/integration/helpers.bash | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index b18688f79a8..17825d5de5d 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -468,27 +468,11 @@ function setup_debian() { } function teardown_running_container() { - runc list - # $1 should be a container name such as "test_busybox" - # here we detect "test_busybox "(with one extra blank) to avoid conflict prefix - # e.g. "test_busybox" and "test_busybox_update" - if [[ "${output}" == *"$1 "* ]]; then - runc kill $1 KILL - retry 10 1 eval "__runc state '$1' | grep -q 'stopped'" - runc delete $1 - fi + __runc delete -f "$1" } function teardown_running_container_inroot() { - ROOT=$2 runc list - # $1 should be a container name such as "test_busybox" - # here we detect "test_busybox "(with one extra blank) to avoid conflict prefix - # e.g. "test_busybox" and "test_busybox_update" - if [[ "${output}" == *"$1 "* ]]; then - ROOT=$2 runc kill $1 KILL - retry 10 1 eval "ROOT='$2' __runc state '$1' | grep -q 'stopped'" - ROOT=$2 runc delete $1 - fi + ROOT="$2" __runc delete -f "$1" } function teardown_busybox() {