diff --git a/tests/integration/cgroups.bats b/tests/integration/cgroups.bats index 9cd95a7d..9ab6f432 100644 --- a/tests/integration/cgroups.bats +++ b/tests/integration/cgroups.bats @@ -3,7 +3,7 @@ load helpers TEST_CGROUP_NAME="runc-cgroups-integration-test" -CGROUP_MEMORY="${CGROUP_BASE_PATH}/${TEST_CGROUP_NAME}" +CGROUP_MEMORY="${CGROUP_MEMORY_BASE_PATH}/${TEST_CGROUP_NAME}" function teardown() { rm -f $BATS_TMPDIR/runc-update-integration-test.json diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 1903eda1..e4c2cb93 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -33,10 +33,12 @@ ROOT="$BATS_TMPDIR/runc" CONSOLE_SOCKET="$BATS_TMPDIR/console.sock" # Cgroup mount -CGROUP_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') +CGROUP_MEMORY_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') +CGROUP_CPU_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') # CONFIG_MEMCG_KMEM support -KMEM="${CGROUP_BASE_PATH}/memory.kmem.limit_in_bytes" +KMEM="${CGROUP_MEMORY_BASE_PATH}/memory.kmem.limit_in_bytes" +RT_PERIOD="${CGROUP_CPU_BASE_PATH}/cpu.rt_period_us" # Wrapper for runc. function runc() { @@ -74,6 +76,11 @@ function requires() { skip "Test requires ${var}." fi ;; + cgroups_rt) + if [ ! -e "$RT_PERIOD" ]; then + skip "Test requires ${var}." + fi + ;; *) fail "BUG: Invalid requires ${var}." ;; @@ -189,7 +196,10 @@ function setup_hello() { function teardown_running_container() { runc list - if [[ "${output}" == *"$1"* ]]; then + # $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 @@ -198,7 +208,10 @@ function teardown_running_container() { function teardown_running_container_inroot() { ROOT=$2 runc list - if [[ "${output}" == *"$1"* ]]; then + # $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 diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 6790e0b4..9e4c1102 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -5,6 +5,7 @@ load helpers function teardown() { rm -f $BATS_TMPDIR/runc-update-integration-test.json teardown_running_container test_update + teardown_running_container test_update_rt teardown_busybox } @@ -212,3 +213,31 @@ EOF check_cgroup_value $CGROUP_MEMORY "memory.limit_in_bytes" 33554432 check_cgroup_value $CGROUP_MEMORY "memory.soft_limit_in_bytes" 25165824 } + +@test "update rt period and runtime" { + requires cgroups_rt + + # run a detached busybox + runc run -d --console-socket $CONSOLE_SOCKET test_update_rt + [ "$status" -eq 0 ] + wait_for_container 15 1 test_update_rt + + # get the cgroup paths + eval CGROUP_CPU="${CGROUP_CPU_BASE_PATH}/runc-update-integration-test" + + runc update -r - test_update_rt <