Skip to content

Commit

Permalink
tests: add integration test for paused-and-updated containers
Browse files Browse the repository at this point in the history
Such containers should remain paused after the update. This has
historically been true, but this helps ensure that the systemd cgroup
changes (freezing the container during SetUnitProperties) don't break
this behaviour.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
  • Loading branch information
cyphar committed May 13, 2020
1 parent 2c59d29 commit 9984829
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
32 changes: 23 additions & 9 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -145,51 +145,65 @@ function fail() {
# support it, the test is skipped with a message.
function requires() {
for var in "$@"; do
local skip_me
case $var in
criu)
if [ ! -e "$CRIU" ]; then
skip "test requires ${var}"
skip_me=1
fi
;;
root)
if [ "$ROOTLESS" -ne 0 ]; then
skip "test requires ${var}"
skip_me=1
fi
;;
rootless)
if [ "$ROOTLESS" -eq 0 ]; then
skip "test requires ${var}"
skip_me=1
fi
;;
rootless_idmap)
if [[ "$ROOTLESS_FEATURES" != *"idmap"* ]]; then
skip "test requires ${var}"
skip_me=1
fi
;;
rootless_cgroup)
if [[ "$ROOTLESS_FEATURES" != *"cgroup"* ]]; then
skip "test requires ${var}"
skip_me=1
fi
;;
rootless_no_cgroup)
if [[ "$ROOTLESS_FEATURES" == *"cgroup"* ]]; then
skip "test requires ${var}"
skip_me=1
fi
;;
cgroups_kmem)
if [ ! -e "$KMEM" ]; then
skip "Test requires ${var}"
skip_me=1
fi
;;
cgroups_rt)
if [ ! -e "$RT_PERIOD" ]; then
skip "Test requires ${var}"
skip_me=1
fi
;;
systemd)
if [ -z "${RUNC_USE_SYSTEMD}" ]; then
skip_me=1
fi
;;
no_systemd)
if [ -n "${RUNC_USE_SYSTEMD}" ]; then
skip_me=1
fi
;;
*)
fail "BUG: Invalid requires ${var}."
fail "BUG: Invalid requires $var."
;;
esac
if [ -n "$skip_me" ]; then
skip "test requires $var"
fi
done
}

Expand Down
14 changes: 10 additions & 4 deletions tests/integration/pause.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ function teardown() {
}

@test "runc pause and resume" {
# XXX: currently cgroups require root containers.
requires root
if [[ "$ROOTLESS" -ne 0 ]]
then
requires rootless_cgroup
set_cgroups_path "$BUSYBOX_BUNDLE"
fi

# run busybox detached
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
Expand All @@ -37,8 +40,11 @@ function teardown() {
}

@test "runc pause and resume with nonexist container" {
# XXX: currently cgroups require root containers.
requires root
if [[ "$ROOTLESS" -ne 0 ]]
then
requires rootless_cgroup
set_cgroups_path "$BUSYBOX_BUNDLE"
fi

# run test_busybox detached
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,26 @@ EOF
cat "$CONTAINER_OUTPUT"
[ -z "$(<"$CONTAINER_OUTPUT")" ]
}

@test "update paused container" {
[[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup

# Run the container in the background.
runc run -d --console-socket "$CONSOLE_SOCKET" test_update
[ "$status" -eq 0 ]

# Pause the container.
runc pause test_update
[ "$status" -eq 0 ]

# Trigger an unrelated update.
runc update --pids-limit 30 test_update
[ "$status" -eq 0 ]

# The container should still be paused.
testcontainer test_update paused

# Resume the container.
runc resume test_update
[ "$status" -eq 0 ]
}

0 comments on commit 9984829

Please sign in to comment.