Skip to content

Commit 728571c

Browse files
committed
tests/int: runc delete: fix flake, enable for rootless
The following failure was observed in CI (on centos-stream-8 in integration-cgroup suite): not ok 42 runc delete (from function `fail' in file tests/integration/helpers.bash, line 338, in test file tests/integration/delete.bats, line 30) `[ "$output" = "" ] || fail "cgroup not cleaned up correctly: $output"' failed .... cgroup not cleaned up correctly: /sys/fs/cgroup/pids/system.slice/tmp-bats\x2drun\x2d68012-runc.IPOypI-state-testbusyboxdelete-runc.zriC8C.mount /sys/fs/cgroup/cpu,cpuacct/system.slice/tmp-bats\x2drun\x2d68012-runc.IPOypI-state-testbusyboxdelete-runc.zriC8C.mount ... Apparently, this is a cgroup systemd creates for a mount unit which appears then runc does internal /proc/self/exe bind-mount. The test case should not take it into account. The second problem with this test is it does not check that cgroup actually exists when the container is running (so checking that it was removed after makes less sense). For example, in rootless mode the cgroup might not have been created. Fix the find arguments to look for a specific cgroup name, and add a check that these arguments are correct (i.e. the cgroup is found when the container is running). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent ec9e81b commit 728571c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/integration/delete.bats

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ function teardown() {
1111
}
1212

1313
@test "runc delete" {
14+
# Need a permission to create a cgroup.
15+
# XXX(@kolyshkin): currently this test does not handle rootless when
16+
# fs cgroup driver is used, because in this case cgroup (with a
17+
# predefined name) is created by tests/rootless.sh, not by runc.
18+
[[ "$ROOTLESS" -ne 0 ]] && requires systemd
19+
set_resources_limit
20+
1421
runc run -d --console-socket "$CONSOLE_SOCKET" testbusyboxdelete
1522
[ "$status" -eq 0 ]
1623

1724
testcontainer testbusyboxdelete running
25+
# Ensure the find statement used later is correct.
26+
output=$(find /sys/fs/cgroup -name testbusyboxdelete -o -name \*-testbusyboxdelete.scope)
27+
if [ -z "$output" ]; then
28+
fail "expected cgroup not found"
29+
fi
1830

1931
runc kill testbusyboxdelete KILL
2032
[ "$status" -eq 0 ]
@@ -26,7 +38,7 @@ function teardown() {
2638
runc state testbusyboxdelete
2739
[ "$status" -ne 0 ]
2840

29-
output=$(find /sys/fs/cgroup -wholename '*testbusyboxdelete*' -type d)
41+
output=$(find /sys/fs/cgroup -name testbusyboxdelete -o -name \*-testbusyboxdelete.scope)
3042
[ "$output" = "" ] || fail "cgroup not cleaned up correctly: $output"
3143
}
3244

0 commit comments

Comments
 (0)