1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
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/53] 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
|