184 lines
7.7 KiB
Diff
184 lines
7.7 KiB
Diff
From edef459d5052dc6d7c29e8a7a48ff4bf1b01bd78 Mon Sep 17 00:00:00 2001
|
|
From: songbuhuang <544824346@qq.com>
|
|
Date: Tue, 14 Feb 2023 14:08:01 +0800
|
|
Subject: [PATCH 08/22] fix isula cpu-rt CI
|
|
|
|
Signed-off-by: songbuhuang <544824346@qq.com>
|
|
---
|
|
CI/test_cases/container_cases/cpu_rt.sh | 102 +++++++++++++++++-------
|
|
1 file changed, 73 insertions(+), 29 deletions(-)
|
|
|
|
diff --git a/CI/test_cases/container_cases/cpu_rt.sh b/CI/test_cases/container_cases/cpu_rt.sh
|
|
index 3d70c840..353c2d71 100755
|
|
--- a/CI/test_cases/container_cases/cpu_rt.sh
|
|
+++ b/CI/test_cases/container_cases/cpu_rt.sh
|
|
@@ -21,12 +21,12 @@
|
|
declare -r curr_path=$(dirname $(readlink -f "$0"))
|
|
source ../helpers.sh
|
|
|
|
-function test_cpu_rt_isulad_spec()
|
|
+function test_cpurt_isulad_abnormal()
|
|
{
|
|
local ret=0
|
|
local test="isulad cpu realtime test => (${FUNCNAME[@]})"
|
|
|
|
- msg_info "${test} starting..."
|
|
+ msg_info "${test} starting..."
|
|
|
|
isulad --cpu-rt-period xx --cpu-rt-runtime 950000 /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument'
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-period" && ((ret++))
|
|
@@ -38,54 +38,64 @@ function test_cpu_rt_isulad_spec()
|
|
return ${ret}
|
|
}
|
|
|
|
-function test_cpu_rt_isula_spec()
|
|
+function test_isula_update_normal()
|
|
{
|
|
- local ret=0
|
|
- local image="busybox"
|
|
- local test="container cpu realtime test => (${FUNCNAME[@]})"
|
|
-
|
|
- msg_info "${test} starting..."
|
|
-
|
|
- #start isulad without cpu_rt
|
|
- start_isulad_without_valgrind
|
|
+ #start isulad with cpu_rt
|
|
+ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 &
|
|
+ wait_isulad_running
|
|
+
|
|
+ c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 950000 ${image} sh`
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++))
|
|
|
|
- isula pull ${image}
|
|
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
|
|
+ isula update --cpu-rt-period 900000 --cpu-rt-runtime 800000 $c_id
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++))
|
|
|
|
- isula images | grep busybox
|
|
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++))
|
|
+ isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us" | grep "800000"
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_runtime_us: 800000" && ((ret++))
|
|
|
|
- test_isula_run_spec
|
|
+ isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_period_us" | grep "900000"
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_period_us: 900000" && ((ret++))
|
|
|
|
- #start isulad without cpu_rt:isulad cpu.rt_period_us default value is the cpu.rt_period_us of the upper-layer directory,cpu.rt_runtime_us is 0.
|
|
- isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "failed to write 10000" | grep "cpu.rt_runtime_us: Invalid argument"
|
|
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++))
|
|
+ isula rm -f $c_id
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++))
|
|
|
|
stop_isulad_without_valgrind
|
|
+ #set cpu-rt to the initial state
|
|
+ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 0 -l DEBUG > /dev/null 2>&1 &
|
|
+ wait_isulad_running
|
|
|
|
+ msg_info "${test} finished with return ${ret}..."
|
|
+ return ${ret}
|
|
+}
|
|
+
|
|
+function test_isula_update_abnormal()
|
|
+{
|
|
#start isulad with cpu_rt
|
|
isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 &
|
|
wait_isulad_running
|
|
-
|
|
- test_isula_run_spec
|
|
|
|
c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 950000 ${image} sh`
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++))
|
|
|
|
- isula update --cpu-rt-runtime 90000 $c_id
|
|
+ isula update --cpu-rt-period 800000 --cpu-rt-runtime 900000 $c_id | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period"
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++))
|
|
|
|
- isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us" | grep "90000"
|
|
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_runtime_us: 90000" && ((ret++))
|
|
+ isula update --cpu-rt-runtime 1000000 $c_id | grep "updating cgroup cpu.rt_runtime_us to 1000000: Invalid argument"
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++))
|
|
|
|
isula rm -f $c_id
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++))
|
|
|
|
+ stop_isulad_without_valgrind
|
|
+ #set cpu-rt to the initial state
|
|
+ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 0 -l DEBUG > /dev/null 2>&1 &
|
|
+ wait_isulad_running
|
|
+
|
|
msg_info "${test} finished with return ${ret}..."
|
|
return ${ret}
|
|
}
|
|
|
|
-function test_kernel_without_cpu_rt_spec()
|
|
+function test_kernel_without_cpurt()
|
|
{
|
|
local ret=0
|
|
local image="busybox"
|
|
@@ -109,8 +119,24 @@ function test_kernel_without_cpu_rt_spec()
|
|
return ${ret}
|
|
}
|
|
|
|
-function test_isula_run_spec()
|
|
+function test_isula_run_abnormal()
|
|
{
|
|
+ local ret=0
|
|
+ local image="busybox"
|
|
+ local test="container cpu realtime test => (${FUNCNAME[@]})"
|
|
+
|
|
+ msg_info "${test} starting..."
|
|
+
|
|
+ #start isulad without cpu_rt
|
|
+ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 &
|
|
+ wait_isulad_running
|
|
+
|
|
+ isula pull ${image}
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
|
|
+
|
|
+ isula images | grep busybox
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++))
|
|
+
|
|
isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime -1 $image /bin/sh 2>&1 | grep "failed to write -1" | grep "cpu.rt_runtime_us: Invalid argument"
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++))
|
|
|
|
@@ -128,15 +154,33 @@ function test_isula_run_spec()
|
|
|
|
isula run -itd --cpu-rt-period 100 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period"
|
|
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - cpu-rt-runtime cannot be higher than cpu-rt-period" && ((ret++))
|
|
+
|
|
+ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 960000 $image /bin/sh 2>&1 | grep "failed to write 960000" | grep "cpu.rt_runtime_us: Invalid argument"
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++))
|
|
+
|
|
+ stop_isulad_without_valgrind
|
|
+}
|
|
+
|
|
+function test_isula_run_normal()
|
|
+{
|
|
+ isula run -itd -n box --cpu-rt-period 1000000 --cpu-rt-runtime 900000 $image /bin/sh 2>&1
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container" && ((ret++))
|
|
+
|
|
+ isula rm -f box
|
|
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++))
|
|
+
|
|
}
|
|
|
|
declare -i ans=0
|
|
|
|
if [ -f "/sys/fs/cgroup/cpu/cpu.rt_runtime_us" ];then
|
|
- test_cpu_rt_isulad_spec || ((ans++))
|
|
- test_cpu_rt_isula_spec || ((ans++))
|
|
+ test_isula_run_abnormal || ((ans++))
|
|
+ test_isula_run_normal || ((ans++))
|
|
+ test_cpurt_isulad_abnormal || ((ans++))
|
|
+ test_isula_update_normal || ((ans++))
|
|
+ test_isula_update_abnormal || ((ans++))
|
|
else
|
|
- test_kernel_without_cpu_rt_spec || ((ans++))
|
|
+ test_kernel_without_cpurt || ((ans++))
|
|
fi
|
|
|
|
show_result ${ans} "${curr_path}/${0}"
|
|
--
|
|
2.25.1
|
|
|