Skip to content

Commit

Permalink
!2563 add dt for cri v1
Browse files Browse the repository at this point in the history
From: @taotao-sauce 
Reviewed-by: @xuxuepeng 
Signed-off-by: @xuxuepeng
  • Loading branch information
openeuler-ci-bot authored and gitee-org committed Jan 22, 2025
2 parents a43cdfd + 262707f commit ce7386e
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 130 deletions.
5 changes: 2 additions & 3 deletions CI/install_depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
39 changes: 19 additions & 20 deletions CI/test_cases/container_cases/cri_default_namespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}"
40 changes: 19 additions & 21 deletions CI/test_cases/container_cases/cri_exec_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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()
Expand All @@ -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}"
51 changes: 26 additions & 25 deletions CI/test_cases/container_cases/cri_pod_ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,23 @@ 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
msg_err "Failed to init cni config"
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()
Expand Down Expand Up @@ -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"
45 changes: 21 additions & 24 deletions CI/test_cases/container_cases/cri_stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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}"
40 changes: 22 additions & 18 deletions CI/test_cases/container_cases/cri_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -82,21 +79,28 @@ 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}
}

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}"

Loading

0 comments on commit ce7386e

Please sign in to comment.