Add integration for update rt period and runtime
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
parent
f376b8033d
commit
51baedf3f3
|
@ -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
|
||||
|
|
|
@ -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) ~ /\<MEMORY\>/ { print $5; exit }')
|
||||
CGROUP_MEMORY_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<MEMORY\>/ { print $5; exit }')
|
||||
CGROUP_CPU_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<CPU\>/ { 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
|
||||
|
|
|
@ -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 <<EOF
|
||||
{
|
||||
"cpu": {
|
||||
"realtimePeriod": 800001,
|
||||
"realtimeRuntime": 500001
|
||||
}
|
||||
}
|
||||
EOF
|
||||
check_cgroup_value $CGROUP_CPU "cpu.rt_period_us" 800001
|
||||
check_cgroup_value $CGROUP_CPU "cpu.rt_runtime_us" 500001
|
||||
|
||||
runc update test_update_rt --cpu-rt-period 900001 --cpu-rt-runtime 600001
|
||||
|
||||
check_cgroup_value $CGROUP_CPU "cpu.rt_period_us" 900001
|
||||
check_cgroup_value $CGROUP_CPU "cpu.rt_runtime_us" 600001
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue