summaryrefslogtreecommitdiff
path: root/0193-add-dt-for-cri-v1.patch
blob: 2c206f571c566ce5bf639989c13e3b24992d276c (plain)
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
From bb2ed9b37d7c69b0af88487693826556321d46e9 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 11 Feb 2025 22:42:39 +0800
Subject: [PATCH 193/198] add dt for cri v1

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 CI/test_cases/container_cases/cri_stats.sh | 90 ++++++++++++++++++++++
 CI/test_cases/container_cases/cri_test.sh  | 80 +++++++++++++++++++
 2 files changed, 170 insertions(+)
 create mode 100755 CI/test_cases/container_cases/cri_stats.sh

diff --git a/CI/test_cases/container_cases/cri_stats.sh b/CI/test_cases/container_cases/cri_stats.sh
new file mode 100755
index 00000000..f6acb397
--- /dev/null
+++ b/CI/test_cases/container_cases/cri_stats.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# attributes: isulad basic cri seccomp
+# concurrent: NA
+# spend time: 4
+
+#######################################################################
+##- Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
+# - iSulad licensed under the Mulan PSL v2.
+# - You can use this software according to the terms and conditions of the Mulan PSL v2.
+# - You may obtain a copy of Mulan PSL v2 at:
+# -     http://license.coscl.org.cn/MulanPSL2
+# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+# - PURPOSE.
+# - See the Mulan PSL v2 for more details.
+##- @Description:CI
+##- @Author: wangfengtu
+##- @Create: 2022-08-13
+#######################################################################
+
+source ../helpers.sh
+curr_path=$(dirname $(readlink -f "$0"))
+data_path=$(realpath $curr_path/criconfigs)
+pause_img_path=$(realpath $curr_path/test_data)
+
+function do_pre()
+{
+  sed -i "s#seccomp_localhost_ref#${data_path}/seccomp_localhost.json#g" ${data_path}/container-config-seccomp-localhost.json
+
+  init_cri_conf $1 "without_valgrind"
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+  
+  isula pull busybox
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull busybox" && return ${FAILURE}
+
+  return 0
+}
+
+function do_post()
+{
+    local ret=0
+    restore_cri_conf "without_valgrind"
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
+    return $ret
+}
+
+function test_cri_stats()
+{
+    local ret=0
+    local test="cri stats test => (${FUNCNAME[@]})"
+    
+    msg_info "${test} starting..."
+
+    sid=$(crictl runp ${data_path}/sandbox-config.json)
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run sandbox" && ((ret++))
+
+    cid=$(crictl create $sid ${data_path}/container-config.json ${data_path}/sandbox-config.json)
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to create container" && ((ret++))
+
+    crictl start $cid
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to start container" && ((ret++))
+    
+    crictl statsp $sid
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to get cri stats" && ((ret++))
+
+    crictl stats $cid
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to get cri stats" && ((ret++))
+    
+    msg_info "${test} finished with return ${ret}..."
+    return ${ret}
+}
+
+declare -i ans=0
+
+for version in ${CRI_LIST[@]};
+do
+    test="test_cri_test_fun, use cri version => (${version})"
+    msg_info "${test} starting..."
+
+    do_pre $version || ((ans++))
+
+    test_cri_stats || ((ans++))
+
+    do_post || ((ans++))
+    msg_info "${test} finished with return ${ans}..."
+done
+
+show_result ${ans} "${curr_path}/${0}"
+
diff --git a/CI/test_cases/container_cases/cri_test.sh b/CI/test_cases/container_cases/cri_test.sh
index ed333a28..6dc2291e 100755
--- a/CI/test_cases/container_cases/cri_test.sh
+++ b/CI/test_cases/container_cases/cri_test.sh
@@ -45,6 +45,83 @@ function do_post()
     return $ret
 }
 
+function test_cri_info()
+{
+  local ret=0
+  local image="busybox"
+  local test="cri info test => (${FUNCNAME[@]})"
+
+  msg_info "${test} starting..."
+
+  crictl info
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to get cri info" && ((ret++))
+
+  msg_info "${test} finished with return ${ret}..."
+  return ${ret}
+}
+
+function test_cri_list()
+{
+  local ret=0
+  local image="busybox"
+  local test="cri list test => (${FUNCNAME[@]})"
+
+  msg_info "${test} starting..."
+
+  sid=$(crictl runp ${data_path}/sandbox-config.json)
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run sandbox" && ((ret++))
+
+  cid=$(crictl create $sid ${data_path}/container-config.json ${data_path}/sandbox-config.json)
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to create container" && ((ret++))
+
+  crictl start $cid
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to start container" && ((ret++))
+
+  crictl pods | grep "^${sid:0:5}"
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to list cri pod" && ((ret++))
+
+  crictl ps -a | grep "^${cid:0:5}"
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to list cri container" && ((ret++))
+
+  stop_isulad_without_valgrind
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && ((ret++))
+
+  start_isulad_without_valgrind
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && ((ret++))
+
+  crictl ps -a | grep "^${cid:0:5}"
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to list cri container after restart" && ((ret++))
+
+  crictl pods | grep "^${sid:0:5}"
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to list cri pod after restart" && ((ret++))
+
+  crictl rmp -f $(crictl pods -q)
+
+  msg_info "${test} finished with return ${ret}..."
+  return ${ret}
+}
+
+function test_cri_images()
+{
+  local ret=0
+  local image="busybox"
+  local test="cri images test => (${FUNCNAME[@]})"
+
+  msg_info "${test} starting..."
+
+  crictl pull $image
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image" && ((ret++))
+
+  crictl images | grep $image
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to list cri images" && ((ret++))
+
+  crictl rmi $image
+  [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to remove image" && ((ret++))
+
+  msg_info "${test} finished with return ${ret}..."
+  return ${ret}
+}
+
 function test_cri_seccomp()
 {
   local ret=0
@@ -97,6 +174,9 @@ do
     test_cri_seccomp "default" || ((ans++))
     test_cri_seccomp "unconfined" || ((ans++))
     test_cri_seccomp "localhost" || ((ans++))
+    test_cri_info || ((ans++))
+    test_cri_list || ((ans++))
+    test_cri_images || ((ans++))
 
     do_post || ((ans++))
     msg_info "${test} finished with return ${ans}..."
-- 
2.34.1