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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-10-27 11:13:17 -07:00
parent c114919fd3
commit e32716d3da
+2 -18
View File
@@ -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() {