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 11, 2020
1 parent 6b30d3f commit abcac2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function check_systemd_value() {
unitname=$1
source=$2
expected=$3

if [ $(id -u) = "0" ]; then
current=$(systemctl show $unitname | grep $source)
else
Expand Down Expand Up @@ -231,6 +231,15 @@ function requires() {
skip "test requires ${var}"
fi
;;
cgroups_freezer)
init_cgroup_paths
if [[ "$CGROUP_UNIFIED" == "yes" ]]
then
[ -e "$CGROUP_FREEZER_BASE_PATH/cgroup.freeze" ] || skip "test requires ${var}"
else
[ -e "$CGROUP_FREEZER_BASE_PATH/freezer.state" ] || skip "test requires ${var}"
fi
;;
cgroups_kmem)
init_cgroup_paths
if [ ! -e "${CGROUP_MEMORY_BASE_PATH}/memory.kmem.limit_in_bytes" ]; then
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,23 @@ EOF
cat "$CONTAINER_OUTPUT"
[ -z "$(<"$CONTAINER_OUTPUT")" ]
}

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

# 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
}

0 comments on commit abcac2e

Please sign in to comment.