From 0504a907def3efb4c0ad7eabd5921c97090430af Mon Sep 17 00:00:00 2001 From: songbuhuang <544824346@qq.com> Date: Tue, 14 Feb 2023 15:55:56 +0800 Subject: [PATCH 09/53] fix cpu-rt CI Signed-off-by: songbuhuang <544824346@qq.com> --- CI/test_cases/container_cases/cpu_rt.sh | 32 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/CI/test_cases/container_cases/cpu_rt.sh b/CI/test_cases/container_cases/cpu_rt.sh index 353c2d71..42006bc8 100755 --- a/CI/test_cases/container_cases/cpu_rt.sh +++ b/CI/test_cases/container_cases/cpu_rt.sh @@ -24,14 +24,14 @@ source ../helpers.sh function test_cpurt_isulad_abnormal() { local ret=0 - local test="isulad cpu realtime test => (${FUNCNAME[@]})" + local test="isulad cpu realtime abnormal test => (${FUNCNAME[@]})" 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' + isulad --cpu-rt-period xx --cpu-rt-runtime 950000 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++)) - isulad --cpu-rt-period 1000000 --cpu-rt-runtime xx /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' + isulad --cpu-rt-period 1000000 --cpu-rt-runtime xx 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) msg_info "${test} finished with return ${ret}..." @@ -40,6 +40,12 @@ function test_cpurt_isulad_abnormal() function test_isula_update_normal() { + local ret=0 + local image="busybox" + local test="isulad update cpu realtime normal test => (${FUNCNAME[@]})" + + msg_info "${test} starting..." + #start isulad with cpu_rt isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & wait_isulad_running @@ -70,6 +76,10 @@ function test_isula_update_normal() function test_isula_update_abnormal() { + local ret=0 + local image="busybox" + local test="isulad update cpu realtime abnormal test => (${FUNCNAME[@]})" + #start isulad with cpu_rt isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & wait_isulad_running @@ -77,10 +87,10 @@ function test_isula_update_abnormal() 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-period 800000 --cpu-rt-runtime 900000 $c_id | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period" + isula update --cpu-rt-period 800000 --cpu-rt-runtime 900000 $c_id 2>&1 | 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 update --cpu-rt-runtime 1000000 $c_id | grep "updating cgroup cpu.rt_runtime_us to 1000000: Invalid argument" + isula update --cpu-rt-runtime 1000000 $c_id 2>&1 | 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 @@ -158,17 +168,23 @@ function test_isula_run_abnormal() 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 + msg_info "${test} finished with return ${ret}..." + return ${ret} } function test_isula_run_normal() { + local ret=0 + local image="busybox" + 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++)) - + + msg_info "${test} finished with return ${ret}..." + return ${ret} } declare -i ans=0 @@ -183,4 +199,6 @@ else test_kernel_without_cpurt || ((ans++)) fi +isula rm -f $(isula ps -aq) + show_result ${ans} "${curr_path}/${0}" -- 2.25.1