提交 2b7c40b9 编写于 作者: L lifeng68

CI: add container test cases

Signed-off-by: Nlifeng68 <lifeng68@huawei.com>
上级 c9207b9e
#!/bin/bash
#
# attributes: isulad inheritance fd
# concurrent: NO
# spend time: 40
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
connect="grpc"
function do_test_t_grpc()
{
if [ $connect != "grpc" ];then
echo "this test is designed for grpc version"
return 0
fi
sleep 1
containername=test_fds
isulad_pid=`cat /var/run/isulad.pid`
precount=`ls /proc/$isulad_pid/fd | wc -l`
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
fn_check_eq "$precount" "$curcount" "test failed"
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
fn_check_eq "$precount" "$curcount" "test failed"
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
fn_check_eq "$precount" "$curcount" "test failed"
return $TC_RET_T
}
function do_test_t_rest()
{
if [ $connect != "rest" ];then
echo "this test is designed for rest version"
return 0
fi
sleep 1
delta_rest="5"
containername=test_fds
isulad_pid=`cat /var/run/isulad.pid`
precount=`ls /proc/$isulad_pid/fd | wc -l`
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
delta=$((10#$curcount - 10#$precount))
echo "delta fd is $delta"
if [ $delta -ne 0 ] && [ $delta -ne $delta_rest ];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
delta=$((10#$curcount - 10#$precount))
echo "delta fd is $delta"
if [ $delta -ne 0 ] && [ $delta -ne $delta_rest ];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
sleep 1
curcount=`ls /proc/$isulad_pid/fd | wc -l`
delta=$((10#$curcount - 10#$precount))
echo "delta fd is $delta"
if [ $delta -ne 0 ] && [ $delta -ne $delta_rest ];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
return $TC_RET_T
}
ret=0
do_test_t_grpc
do_test_t_rest
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic check fd leak"
#!/bin/bash
#
# attributes: isulad cri cni
# concurrent: NA
# spend time: 10
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/criconfigs)
source ../helpers.bash
function do_pre()
{
cp /etc/isulad/daemon.json /etc/isulad/daemon.bak
sed -i "s#\"pod-sandbox-image\": \"\"#\"pod-sandbox-image\": \"rancher/pause-amd64:3.0\"#g" /etc/isulad/daemon.json
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
}
function do_post()
{
cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json
stop_isulad_without_valgrind
start_isulad_without_valgrind
}
function do_test_help()
{
msg_info "this is $0 do_test"
crictl images | grep busybox
if [ $? -ne 0 ]; then
msg_err "Failed to find busybox image"
TC_RET_T=$(($TC_RET_T+1))
fi
sid=`crictl runp ${data_path}/sandbox-config.json`
if [ $? -ne 0 ]; then
msg_err "Failed to run sandbox"
TC_RET_T=$(($TC_RET_T+1))
fi
spid=`isula inspect -f '{{json .State.Pid}}' $sid`
nsenter -t $spid -n ifconfig eth0
if [ $? -ne 0 ];then
msg_err "Sandbox network config failed"
TC_RET_T=$(($TC_RET_T+1))
fi
cid=`crictl create $sid ${data_path}/container-config.json ${data_path}/sandbox-config.json`
if [ $? -ne 0 ];then
msg_err "create container failed"
TC_RET_T=$(($TC_RET_T+1))
fi
crictl start $cid
if [ $? -ne 0 ];then
msg_err "start container failed"
TC_RET_T=$(($TC_RET_T+1))
fi
# check whether container use pod network namespace
pod_pid=`isula inspect -f '{{json .State.Pid}}' $sid`
pod_net_ns_id=`ls -l /proc/${pod_pid}/ns/net | awk -F[ '{print $2}' |awk -F] '{print $1}'`
con_pid=`isula inspect -f '{{json .State.Pid}}' $cid`
con_net_ns_id=`ls -l /proc/${con_pid}/ns/net | awk -F[ '{print $2}' |awk -F] '{print $1}'`
if [ "$pod_net_ns_id" != "$con_net_ns_id" ];then
msg_err "Pod and container use different network namespace"
nsenter -t $pod_pid -n ifconfig eth0
nsenter -t $con_pid -n ifconfig eth0
TC_RET_T=$(($TC_RET_T+1))
fi
nsenter -t $pod_pid -n ifconfig eth0 | grep "$1"
if [ $? -ne 0 ];then
msg_err "expect ip: $1, get: "
nsenter -t $pod_pid -n ifconfig eth0
TC_RET_T=$(($TC_RET_T+1))
fi
crictl stop $cid
if [ $? -ne 0 ];then
msg_err "stop container failed"
TC_RET_T=$(($TC_RET_T+1))
fi
crictl rm $cid
if [ $? -ne 0 ];then
msg_err "stop container failed"
TC_RET_T=$(($TC_RET_T+1))
fi
crictl stopp $sid
if [ $? -ne 0 ];then
msg_err "stop sandbox failed"
TC_RET_T=$(($TC_RET_T+1))
fi
crictl rmp $sid
if [ $? -ne 0 ];then
msg_err "rm sandbox failed"
TC_RET_T=$(($TC_RET_T+1))
fi
return $TC_RET_T
}
function default_cni_config()
{
do_test_help "10\.1\."
}
function new_cni_config()
{
cp ${data_path}/bridge.json /etc/cni/net.d/
sync;sync;
tail $ISUALD_LOG
# wait cni updated
s=`date "+%s"`
for ((i=0;i<30;i++)); do
sleep 1
cur=`date "+%s"`
let "t=cur-s"
if [ $t -gt 6 ];then
break
fi
done
tail $ISUALD_LOG
do_test_help "10\.2\."
}
ret=0
do_pre
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
default_cni_config
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
new_cni_config
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
do_post
show_result $ret "cni base test"
#!/bin/bash
#
# attributes: isulad inheritance create
# concurrent: YES
# spend time: 8
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
source ../helpers.bash
function do_test_t()
{
containername=test_create
isula run -itd --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername running
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
isula inspect $containername
fn_check_ne "$?" "0" "inspect should fail"
containerid=`isula run -itd --name $containername --cpu-shares 1024 busybox`
fn_check_eq "$?" "0" "create failed"
cat "$LCR_ROOT_PATH/$containerid/config" | grep "cpu.shares = 1024"
fn_check_eq "$?" "0" "create failed"
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
containerid=`isula run -itd --name $containername --cpu-quota 50000 busybox`
fn_check_eq "$?" "0" "create failed"
cat "$LCR_ROOT_PATH/$containerid/config" | grep "cpu.cfs_quota_us = 50000"
fn_check_eq "$?" "0" "create failed"
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
containerid=`isula run -itd --name $containername --cpuset-cpus 0-1 busybox`
fn_check_eq "$?" "0" "create failed"
cat "$LCR_ROOT_PATH/$containerid/config" | grep "cpuset.cpus = 0-1"
fn_check_eq "$?" "0" "create failed"
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
containerid=`isula run -itd --name $containername --memory 1000000000 busybox`
fn_check_eq "$?" "0" "create failed"
cat "$LCR_ROOT_PATH/$containerid/config" | grep "memory.limit_in_bytes = 1000000000"
fn_check_eq "$?" "0" "create failed"
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic create"
#!/bin/bash
#
# attributes: isulad inheritance start
# concurrent: YES
# spend time: 11
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: gaohuatao
##- @Create: 2020-05-11
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
id=`isula run -tid --runtime runc busybox`
fn_check_eq "$?" "0" "run failed"
testcontainer $id running
isula exec $id sh -c 'ls -al /etc/mtab'
fn_check_eq "$?" "0" "/etc/mtab not exist"
isula rm -f $id
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "creat mtab symbol link"
#!/bin/bash
basepath=/tmp/cnilogs/
mkdir -p $basepath
secs=`date "+%s"`
confpath=${basepath}/${secs}.netconf
envpath=${basepath}/${secs}.env
env | grep CNI_CONTAINERID >/dev/null 2>&1
if [ $? -eq 0 ];then
confpath=${basepath}/${CNI_CONTAINERID}.netconf
envpath=${basepath}/${CNI_CONTAINERID}.env
fi
read -r line
echo $line > ${confpath}
env > ${envpath}
echo "{
\"cniVersion\": \"0.3.1\",
\"dns\": {}
}"
{
"cniVersion": "0.3.0",
"name": "ok",
"type": "bridge",
"bridge": "cni0",
"ipam": {
"type": "host-local",
"subnet": "10.2.0.0/16"
}
}
{
"metadata": {
"name": "haozi"
},
"image":{
"image": "busybox:latest"
},
"command": [
"/bin/sh",
"-c",
"i=0; while true; do echo \"$i: $(date)\"; i=$((i+1)); sleep 10; done"
],
"labels": {
"filter_label_key": "filter_label_val"
},
"annotations": {
"extension.network.kubernetes.io/cni/instancename": "pod_instance_name"
},
"mounts" : [
{
"container_path": "/tmp/contpath",
"host_path": "/tmp/hostpath",
"readonly": true,
"selinux_relabel": true,
"propagation": 0
},
{
"container_path": "/tmp/contpath2",
"host_path": "/tmp/hostpath2",
"readonly": false,
"selinux_relabel": false,
"propagation": 0
}
],
"linux": {
"security_context": {
"namespace_options": {
"host_network": true,
"host_pid": false,
"host_ipc": false
}
}
},
"log_path": "cri_test.log"
}
{
"cniVersion": "0.3.1",
"name": "good",
"plugins": [
{
"name": "good",
"type": "ptp",
"ipam": {
"type": "host-local",
"subnet": "10.1.0.0/16"
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
{
"cniVersion": "0.3.1",
"name": 666,
"plugins": [
{
"name": "default",
"type": "ptp",
"ipam": {
"type": "host-local",
"subnet": "10.1.0.0/16"
}
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
}
]
}
{
"port_mappings":[{"protocol": 1, "container_port": 80, "host_port": 8080}],
"metadata": {
"name": "test",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {
}
}
#!/bin/bash
#
# attributes: isulad inheritance help
# concurrent: YES
# spend time: 1
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function isulad_help()
{
isulad --help
fn_check_eq "$?" "0" "test failed"
}
function isula_help()
{
isula
fn_check_eq "$?" "0" "test failed"
isula --help
fn_check_eq "$?" "0" "test failed"
}
function isula_subcmd_help()
{
isula create --help
fn_check_eq "$?" "0" "test failed"
isula rm --help
fn_check_eq "$?" "0" "test failed"
isula ps --help
fn_check_eq "$?" "0" "test failed"
isula start --help
fn_check_eq "$?" "0" "test failed"
isula stop --help
fn_check_eq "$?" "0" "test failed"
isula exec --help
fn_check_eq "$?" "0" "test failed"
isula version --help
fn_check_eq "$?" "0" "test failed"
isula foo --help
fn_check_ne "$?" "0" "test failed"
}
function do_test_t()
{
isulad_help
isula_help
isula_subcmd_help
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic help"
#!/bin/bash
#
# attributes: isulad inheritance kill
# concurrent: YES
# spend time: 4
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_kill
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula kill $containername
fn_check_eq "$?" "0" "kill failed"
sleep 2
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic kill"
#!/bin/bash
#
# attributes: isulad inheritance pause
# concurrent: YES
# spend time: 1
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
echo "Do not support pause function now"
return 0
containername=test_pause
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula pause $containername
fn_check_ne "$?" "0" "pause should fail"
testcontainer $containername inited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula pause $containername
fn_check_eq "$?" "0" "pause failed"
testcontainer $containername paused
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic pause"
#!/bin/bash
#
# attributes: isulad inheritance ps list
# concurrent: NO
# spend time: 14
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_list
containername2=test_list2
containername3=test_list3
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula create -t --name $containername2 busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername2 inited
isula create -t --name $containername3 busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername3 inited
# start container $containername2
isula start $containername2
fn_check_eq "$?" "0" "start failed"
testcontainer $containername2 running
# ps containers
cut_output_lines isula ps -a
if [[ "${lines[1]}" != *"Up"*"$containername2"* ]];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[2]}" != *"Created"* ]];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[3]}" != *"Created"* ]];then
echo "test failed"
TC_RET_T=$(($TC_RET_T+1))
fi
isula stop $containername2
fn_check_eq "$?" "0" "stop failed"
isula rm $containername $containername2 $containername3
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic ps"
#!/bin/bash
#
# attributes: isulad inheritance restart
# concurrent: YES
# spend time: 22
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_restart
isula run --name $containername -td busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula restart $containername
fn_check_eq "$?" "0" "restart failed"
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic restart"
#!/bin/bash
#
# attributes: isulad inheritance restartpolicy
# concurrent: NO
# spend time: 25
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_on_failure()
{
containername=test_rp_on_failure
isula run --name $containername -td --restart on-failure:3 busybox /bin/sh -c "exit 2"
fn_check_eq "$?" "0" "run failed"
sleep 6
count=`isula inspect --format='{{json .RestartCount}}' $containername`
if [[ $count != "3" ]];then
echo "expect 3 but get $count"
TC_RET_T=$(($TC_RET_T+1))
fi
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
}
function do_test_always_cancel()
{
containername=test_rp_always_cancel
isula run --name $containername -td --restart always busybox
testcontainer $containername running
cpid=`isula inspect -f '{{json .State.Pid}}' $containername`
kill -9 $cpid
sleep 6
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
}
function do_test_t()
{
do_test_on_failure
do_test_always_cancel
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic restartpolicy"
#!/bin/bash
#
# attributes: isulad inheritance resume
# concurrent: YES
# spend time: 1
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
echo "Do not support resume function now"
return 0
containername=test_resume
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula resume $containername
fn_check_ne "$?" "0" "resume should fail"
testcontainer $containername inited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula pause $containername
fn_check_eq "$?" "0" "pause failed"
testcontainer $containername paused
isula resume $containername
fn_check_eq "$?" "0" "resume failed"
testcontainer $containername running
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic resume"
#!/bin/bash
#
# attributes: isulad inheritance rm
# concurrent: YES
# spend time: 14
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function rm_stopped_container()
{
containername=test_rm_stopped
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
isula inspect $containername
fn_check_ne "$?" "0" "inspect should fail"
}
function rm_running_container()
{
containername=test_rm_running
isula run -td --name $containername busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula rm $containername
fn_check_ne "$?" "0" "rm should fail"
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
isula inspect $containername
fn_check_ne "$?" "0" "inspect should fail"
}
function rm_running_container_force()
{
containername=test_rm_running_force
isula run -td --name $containername busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula rm --force $containername
fn_check_eq "$?" "0" "rm failed"
isula inspect $containername
fn_check_ne "$?" "0" "inspect should fail"
}
function do_test_t()
{
rm_stopped_container
rm_running_container
rm_running_container_force
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic rm"
#!/bin/bash
#
# attributes: isulad inheritance run
# concurrent: YES
# spend time: 12
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_basic_run
isula run --name $containername -td busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula stop -t 0 $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
isula run --name $containername -td -v /dev/shm:/dev/shm busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula stop -t 0 $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic run"
#!/bin/bash
#
# attributes: isulad share namepaces
# concurrent: NO
# spend time: 6
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: gaohuatao
##- @Create: 2020-04-24
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
arr_ns_type[0]="--ipc"
arr_ns_type[1]="--pid"
arr_ns_type[2]="--net"
arr_ns_type[3]="--uts"
function do_test_t()
{
for((i = 0; i < ${#arr_ns_type[*]}; i++))
do
echo ${arr_ns_type[$i]}
cid[$i]=`isula create -ti busybox /bin/sh`
fn_check_eq "$?" "0" "create ${cid[$i]}"
msg=`isula run -tid ${arr_ns_type[$i]}="container:${cid[$i]}" busybox /bin/sh 2>&1`
echo $msg | grep "Can not join namespace of a non running container"
fn_check_eq "$?" "0" "share ipc fail test"
isula rm -f ${cid[$i]}
rid[$i]=`isula run -tid busybox /bin/sh`
fn_check_eq "$?" "0" "run ${rid[$i]}"
id=`isula run -tid busybox /bin/sh`
fn_check_eq "$?" "0" "run $id"
test_id=`isula run -tid ${arr_ns_type[$i]}="container:$id" busybox /bin/sh`
fn_check_eq "$?" "0" "share ${arr_ns_type[$i]} success test"
isula restart --time=0 $id
fn_check_eq "$?" "0" "restart container $id"
testcontainer $id running
isula restart --time=0 ${test_id}
fn_check_eq "$?" "0" "restart container ${test_id}"
testcontainer ${test_id} running
isula rm -f ${test_id} $id
done
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic share ns test"
#!/bin/bash
#
# attributes: isulad inheritance start
# concurrent: YES
# spend time: 11
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_start
isula create -t --name $containername busybox
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic start"
#!/bin/bash
#
# attributes: isulad inheritance stop
# concurrent: YES
# spend time: 24
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_stop
isula run --name $containername -td busybox
fn_check_eq "$?" "0" "run failed"
testcontainer $containername running
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop --force $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop --time 10 $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula stop --time 10 --force $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula rm $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic stop"
#!/bin/bash
#
# attributes: isulad inheritance update
# concurrent: YES
# spend time: 17
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function do_test_t()
{
containername=test_update
containerid=`isula create -t --name $containername busybox`
fn_check_eq "$?" "0" "create failed"
testcontainer $containername inited
isula start $containername
fn_check_eq "$?" "0" "start failed"
testcontainer $containername running
isula update --kernel-memory 1000000000 $containername
fn_check_ne "$?" "0" "update should fail"
isula update --cpu-shares 1024 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/cpu/cpu.shares`
if [ $tmp != "1024" ]; then
echo "Failed to check running cpu shares"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --cpu-period 100000 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/cpu/cpu.cfs_period_us`
if [ $tmp != "100000" ]; then
echo "Failed to check running cpu period"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --cpu-quota 50000 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us`
if [ $tmp != "50000" ]; then
echo "Failed to check running cpu quota"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --cpuset-cpus 0-1 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/cpuset/cpuset.cpus`
if [ $tmp != "0-1" ]; then
echo "Failed to check running cpu set"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --cpuset-mems 0 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/cpuset/cpuset.mems`
if [ $tmp != "0" ]; then
echo "Failed to check running cpu set mems"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --memory 1000000000 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/memory/memory.limit_in_bytes`
value=$(($tmp - 1000000000))
if [[ $value -lt -10000 || $value -gt 10000 ]]; then
echo "Failed to check running memory"
TC_RET_T=$(($TC_RET_T+1))
fi
isula update --memory-reservation 100000000 $containername
fn_check_eq "$?" "0" "update failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes`
value=$(($tmp - 100000000))
if [[ $value -lt -10000 || $value -gt 10000 ]]; then
echo "Failed to check running reservation memory"
TC_RET_T=$(($TC_RET_T+1))
fi
isula stop $containername
fn_check_eq "$?" "0" "stop failed"
testcontainer $containername exited
isula update --kernel-memory 2000000000 $containername
fn_check_eq "$?" "0" "update failed"
isula start $containername
fn_check_eq "$?" "0" "start failed"
tmp=`isula exec $containername cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes`
value=$(($tmp - 2000000000))
if [[ $value -lt -10000 || $value -gt 10000 ]]; then
echo "Failed to check running reservation memory"
TC_RET_T=$(($TC_RET_T+1))
fi
isula rm -f $containername
fn_check_eq "$?" "0" "rm failed"
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic update"
#!/bin/bash
#
# attributes: isulad inheritance version
# concurrent: YES
# spend time: 1
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng
##- @Create: 2020-03-30
#######################################################################
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/../data)
source ../helpers.bash
function isulad_version()
{
cut_output_lines isulad --version
fn_check_eq "$?" "0" "check failed"
if ! [[ ${lines[0]} =~ Version\ [0-9]+\.[0-9]+\.[0-9]+,\ commit ]];then
echo "isulad version error"
TC_RET_T=$(($TC_RET_T+1))
fi
}
function isula_version()
{
cut_output_lines isula --version
fn_check_eq "$?" "0" "check failed"
if ![[ ${lines[0]} =~ Version\ [0-9]+\.[0-9]+\.[0-9]+,\ commit ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
cut_output_lines isula version
fn_check_eq "$?" "0" "check failed"
if [[ "${lines[0]}" != "Client:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[1]}" != " Version:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[2]}" != " Git commit:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[3]}" != " Built:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[4]}" != "Server:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[5]}" != " Version:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[6]}" != " Git commit:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[7]}" != " Built:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[8]}" != "OCI config:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[9]}" != " Version:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
if [[ "${lines[10]}" != " Default file:"* ]];then
echo "isula version error"
TC_RET_T=$(($TC_RET_T+1))
fi
}
function do_test_t()
{
isula_version
isulad_version
return $TC_RET_T
}
ret=0
do_test_t
if [ $? -ne 0 ];then
let "ret=$ret + 1"
fi
show_result $ret "basic version"
......@@ -579,6 +579,7 @@ int oci_image_conf_merge_into_spec(const char *image_name, container_config *con
out:
free(resolved_name);
free_imagetool_image(image_info);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册