diff --git a/CI/test_cases/container_cases/check_fd_leakage_of_isulad.bash b/CI/test_cases/container_cases/check_fd_leakage_of_isulad.bash index 4e51555b81ede734111741a6227461d842976900..b66f03ea7699e287aa0d49c219e2a01c40336488 100755 --- a/CI/test_cases/container_cases/check_fd_leakage_of_isulad.bash +++ b/CI/test_cases/container_cases/check_fd_leakage_of_isulad.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance fd # concurrent: NO -# spend time: 15 +# spend time: 16 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. # - iSulad licensed under the Mulan PSL v2. diff --git a/CI/test_cases/container_cases/cni_test.bash b/CI/test_cases/container_cases/cni_test.bash index 39107787a12639bffa9778d5874f9f6ef35262eb..1f5e2274914347e7c4f73a826abf00d653553bce 100644 --- a/CI/test_cases/container_cases/cni_test.bash +++ b/CI/test_cases/container_cases/cni_test.bash @@ -2,7 +2,7 @@ # # attributes: isulad cri cni # concurrent: NA -# spend time: 45 +# spend time: 46 curr_path=$(dirname $(readlink -f "$0")) data_path=$(realpath $curr_path/criconfigs) diff --git a/CI/test_cases/container_cases/cp.bash b/CI/test_cases/container_cases/cp.bash index a59a7f8e89398132e0d1de798441a62f29d57140..7f78cd7a0289d2adc112b71bc988e576d0f5c1b0 100644 --- a/CI/test_cases/container_cases/cp.bash +++ b/CI/test_cases/container_cases/cp.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic container hook # concurrent: NA -# spend time: 25 +# spend time: 8 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/create.bash b/CI/test_cases/container_cases/create.bash index f9fca3b8c2a51ef6e4a052d3bb167082f8d43830..055cd39aab19f8b282afa43c3bdd4137ddaf4917 100755 --- a/CI/test_cases/container_cases/create.bash +++ b/CI/test_cases/container_cases/create.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance create # concurrent: YES -# spend time: 4 +# spend time: 17 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/create_mtab_test.bash b/CI/test_cases/container_cases/create_mtab_test.bash index d90d059e5b30c889e3691e0e69baa23036fa36c6..f079e45ee868da7f3b0174610ee70faaacfd4f07 100755 --- a/CI/test_cases/container_cases/create_mtab_test.bash +++ b/CI/test_cases/container_cases/create_mtab_test.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance start # concurrent: YES -# spend time: 1 +# spend time: 2 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/export.bash b/CI/test_cases/container_cases/export.bash index ec5078c70bd150b9ec518c70541c29f6c4b520c8..143be4c8fd7d47019dfdb39318973d2c639e66a0 100755 --- a/CI/test_cases/container_cases/export.bash +++ b/CI/test_cases/container_cases/export.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic export container # concurrent: NA -# spend time: 5 +# spend time: 6 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/hook_ignore_poststart_error.bash b/CI/test_cases/container_cases/hook_ignore_poststart_error.bash index 9556219ba0f68da2ef2be4aaadaf81236ae376cc..0d39ffefee6484851f151312316b0e07eb52c74c 100644 --- a/CI/test_cases/container_cases/hook_ignore_poststart_error.bash +++ b/CI/test_cases/container_cases/hook_ignore_poststart_error.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic container hook # concurrent: NA -# spend time: 25 +# spend time: 7 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/hook_spec_test.bash b/CI/test_cases/container_cases/hook_spec_test.bash index 57f6a2f33e8ba97798a1019e5371f60af3c2ebee..c4fa397676280b99518333cfaf1b792798f480cd 100644 --- a/CI/test_cases/container_cases/hook_spec_test.bash +++ b/CI/test_cases/container_cases/hook_spec_test.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic container hook # concurrent: NA -# spend time: 5 +# spend time: 9 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/inspect.bash b/CI/test_cases/container_cases/inspect.bash new file mode 100644 index 0000000000000000000000000000000000000000..6de82789f9021474cc023cafdafb8c0573698839 --- /dev/null +++ b/CI/test_cases/container_cases/inspect.bash @@ -0,0 +1,149 @@ +#!/bin/bash +# +# attributes: isulad basic container hook +# concurrent: NA +# 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: lifeng +##- @Create: 2020-06-03 +####################################################################### + +declare -r curr_path=$(dirname $(readlink -f "$0")) +source ../helpers.bash +test_data_path=$(realpath $curr_path/test_data) + +function test_inspect_spec() +{ + local ret=0 + local image="busybox" + local test="container inspect test => (${FUNCNAME[@]})" + + msg_info "${test} starting..." + + isula pull ${image} + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} + + isula images | grep busybox + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) + + containername=test_inspect + + isula create --name $containername --ipc host --pid host --uts host --restart=on-failure:10 --hook-spec ${test_data_path}/test-hookspec.json --cpu-shares 100 --memory 5MB --memory-reservation 4MB --cpu-period 1000000 --cpu-quota 200000 --cpuset-cpus 1 --cpuset-mems 0 --kernel-memory 50M --pids-limit=10000 --volume /home:/root --env a=1 $image /bin/sh ls + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Path}}' $containername 2>&1 | grep "/bin/sh" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Args}}' $containername 2>&1 | grep "ls" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.IpcMode}}' $containername 2>&1 | grep "host" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.PidMode}}' $containername 2>&1 | grep "host" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.UTSMode}}' $containername 2>&1 | grep "host" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.RestartPolicy.Name}}' $containername 2>&1 | grep "on-failure" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.RestartPolicy.MaximumRetryCount}}' $containername 2>&1 | grep "10" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.HookSpec}}' $containername 2>&1 | grep "test-hookspec.json" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.Binds}}' $containername 2>&1 | grep "/home:/root" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.CPUShares}}' $containername 2>&1 | grep "100" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.Memory}}' $containername 2>&1 | grep "5242880" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.MemoryReservation}}' $containername 2>&1 | grep "4194304" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.CPUPeriod}}' $containername 2>&1 | grep "1000000" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.CPUQuota}}' $containername 2>&1 | grep "200000" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.CpusetCpus}}' $containername 2>&1 | grep "1" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.CpusetMems}}' $containername 2>&1 | grep "0" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.KernelMemory}}' $containername 2>&1 | grep "52428800" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .HostConfig.PidsLimit}}' $containername 2>&1 | grep "10000" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{.Config.Image}}' $containername 2>&1 | grep ${image} + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + image_id=$(isula inspect -f '{{.image.id}}' ${image}) + isula inspect --format='{{.Image}}' $containername 2>&1 | grep "sha256:${image_id}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + if [ -d /sys/fs/cgroup/files ];then + grepval="100" + else + grepval="0" + fi + isula inspect --format='{{json .HostConfig.FilesLimit}}' $containername 2>&1 | grep "$grepval" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Config.Env}}' $containername 2>&1 | grep "a=1" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Config.Cmd}}' $containername 2>&1 | grep "ls" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula rm -f $containername + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + containername=test_inspect_entrypoint + isula create --entrypoint /bin/sh --name $containername $image -c "exit 0" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Path}}' $containername 2>&1 | grep "/bin/sh" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Args}}' $containername 2>&1 | grep "exit 0" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Config.Entrypoint}}' $containername 2>&1 | grep "/bin/sh" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Config.Cmd}}' $containername 2>&1 | grep "exit 0" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula rm -f $containername + + msg_info "${test} finished with return ${ret}..." + return ${ret} +} + +declare -i ans=0 + +test_inspect_spec || ((ans++)) + +show_result ${ans} "${curr_path}/${0}" \ No newline at end of file diff --git a/CI/test_cases/container_cases/kill.bash b/CI/test_cases/container_cases/kill.bash index d09a48b0cfe267ca8d1b691aeadf4ea7460cc3be..f156c22601e9a92bc81e1d19d2b3cf5e237e042f 100755 --- a/CI/test_cases/container_cases/kill.bash +++ b/CI/test_cases/container_cases/kill.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance kill # concurrent: YES -# spend time: 9 +# spend time: 3 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/ps.bash b/CI/test_cases/container_cases/ps.bash index 589ee4d65916fdf051715af1de2b911d8bae3dff..def0a2e76bf6873dd1707d9a6b0646e91779572b 100755 --- a/CI/test_cases/container_cases/ps.bash +++ b/CI/test_cases/container_cases/ps.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance ps list # concurrent: NO -# spend time: 12 +# spend time: 11 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/rename.bash b/CI/test_cases/container_cases/rename.bash index 0347cd7b732a200f56e12f25ba50156ab4e37e0d..cedc4022550fdf6d8477fb821aaec02d57039ba2 100644 --- a/CI/test_cases/container_cases/rename.bash +++ b/CI/test_cases/container_cases/rename.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic container hook # concurrent: NA -# spend time: 5 +# spend time: 7 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/restart.bash b/CI/test_cases/container_cases/restart.bash index 677dc3599d4c2edb12f75a7b95e53be648dcc788..3d21d07d7231b6db79a9f391681e390305211367 100755 --- a/CI/test_cases/container_cases/restart.bash +++ b/CI/test_cases/container_cases/restart.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance restart # concurrent: YES -# spend time: 33 +# spend time: 26 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/restartpolicy.bash b/CI/test_cases/container_cases/restartpolicy.bash index 8a263643666b6eb35944efda76ec6358057dbac6..7c86894ef65b2a8f8fe98d1f32dc4bbd5e69d421 100755 --- a/CI/test_cases/container_cases/restartpolicy.bash +++ b/CI/test_cases/container_cases/restartpolicy.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance restartpolicy # concurrent: NO -# spend time: 29 +# spend time: 28 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/rm.bash b/CI/test_cases/container_cases/rm.bash index 6990dd2d2a0b3a97276b5664bddfbb9ccc752efc..4d9fbc202f2e4074d87d5d8b394db63c6d8175ec 100755 --- a/CI/test_cases/container_cases/rm.bash +++ b/CI/test_cases/container_cases/rm.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance rm # concurrent: YES -# spend time: 12 +# spend time: 24 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/share_ns_test.bash b/CI/test_cases/container_cases/share_ns_test.bash index e9b6c7b671d459a1313221be7edda1ad79017e68..4fceedc209c938a99af6677aadadcf612e195108 100755 --- a/CI/test_cases/container_cases/share_ns_test.bash +++ b/CI/test_cases/container_cases/share_ns_test.bash @@ -2,7 +2,7 @@ # # attributes: isulad share namepaces # concurrent: NO -# spend time: 25 +# spend time: 29 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/stats.bash b/CI/test_cases/container_cases/stats.bash new file mode 100644 index 0000000000000000000000000000000000000000..2daf7833bcc8f172535481579ae69ef41f80c062 --- /dev/null +++ b/CI/test_cases/container_cases/stats.bash @@ -0,0 +1,87 @@ +#!/bin/bash +# +# attributes: isulad basic container hook +# concurrent: NA +# spend time: 5 + +####################################################################### +##- @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-06-03 +####################################################################### + +declare -r curr_path=$(dirname $(readlink -f "$0")) +source ../helpers.bash + +function test_stats_spec() +{ + local ret=0 + local image="busybox" + local test="container stats test => (${FUNCNAME[@]})" + statslog=/tmp/stats.log + + msg_info "${test} starting..." + + isula pull ${image} + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} + + isula images | grep busybox + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) + + isula stats xxxxxx 2>&1 | grep "No such container" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula stats - 2>&1 | grep "Invalid container name" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + container_name_stop=stats_stopped + id_stop=`isula create -t -n $container_name_stop $image /bin/sh` + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + container_name_running=stats_running + id_running=`isula run -td -n $container_name_running $image /bin/sh` + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula stats --no-stream > $statslog + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + cat $statslog | grep "${id_running:0:12}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula stats --no-stream -a > $statslog + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + cat $statslog | grep "${id_running:0:12}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + cat $statslog | grep "${id_stop:0:12}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula stats --no-stream "$id_stop" > $statslog + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + cat $statslog | grep "${id_stop:0:12}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula rm -f "$container_name_stop" "$container_name_running" + + rm -f $statslog + + msg_info "${test} finished with return ${ret}..." + return ${ret} +} + +declare -i ans=0 + +test_stats_spec || ((ans++)) + +show_result ${ans} "${curr_path}/${0}" \ No newline at end of file diff --git a/CI/test_cases/container_cases/stop.bash b/CI/test_cases/container_cases/stop.bash index 4eb8dd5584fae27135be55f93fbe0466f041e9a1..0296a2f8e5a04efeb965a46e38818481809b769a 100755 --- a/CI/test_cases/container_cases/stop.bash +++ b/CI/test_cases/container_cases/stop.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance stop # concurrent: YES -# spend time: 28 +# spend time: 27 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/container_cases/top.bash b/CI/test_cases/container_cases/top.bash new file mode 100644 index 0000000000000000000000000000000000000000..6226811953832c43d32989677f05b6b4bb3fb52a --- /dev/null +++ b/CI/test_cases/container_cases/top.bash @@ -0,0 +1,56 @@ +#!/bin/bash +# +# attributes: isulad basic container hook +# concurrent: NA +# 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-06-03 +####################################################################### + +declare -r curr_path=$(dirname $(readlink -f "$0")) +source ../helpers.bash + +function test_top_spec() +{ + local ret=0 + local image="busybox" + local test="container top test => (${FUNCNAME[@]})" + + msg_info "${test} starting..." + + isula pull ${image} + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} + + isula images | grep busybox + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) + + CONT=`isula run -itd $image /bin/sh` + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula top $CONT -ef + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + isula rm -f $CONT + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + + msg_info "${test} finished with return ${ret}..." + return ${ret} +} + +declare -i ans=0 + +test_top_spec || ((ans++)) + +show_result ${ans} "${curr_path}/${0}" \ No newline at end of file diff --git a/CI/test_cases/container_cases/ulimit.bash b/CI/test_cases/container_cases/ulimit.bash new file mode 100644 index 0000000000000000000000000000000000000000..9640cb9811ef65149c891cce22bbe8c97c2f91dc --- /dev/null +++ b/CI/test_cases/container_cases/ulimit.bash @@ -0,0 +1,111 @@ +#!/bin/bash +# +# attributes: isulad inheritance restart +# concurrent: YES +# spend time: 18 + +####################################################################### +##- @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-07-1 +####################################################################### + +curr_path=$(dirname $(readlink -f "$0")) +data_path=$(realpath $curr_path/../data) +source ../helpers.bash + +function test_ulimit() +{ + local ret=0 + local image="busybox" + ulimitlog=/tmp/ulimit.log + + local test="ulimit test => (${FUNCNAME[@]})" + msg_info "${test} starting..." + + check_valgrind_log + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && ((ret++)) + + start_isulad_with_valgrind --default-ulimit nproc=2048:4096 --default-ulimit nproc=2048:8192 --default-ulimit nofile=1024:4096 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - start isulad failed" && ((ret++)) + + isula run --ulimit nproc= $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "delimiter '=' can't be the first or the last character" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit nproc=1024: $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "delimiter ':' can't be the first or the last character" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit npro=1024:2048 $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "Invalid ulimit type" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit nproc=4096:2048 $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "Ulimit soft limit must be less than or equal to hard limit" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit nproc=2048:4096.5 $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "Invalid ulimit hard value" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit nproc==2048:4096 $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "Invalid ulimit argument" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula run --ulimit nproc=2048::4096 $image /bin/sh > $ulimitlog 2>&1 + cat $ulimitlog | grep "Too many limit value arguments" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + container_name="ulimit_test" + + isula run -td -n $container_name --ulimit nofile=20480:40960 --ulimit core=1024:2048 $image /bin/sh + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max open files" |awk '{ print $(NF-1) }' |grep 40960 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max open files" |awk '{ print $(NF-2) }' |grep 20480 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max processes" |awk '{ print $(NF-1) }' |grep 8192 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max processes" |awk '{ print $(NF-2) }' |grep 2048 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max core file size" |awk '{ print $(NF-1) }' |grep 4 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula exec $container_name /bin/sh -c "cat /proc/self/limits" | grep "Max core file size" |awk '{ print $(NF-2) }' |grep 2 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + isula rm -f $container_name + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - check failed" && ((ret++)) + + check_valgrind_log + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && ((ret++)) + + start_isulad_with_valgrind + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - start isulad failed" && ((ret++)) + + rm -rf $ulimitlog + + msg_info "${test} finished with return ${ret}..." + return ${ret} +} + +declare -i ans=0 + +test_ulimit || ((ans++)) + +show_result ${ans} "${curr_path}/${0}" diff --git a/CI/test_cases/container_cases/version.bash b/CI/test_cases/container_cases/version.bash index 6216c5d1fbcb47ae78e39f659fed50d556d5da6c..941b4dc46bb1a1d5681d6c17506f442e36d07528 100755 --- a/CI/test_cases/container_cases/version.bash +++ b/CI/test_cases/container_cases/version.bash @@ -90,6 +90,8 @@ function isula_version() echo "isula version error" TC_RET_T=$(($TC_RET_T+1)) fi + + isula info } function do_test_t() diff --git a/CI/test_cases/image_cases/image_load.bash b/CI/test_cases/image_cases/image_load.bash index 61a8fd8a6141a4fe8809f40125e8059990f41e72..a033bf6d4e0448855e709782e5563c21dc73e615 100755 --- a/CI/test_cases/image_cases/image_load.bash +++ b/CI/test_cases/image_cases/image_load.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic image # concurrent: NA -# spend time: 18 +# spend time: 22 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/image_cases/image_remove.bash b/CI/test_cases/image_cases/image_remove.bash index f1d6035d2e6c6c95c84106456aaf64278d5fa303..8b279c6c43bc3c7438e713d833becc7ef25062eb 100755 --- a/CI/test_cases/image_cases/image_remove.bash +++ b/CI/test_cases/image_cases/image_remove.bash @@ -2,7 +2,7 @@ # # attributes: isulad basic remove image # concurrent: NA -# spend time: 8 +# spend time: 5 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/image_cases/image_tag.bash b/CI/test_cases/image_cases/image_tag.bash index 559dc40da4431ca71d4ba79a2071ffc61e39e22f..893565cb3cc07bb8370cd3ef0ab1c748e62a8aa0 100755 --- a/CI/test_cases/image_cases/image_tag.bash +++ b/CI/test_cases/image_cases/image_tag.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance tag # concurrent: YES -# spend time: 9 +# spend time: 10 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved. diff --git a/CI/test_cases/image_cases/registry.bash b/CI/test_cases/image_cases/registry.bash index 71df80e22aa77857385d5e1b62d39eba35dc0f21..b103be94532fe748191706c80b495840a95b609c 100755 --- a/CI/test_cases/image_cases/registry.bash +++ b/CI/test_cases/image_cases/registry.bash @@ -2,7 +2,7 @@ # # attributes: isulad inheritance version # concurrent: YES -# spend time: 7 +# spend time: 10 ####################################################################### ##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.