summaryrefslogtreecommitdiff
path: root/0183-add-dt-for-cri-v1.patch
diff options
context:
space:
mode:
Diffstat (limited to '0183-add-dt-for-cri-v1.patch')
-rw-r--r--0183-add-dt-for-cri-v1.patch575
1 files changed, 575 insertions, 0 deletions
diff --git a/0183-add-dt-for-cri-v1.patch b/0183-add-dt-for-cri-v1.patch
new file mode 100644
index 0000000..28fe618
--- /dev/null
+++ b/0183-add-dt-for-cri-v1.patch
@@ -0,0 +1,575 @@
+From 262707f0d14e7c42554875cab38fdef985c21acc Mon Sep 17 00:00:00 2001
+From: zhongtao <zhongtao17@huawei.com>
+Date: Sat, 11 Jan 2025 15:04:54 +0800
+Subject: [PATCH 183/198] add dt for cri v1
+
+Signed-off-by: zhongtao <zhongtao17@huawei.com>
+---
+ CI/install_depends.sh | 5 +-
+ .../container_cases/cri_default_namespace.sh | 39 ++++++------
+ .../container_cases/cri_exec_sync.sh | 40 ++++++------
+ CI/test_cases/container_cases/cri_pod_ip.sh | 51 +++++++--------
+ CI/test_cases/container_cases/cri_stream.sh | 45 +++++++------
+ CI/test_cases/container_cases/cri_test.sh | 40 ++++++------
+ CI/test_cases/critest.sh | 52 +++++++++------
+ CI/test_cases/helpers.sh | 63 +++++++++++++++++++
+ 8 files changed, 205 insertions(+), 130 deletions(-)
+
+diff --git a/CI/install_depends.sh b/CI/install_depends.sh
+index 8b7c7201..c7fb9563 100755
+--- a/CI/install_depends.sh
++++ b/CI/install_depends.sh
+@@ -44,9 +44,8 @@ function make_crictl()
+ git clone https://gitee.com/duguhaotian/cri-tools.git
+ go version
+ cd cri-tools
+- # crictl v1.18 cannot recognise the SecurityProfile seccomp of LinuxSandboxSecurityContext
+- # and the LinuxContainerSecurityContext.has_seccomp() always false
+- git checkout v1.22.0
++ # update crictl to 1.25, used to test cri v1 alpha and cri v1.
++ git checkout v1.25.0
+ make -j $nproc
+ echo "make cri-tools: $?"
+ cp ./build/bin/crictl ${builddir}/bin/
+diff --git a/CI/test_cases/container_cases/cri_default_namespace.sh b/CI/test_cases/container_cases/cri_default_namespace.sh
+index d013c6fa..1f418947 100755
+--- a/CI/test_cases/container_cases/cri_default_namespace.sh
++++ b/CI/test_cases/container_cases/cri_default_namespace.sh
+@@ -18,17 +18,8 @@ function set_up()
+
+ msg_info "${test} starting..."
+
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
+-
+- check_valgrind_log
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to stop isulad" && return ${FAILURE}
+-
+- start_isulad_with_valgrind
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to start isulad" && return ${FAILURE}
+-
+- isula load -i ${pause_img_path}/pause.tar
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to load pause image" && return ${FAILURE}
++ init_cri_conf $1
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+
+ crictl pull ${image}
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
+@@ -92,20 +83,28 @@ function test_cri_default_namespace_in_pod_fun()
+
+ function tear_down()
+ {
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
+- check_valgrind_log
+- start_isulad_with_valgrind
++ local ret=0
++ restore_cri_conf
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
++ return $ret
+ }
+
+ declare -i ans=0
+
+-set_up || ((ans++))
+-
+-for element in ${RUNTIME_LIST[@]};
++for version in ${CRI_LIST[@]};
+ do
+- test_cri_default_namespace_in_pod_fun $element || ((ans++))
+-done
++ test="test_cri_default_namespace_in_pod_fun, use cri version => (${version})"
++ msg_info "${test} starting..."
++
++ set_up $version || ((ans++))
+
+-tear_down
++ for element in ${RUNTIME_LIST[@]};
++ do
++ test_cri_default_namespace_in_pod_fun $element || ((ans++))
++ done
++
++ tear_down || ((ans++))
++ msg_info "${test} finished with return ${ans}..."
++done
+
+ show_result ${ans} "${curr_path}/${0}"
+diff --git a/CI/test_cases/container_cases/cri_exec_sync.sh b/CI/test_cases/container_cases/cri_exec_sync.sh
+index 97ea01ca..62352be5 100755
+--- a/CI/test_cases/container_cases/cri_exec_sync.sh
++++ b/CI/test_cases/container_cases/cri_exec_sync.sh
+@@ -33,17 +33,8 @@ function do_pre()
+
+ msg_info "${test} starting..."
+
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
+-
+- check_valgrind_log
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to stop isulad" && return ${FAILURE}
+-
+- start_isulad_with_valgrind
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to start isulad" && return ${FAILURE}
+-
+- isula load -i ${pause_img_path}/pause.tar
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to load pause image" && return ${FAILURE}
++ init_cri_conf $1
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+
+ crictl pull ${image}
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
+@@ -116,10 +107,10 @@ function tear_down()
+
+ function do_post()
+ {
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
+-
+- check_valgrind_log
+- start_isulad_with_valgrind
++ local ret=0
++ restore_cri_conf
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
++ return $ret
+ }
+
+ function do_test_t()
+@@ -142,13 +133,20 @@ function do_test_t()
+
+ declare -i ans=0
+
+-do_pre || ((ans++))
+-
+-for element in ${RUNTIME_LIST[@]};
++for version in ${CRI_LIST[@]};
+ do
+- do_test_t $element || ((ans++))
+-done
++ test="test_cri_exec_sync_fun, use cri version => (${version})"
++ msg_info "${test} starting..."
+
+-do_post
++ do_pre $version || ((ans++))
++
++ for element in ${RUNTIME_LIST[@]};
++ do
++ do_test_t $element || ((ans++))
++ done
++
++ 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_pod_ip.sh b/CI/test_cases/container_cases/cri_pod_ip.sh
+index 7bf7833b..01c644f4 100755
+--- a/CI/test_cases/container_cases/cri_pod_ip.sh
++++ b/CI/test_cases/container_cases/cri_pod_ip.sh
+@@ -12,8 +12,8 @@ source ../helpers.sh
+
+ function do_pre()
+ {
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
++ init_cri_conf $1
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+
+ init_cni_conf $data_path
+ if [ $? -ne 0 ]; then
+@@ -21,21 +21,14 @@ function do_pre()
+ TC_RET_T=$(($TC_RET_T+1))
+ return $TC_RET_T
+ fi
+-
+- isula load -i ${pause_img_path}/pause.tar
+- if [ $? -ne 0 ]; then
+- msg_err "Failed to load pause image"
+- TC_RET_T=$(($TC_RET_T+1))
+- return $TC_RET_T
+- fi
+-
+ }
+
+ function do_post()
+ {
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
+- check_valgrind_log
+- start_isulad_with_valgrind
++ local ret=0
++ restore_cri_conf
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
++ return $ret
+ }
+
+ function do_test()
+@@ -104,21 +97,29 @@ function do_test()
+ }
+
+
+-ret=0
++ans=0
+
+-do_pre
+-if [ $? -ne 0 ];then
+- let "ret=$ret + 1"
+-fi
+-
+-for element in ${RUNTIME_LIST[@]};
++for version in ${CRI_LIST[@]};
+ do
+- do_test $element
++ test="test_cri_default_namespace_fun, use cri version => (${version})"
++ msg_info "${test} starting..."
++
++ do_pre $version || ((ans++))
+ if [ $? -ne 0 ];then
+- let "ret=$ret + 1"
++ let "ans=$ans + 1"
+ fi
+-done
+
+-do_post
++ for element in ${RUNTIME_LIST[@]};
++ do
++ do_test $element
++ if [ $? -ne 0 ];then
++ let "ans=$ans + 1"
++ fi
++ done
++
++ do_post || ((ans++))
++
++ msg_info "${test} finished with return ${ans}..."
++done
+
+-show_result $ret "cni base test"
++show_result $ans "cni base test"
+diff --git a/CI/test_cases/container_cases/cri_stream.sh b/CI/test_cases/container_cases/cri_stream.sh
+index 43ed3891..e4918c23 100755
+--- a/CI/test_cases/container_cases/cri_stream.sh
++++ b/CI/test_cases/container_cases/cri_stream.sh
+@@ -39,17 +39,8 @@ function do_pre()
+
+ msg_info "${test} starting..."
+
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
+-
+- check_valgrind_log
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to stop isulad" && return ${FAILURE}
+-
+- start_isulad_without_valgrind
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to start isulad" && return ${FAILURE}
+-
+- isula load -i ${pause_img_path}/pause.tar
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to load pause image" && return ${FAILURE}
++ init_cri_conf $1 "without_valgrind"
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+
+ crictl pull ${image}
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
+@@ -130,13 +121,12 @@ function test_cri_attach
+ local test="test_cri_attach => (${FUNCNAME[@]})"
+ msg_info "${test} starting..."
+
+- nohup cricli attach -i ${cid} &
++ nohup cricli attach -ti ${cid} &
+ pid=$!
+ sleep 2
+
+ ps -T -p $(cat /var/run/isulad.pid) | grep IoCopy
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual IO copy thread in CRI attach operation" && ((ret++))
+-
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - attach failed, no IOCopy thread" && ((ret++))
+
+ kill -9 $pid
+ sleep 2
+@@ -169,10 +159,10 @@ function tear_down()
+
+ function do_post()
+ {
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
+-
+- stop_isulad_without_valgrind
+- start_isulad_with_valgrind
++ local ret=0
++ restore_cri_conf "without_valgrind"
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
++ return $ret
+ }
+
+ function do_test_t()
+@@ -198,13 +188,20 @@ function do_test_t()
+
+ declare -i ans=0
+
+-do_pre || ((ans++))
+-
+-for element in ${RUNTIME_LIST[@]};
++for version in ${CRI_LIST[@]};
+ do
+- do_test_t $element || ((ans++))
+-done
++ test="test_cri_stream_fun, use cri version => (${version})"
++ msg_info "${test} starting..."
++
++ do_pre $version || ((ans++))
+
+-do_post
++ for element in ${RUNTIME_LIST[@]};
++ do
++ do_test_t $element || ((ans++))
++ done
++
++ 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 88420761..ed333a28 100755
+--- a/CI/test_cases/container_cases/cri_test.sh
++++ b/CI/test_cases/container_cases/cri_test.sh
+@@ -28,24 +28,21 @@ function do_pre()
+ {
+ sed -i "s#seccomp_localhost_ref#${data_path}/seccomp_localhost.json#g" ${data_path}/container-config-seccomp-localhost.json
+
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
+-
+- check_valgrind_log
+- start_isulad_with_valgrind
+-
+- isula load -i ${pause_img_path}/pause.tar
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to load pause" && return ${FAILURE}
+-
++ 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()
+ {
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
+- check_valgrind_log
+- start_isulad_with_valgrind
++ 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_seccomp()
+@@ -82,7 +79,7 @@ function test_cri_seccomp()
+ [[ $? -eq 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - chmod should fail as it's blocked by seccomp" && ((ret++))
+ fi
+
+- isula rm -f `isula ps -a -q`
++ crictl rmp -f $(crictl pods -q)
+
+ msg_info "${test} finished with return ${ret}..."
+ return ${ret}
+@@ -90,13 +87,20 @@ function test_cri_seccomp()
+
+ declare -i ans=0
+
+-do_pre
++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_seccomp "default" || ((ans++))
+-test_cri_seccomp "unconfined" || ((ans++))
+-test_cri_seccomp "localhost" || ((ans++))
++ test_cri_seccomp "default" || ((ans++))
++ test_cri_seccomp "unconfined" || ((ans++))
++ test_cri_seccomp "localhost" || ((ans++))
+
+-do_post
++ do_post || ((ans++))
++ msg_info "${test} finished with return ${ans}..."
++done
+
+ show_result ${ans} "${curr_path}/${0}"
+
+diff --git a/CI/test_cases/critest.sh b/CI/test_cases/critest.sh
+index f8d4975e..136594a0 100755
+--- a/CI/test_cases/critest.sh
++++ b/CI/test_cases/critest.sh
+@@ -62,8 +62,9 @@ function restore_selinux_environment() {
+
+ function pre_test() {
+ # build critest
+- local VERSION="v1.22.0"
++ local VERSION="v1.25.0"
+
++ rm -rf cri-tools
+ git clone https://gitee.com/duguhaotian/cri-tools.git
+ go version
+ cd cri-tools
+@@ -75,15 +76,8 @@ function pre_test() {
+ critest --version
+
+ # config pause
+- cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
+- sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
+-
+- isula load -i ${pause_img_path}/pause.tar
+- if [ $? -ne 0 ]; then
+- msg_err "Failed to load pause image"
+- TC_RET_T=$(($TC_RET_T + 1))
+- return $TC_RET_T
+- fi
++ init_cri_conf $1
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to init cri conf: ${1}" && return ${FAILURE}
+
+ # config cni
+ init_cni_conf $data_path
+@@ -107,7 +101,9 @@ function post_test() {
+ restore_selinux_environment
+ rm -rf ./cri-tools
+ rm /usr/local/bin/critest
+- cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
++
++ restore_cri_conf
++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to restore cri conf" && ((ret++))
+
+ # clear env
+ isula rm -f `isula ps -qa`
+@@ -117,10 +113,8 @@ function post_test() {
+ do
+ isula pull ${image}
+ done
+-
+- stop_isulad_without_valgrind
+- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - memory leak" && return ${FAILURE}
+- start_isulad_with_valgrind
++
++ return ${ret}
+ }
+
+ function test_critest() {
+@@ -158,12 +152,32 @@ function do_test_t() {
+ return $ret
+ }
+
+-declare -i ans=0
++function do_critest_test_t()
++{
++ local cri_version=$1
++ local ret=0
++ local test="do_critest_test_t => (${cri_version})"
++ msg_info "${test} starting..."
++
++ pre_test $cri_version || (ret++)
+
+-pre_test || (ans++)
++ do_test_t || ((ret++))
+
+-do_test_t || ((ans++))
++ post_test || (ret++)
+
+-post_test || (ans++)
++ msg_info "${test} finished with return ${ret}..."
++
++ return $ret
++}
++
++declare -i ans=0
++
++for version in ${CRI_LIST[@]};
++do
++ do_critest_test_t $version
++ if [ $? -ne 0 ];then
++ let "ans=$ans + 1"
++ fi
++done
+
+ show_result ${ans} "${curr_path}/${0}"
+diff --git a/CI/test_cases/helpers.sh b/CI/test_cases/helpers.sh
+index 0288b4ea..111058e3 100755
+--- a/CI/test_cases/helpers.sh
++++ b/CI/test_cases/helpers.sh
+@@ -31,6 +31,8 @@ RUNTIME_LIST=(lcr runc)
+
+ DEFAULT_RUNTIME=runc
+
++CRI_LIST=(v1alpha v1)
++
+ testcase_data="/tmp/testcases_data"
+
+ enable_native_network=0
+@@ -321,4 +323,65 @@ function do_pretest() {
+ msg_info "#####################"
+ }
+
++function init_cri_conf() {
++ local ret=0
++ check_valgrind_log
++ if [ $? -ne 0 ]; then
++ echo "stop isulad failed"
++ ret=$(($ret+1))
++ fi
++
++ cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
++ if [ "x$1" == "xv1" ]; then
++ echo "use cri v1"
++ sed -i '/"pod-sandbox-image": ""/i "enable-cri-v1": true,' /etc/isulad/daemon.json
++ fi
++ sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"mirrorgooglecontainers/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
++
++ if [ "x$2" == "xwithout_valgrind" ]; then
++ start_isulad_without_valgrind
++ else
++ echo "start with valgrind"
++ start_isulad_with_valgrind
++ fi
++ if [ $? -ne 0 ]; then
++ echo "start failed"
++ ret=$(($ret+1))
++ fi
++
++ isula load -i ${pause_img_path}/pause.tar
++ if [ $? -ne 0 ]; then
++ msg_err "Failed to load pause image"
++ ret=$(($ret + 1))
++ return $ret
++ fi
++
++ return $ret
++}
++
++function restore_cri_conf() {
++ local ret=0
++
++ if [ "x$1" == "xwithout_valgrind" ]; then
++ stop_isulad_without_valgrind
++ else
++ echo "stop with valgrind"
++ check_valgrind_log
++ fi
++ if [ $? -ne 0 ]; then
++ echo "stop isulad failed"
++ ret=$(($ret+1))
++ fi
++
++ cp /etc/isulad/daemon.bak /etc/isulad/daemon.json
++
++ start_isulad_with_valgrind
++ if [ $? -ne 0 ]; then
++ echo "start failed"
++ ret=$(($ret+1))
++ fi
++
++ return $ret
++}
++
+ do_pretest
+--
+2.34.1
+