1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/src-openeuler-iSulad

В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
0183-add-dt-for-cri-v1.patch 17 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
liuxu Отправлено 17.02.2025 20:07 ea77daa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
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

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/src-openeuler-iSulad.git
git@api.gitlife.ru:oschina-mirror/src-openeuler-iSulad.git
oschina-mirror
src-openeuler-iSulad
src-openeuler-iSulad
master