From 1b03e72554e30a8abf4317e7a711a794fd43c34c Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 8 Jun 2020 17:35:02 -0700 Subject: [PATCH] tests/int/update: more cpu period/quota cases Add four "corner case" tests that check that the CPU period/quota can be set/updated even in case neither CPU quota nor CPU period (were previously) set. Signed-off-by: Kir Kolyshkin --- tests/integration/update.bats | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 9a42e65c..1a4d220e 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -340,6 +340,55 @@ EOF check_cpu_shares 100 } +@test "set cpu period with no quota" { + [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup + + update_config '.linux.resources.cpu |= { "period": 1000000 }' ${BUSYBOX_BUNDLE} + + runc run -d --console-socket $CONSOLE_SOCKET test_update + [ "$status" -eq 0 ] + + check_cpu_quota -1 1000000 "infinity" +} + +@test "set cpu quota with no period" { + [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup + + update_config '.linux.resources.cpu |= { "quota": 5000 }' ${BUSYBOX_BUNDLE} + + runc run -d --console-socket $CONSOLE_SOCKET test_update + [ "$status" -eq 0 ] + check_cpu_quota 5000 100000 "50ms" +} + +@test "update cpu period with no previous period/quota set" { + [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup + + update_config '.linux.resources.cpu |= {}' ${BUSYBOX_BUNDLE} + + runc run -d --console-socket $CONSOLE_SOCKET test_update + [ "$status" -eq 0 ] + + # update the period alone, no old values were set + runc update --cpu-period 50000 test_update + [ "$status" -eq 0 ] + check_cpu_quota -1 50000 "infinity" +} + +@test "update cpu quota with no previous period/quota set" { + [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup + + update_config '.linux.resources.cpu |= {}' ${BUSYBOX_BUNDLE} + + runc run -d --console-socket $CONSOLE_SOCKET test_update + [ "$status" -eq 0 ] + + # update the quota alone, no old values were set + runc update --cpu-quota 30000 test_update + [ "$status" -eq 0 ] + check_cpu_quota 30000 100000 "300ms" +} + @test "update rt period and runtime" { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup requires cgroups_rt