diff --git a/suite2cases/smoke-testing b/suite2cases/smoke-testing index 34b4f49d41d2825dc4aff54780a3ff03799b2d61..85bf8fb090da45e742fee53bc0cd3602733391d3 100644 --- a/suite2cases/smoke-testing +++ b/suite2cases/smoke-testing @@ -35,3 +35,26 @@ oe_test_syslog_journalctl_002 oe_test_syslog_journald_001 oe_test_syslog_logrotate_001 oe_test_syslog_messages_001 +oe_test_docker_attach_001 +oe_test_docker_commit_export_import_001 +oe_test_docker_cp_001 +oe_test_docker_create_001 +oe_test_docker_create_002 +oe_test_docker_create_003 +oe_test_docker_exec_cmd_001 +oe_test_docker_image_history_001 +oe_test_docker_rename_pause_resume_001 +oe_test_docker_save_load_001 +oe_test_docker_search_info_001 +oe_test_docker_start_stop_delete_001 +oe_test_docker_tag_001 +oe_test_iSula_attach_rename_001 +oe_test_iSula_cp_001 +oe_test_iSula_create_start_001 +oe_test_iSula_exec_cmd_001 +oe_test_iSula_export_001 +oe_test_iSula_install_deploy_001 +oe_test_iSula_pause_resume_001 +oe_test_iSula_query_state_001 +oe_test_iSula_restart_stop_001 +oe_test_iSula_search_info_001 diff --git a/testcases/smoke-testing/common/prepare_docker.sh b/testcases/smoke-testing/common/prepare_docker.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9fe2facc307f11a4a8143b1a3d19edaea6c6fde --- /dev/null +++ b/testcases/smoke-testing/common/prepare_docker.sh @@ -0,0 +1,54 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : prepare_docker +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : prepare docker +# ############################################ + +source ${OET_PATH}/libs/locallibs/common_lib.sh +Images_name="busybox" +Image_address="ariq8blp.mirror.aliyuncs.com" + +function pre_docker_env() { + DNF_INSTALL docker + ping ${Image_address} -c 3 + if [ $? -ne 0 ];then + clean_docker_env + if [ ${FRAME} == aarch64 ];then + docker load -i ../common/openEuler-docker.aarch64.tar.xz + else + docker load -i ../common/openEuler-docker.x86_64.tar.xz + fi + Images_name=$(docker images | grep latest | awk '{print$1}') + else + docker pull ${Images_name} + fi +} + +function run_docker_container() { + containers_id=$(docker run -itd ${Images_name}) + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${containers_id} | grep running + CHECK_RESULT $? +} + +function clean_docker_env() { + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) + docker rmi $(docker images -q) + test -z "$(docker images -q)" + CHECK_RESULT $? +} diff --git a/testcases/smoke-testing/common/prepare_isulad.sh b/testcases/smoke-testing/common/prepare_isulad.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbef8cae1302e777a6facf080b6316ba10affeec --- /dev/null +++ b/testcases/smoke-testing/common/prepare_isulad.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : prepare_isulad +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : prepare isulad +# ############################################ + +source ${OET_PATH}/libs/locallibs/common_lib.sh +Images_names="busybox" +Image_address="ariq8blp.mirror.aliyuncs.com" + +function pre_isulad_env() { + DNF_INSTALL "iSulad tar" + clean_isulad_env + ping ${Image_address} -c 3 + if [ $? -eq 0 ];then + sed -i "/registry-mirrors/a\"https:\/\/${Image_address}\"" /etc/isulad/daemon.json + systemctl restart isulad + isula pull ${Images_name} + else + if [ ${FRAME} == aarch64 ];then + isula load -i ../common/openEuler-docker.aarch64.tar.xz + else + isula load -i ../common/openEuler-docker.x86_64.tar.xz + fi + Images_name=$(isula images | grep latest | awk '{print$1}') + fi +} + +function run_isulad_container() { + containerId=$(isula run -itd ${Images_name}) + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep running + CHECK_RESULT $? +} + +function clean_isulad_env() { + isula stop $(isula ps -aq) + isula rm $(isula ps -aq) + isula rmi $(isula images -q) + test -z "$(isula images -q)" + CHECK_RESULT $? + sed -i "/${Image_address}/d" /etc/isulad/daemon.json +} diff --git a/testcases/smoke-testing/oe_test_docker_attach_001/oe_test_docker_attach_001.sh b/testcases/smoke-testing/oe_test_docker_attach_001/oe_test_docker_attach_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..e7cdc1da6f6ef65def4520a62f2836d5f4c9e2a5 --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_attach_001/oe_test_docker_attach_001.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_attach_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Access container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + run_docker_container + + expect -c " + log_file testlog + spawn docker attach ${containers_id} + expect { + \"*\/*\" {send \"exit\r\"} +} +expect eof +" + grep -iE 'error|fail' testlog + CHECK_RESULT $? 1 + cat testlog | grep "/" | grep "exit" + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_docker_env + DNF_REMOVE docker + rm -rf testlog + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_commit_export_import_001/oe_test_docker_commit_export_import_001.sh b/testcases/smoke-testing/oe_test_docker_commit_export_import_001/oe_test_docker_commit_export_import_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..43e858b87021575b6e66ebd46d379d01eb898f76 --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_commit_export_import_001/oe_test_docker_commit_export_import_001.sh @@ -0,0 +1,66 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_commit_export_import_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Commit / export / import application of container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + run_docker_container + docker commit ${containers_id} ${Images_name}:test + CHECK_RESULT $? + + docker images | grep ${Images_name} | grep -w test + CHECK_RESULT $? + + docker export ${containers_id} > ${Images_name}.tar + CHECK_RESULT $? + test -f ${Images_name}.tar + CHECK_RESULT $? + + clean_docker_env + + docker images | grep ${Images_name} + CHECK_RESULT $? 1 + docker import ${Images_name}.tar ${Images_name}:latest + CHECK_RESULT $? + docker images | grep ${Images_name} | grep latest + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + docker rmi $(docker images -q) + DNF_REMOVE docker + rm -rf ${Images_name}.tar + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_cp_001/oe_test_docker_cp_001.sh b/testcases/smoke-testing/oe_test_docker_cp_001/oe_test_docker_cp_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..85591eca7d7edd3b9e9335914b930d4fae0883dd --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_cp_001/oe_test_docker_cp_001.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_cp_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : data copy between the container and the host +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + run_docker_container + + test -d testdir && rm -rf testdir + mkdir testdir + touch testdir/mytest.txt + docker cp testdir ${containers_id}:/root + CHECK_RESULT $? + + docker exec -i ${containers_id} /bin/sh >testlog <testlog <testlog < ${Images_name}.tar + CHECK_RESULT $? + test -f ${Images_name}.tar + CHECK_RESULT $? + + clean_docker_env + docker import ${Images_name}.tar ${Images_name}:latest + CHECK_RESULT $? + docker images | grep ${Images_name} | grep latest + CHECK_RESULT $? + + docker history ${Images_name}:latest | grep -i "Imported" + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + docker rmi $(docker images -q) + DNF_REMOVE docker + rm -rf ${Images_name}.tar + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_rename_pause_resume_001/oe_test_docker_rename_pause_resume_001.sh b/testcases/smoke-testing/oe_test_docker_rename_pause_resume_001/oe_test_docker_rename_pause_resume_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bc9cd975cbf6aeaedbe50906a2cedaa5d12a271 --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_rename_pause_resume_001/oe_test_docker_rename_pause_resume_001.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_rename_pause_resume_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Rename container/pause and resume container process +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "Start loading data." + container_name=old_container + new_name=new_container + LOG_INFO "Loading data is complete." +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + docker run -itd --name=${container_name} ${Images_name} + CHECK_RESULT $? + + docker rename ${container_name} ${new_name} + CHECK_RESULT $? + docker ps -a | grep ${new_name} + CHECK_RESULT $? + docker ps -a | grep ${container_name} + CHECK_RESULT $? 1 + + docker pause ${new_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${new_name} | grep paused + + docker unpause ${new_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${new_name} | grep running + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_docker_env + DNF_REMOVE docker + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_save_load_001/oe_test_docker_save_load_001.sh b/testcases/smoke-testing/oe_test_docker_save_load_001/oe_test_docker_save_load_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..40c58724e5e16571f8eefbb1758754ad0ea00c73 --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_save_load_001/oe_test_docker_save_load_001.sh @@ -0,0 +1,64 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_save_load_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Save an image to a tar package / tar package saved by docker reload an image +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + docker images | grep ${Images_name} + CHECK_RESULT $? + + docker save -o ${Images_name}.tar ${Images_name}:latest + CHECK_RESULT $? + + test -f ${Images_name}.tar + CHECK_RESULT $? + + Images_id=$(docker images ${Images_name} -q) + docker rmi ${Images_id} + docker images | grep ${Images_name} + CHECK_RESULT $? 1 + docker load -i ${Images_name}.tar + CHECK_RESULT $? + + docker images | grep ${Images_name} + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf ${Images_name}.tar + clean_docker_env + DNF_REMOVE docker + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_search_info_001/oe_test_docker_search_info_001.sh b/testcases/smoke-testing/oe_test_docker_search_info_001/oe_test_docker_search_info_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b43aa789738df68ca45c59aeab2eec330dd4326 --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_search_info_001/oe_test_docker_search_info_001.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_search_info_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Container information query +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "Start loading data." + container_name=container_test + LOG_INFO "Loading data is complete." +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + containers_id=$(docker run -itd --name=${container_name} ${Images_name}) + CHECK_RESULT $? + + docker inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + docker inspect -f {{.Name}} ${container_name} | grep ${container_name} + CHECK_RESULT $? + + docker inspect -f {{.State.Status}} ${containers_id} | grep running + CHECK_RESULT $? + docker inspect -f {{.Name}} ${containers_id} | grep ${container_name} + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_docker_env + DNF_REMOVE docker + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_start_stop_delete_001/oe_test_docker_start_stop_delete_001.sh b/testcases/smoke-testing/oe_test_docker_start_stop_delete_001/oe_test_docker_start_stop_delete_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..30254d6ca88f9b71f59c65515791fc67f2ebbfea --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_start_stop_delete_001/oe_test_docker_start_stop_delete_001.sh @@ -0,0 +1,80 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_start_stop_delete_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Start / stop / delete container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "Start loading data." + container_name=container_test + LOG_INFO "Loading data is complete." +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + docker run -itd --name=${container_name} ${Images_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + + docker stop ${container_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${container_name} | grep exited + CHECK_RESULT $? + + docker start ${container_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + docker kill ${container_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${container_name} | grep exited + CHECK_RESULT $? + docker rm ${container_name} + CHECK_RESULT $? + docker ps -a | grep ${container_name} + CHECK_RESULT $? 1 + + docker run -itd --name=${container_name} ${Images_name} + CHECK_RESULT $? + docker inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + docker stop ${container_name} + CHECK_RESULT $? + docker rm -f ${container_name} + CHECK_RESULT $? + docker ps -a | grep ${container_name} + CHECK_RESULT $? 1 + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_docker_env + DNF_REMOVE docker + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_docker_tag_001/oe_test_docker_tag_001.sh b/testcases/smoke-testing/oe_test_docker_tag_001/oe_test_docker_tag_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..ae893b7f057ff7180a8e2c0c948e54bd28f3cfcf --- /dev/null +++ b/testcases/smoke-testing/oe_test_docker_tag_001/oe_test_docker_tag_001.sh @@ -0,0 +1,54 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_docker_tag_001 +# @Author : Classicriver_jia +# @Contact : classicriver_jia@foxmail.com +# @Date : 2020-06-08 +# @License : Mulan PSL v2 +# @Desc : Tag an image into a library +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_docker.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_docker_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase." + docker images | grep ${Images_name} + CHECK_RESULT $? + + docker tag ${Images_name}:latest ${Images_name}:test_tag + CHECK_RESULT $? + + docker images | grep ${Images_name} | grep test_tag + CHECK_RESULT $? + LOG_INFO "End of testcase execution." +} + +function post_test() { + LOG_INFO "start environment cleanup." + docker rmi ${Images_name}:test_tag + clean_docker_env + DNF_REMOVE docker + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_attach_rename_001/oe_test_iSula_attach_rename_001.sh b/testcases/smoke-testing/oe_test_iSula_attach_rename_001/oe_test_iSula_attach_rename_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..35144aa60fb4ff06540df43bf79ec9f83b8e08fa --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_attach_rename_001/oe_test_iSula_attach_rename_001.sh @@ -0,0 +1,73 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_attach_rename_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : attach and rename containers +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + run_isulad_container + + expect -c " + log_file testlog + spawn isula attach ${containerId} + sleep 1 + expect { + \"\" {send \"\r\"; + expect \"*/*\" {send \"exit\r\"} +} +} +expect eof +" + grep -iE 'error|fail' testlog + CHECK_RESULT $? 1 + + cat testlog | grep "/" | grep "exit" + CHECK_RESULT $? + + container_name=$(isula ps -a | grep ${Images_name} | awk '{print$NF}') + CHECK_RESULT $? + + isula rename ${container_name} ${container_name}_test + CHECK_RESULT $? + + isula ps -a | grep "${container_name}_test" + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + rm -rf testlog + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_cp_001/oe_test_iSula_cp_001.sh b/testcases/smoke-testing/oe_test_iSula_cp_001/oe_test_iSula_cp_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..cea24086ca72b11dbe20a7aa513e512731748056 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_cp_001/oe_test_iSula_cp_001.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_cp_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : Copy between container and host +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + run_isulad_container + + test -d testdir || mkdir testdir + touch testdir/mytest.txt + isula cp testdir ${containerId}:/home + CHECK_RESULT $? + isula exec -it ${containerId} /bin/sh -c "ls /home/testdir" | grep mytest.txt + CHECK_RESULT $? + + isula cp ${containerId}:/home . + CHECK_RESULT $? + ls home/testdir | grep mytest.txt + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf testdir home + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_create_start_001/oe_test_iSula_create_start_001.sh b/testcases/smoke-testing/oe_test_iSula_create_start_001/oe_test_iSula_create_start_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..78197f93170fb2d5fb70c65b307274ee49f18016 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_create_start_001/oe_test_iSula_create_start_001.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_create_start_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : create and start container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + containerId=$(isula create -it ${Images_name}) + CHECK_RESULT $? + + isula start ${containerId} + CHECK_RESULT $? + + isula inspect -f {{.State.Status}} ${containerId} | grep running + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_exec_cmd_001/oe_test_iSula_exec_cmd_001.sh b/testcases/smoke-testing/oe_test_iSula_exec_cmd_001/oe_test_iSula_exec_cmd_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1da8026134f2932b1b893c369076e0c879e7e0e --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_exec_cmd_001/oe_test_iSula_exec_cmd_001.sh @@ -0,0 +1,66 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_exec_cmd_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : Execute command in container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + run_isulad_container + expect -c " + log_file testlog + spawn isula attach ${containerId} + sleep 1 + expect { + \"\" {send \"\r\"; + expect \"\/*\" {send \"ls\r\"} + expect \"\/*\" {send \"exit\r\"} +} +} +" + cat testlog | grep -E 'bin|home' + CHECK_RESULT $? + + isula start ${containerId} + isula inspect -f {{.State.Status}} ${containerId} | grep running + CHECK_RESULT $? + isula exec -it ${containerId} /bin/sh -c "ls / | grep bin" | grep bin + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + rm -rf testlog + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_export_001/oe_test_iSula_export_001.sh b/testcases/smoke-testing/oe_test_iSula_export_001/oe_test_iSula_export_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e94312a1c790f7be566bee7cd36acd7bcbc75b7 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_export_001/oe_test_iSula_export_001.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_export_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : Export container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + isula run -itd ${Images_name} + CHECK_RESULT $? + + container_name=$(isula ps -a | grep ${Images_name} | awk '{print$NF}') + CHECK_RESULT $? + + isula inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + + isula export -o ${Images_name}.tar ${container_name} + CHECK_RESULT $? + + test -f ${Images_name}.tar + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf ${Images_name}.tar + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_install_deploy_001/oe_test_iSula_install_deploy_001.sh b/testcases/smoke-testing/oe_test_iSula_install_deploy_001/oe_test_iSula_install_deploy_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..5563d0ebb8f68ad96f5cb22067f4c2d909e43259 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_install_deploy_001/oe_test_iSula_install_deploy_001.sh @@ -0,0 +1,55 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_install_deploy_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : install and deploy iSula container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + DNF_INSTALL iSulad + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + systemctl status isulad | grep running + CHECK_RESULT $? + + sed -i "/registry-mirrors/a\"https:\/\/${Image_address}\"" /etc/isulad/daemon.json + systemctl restart isulad + CHECK_RESULT $? + + systemctl status isulad | grep running + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf /etc/isulad/daemon.json + sed -i "/${Image_address}/d" /etc/isulad/daemon.json + DNF_REMOVE iSulad + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_pause_resume_001/oe_test_iSula_pause_resume_001.sh b/testcases/smoke-testing/oe_test_iSula_pause_resume_001/oe_test_iSula_pause_resume_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..679adc36c449139bc7507fbe215eb0f95a67b6ca --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_pause_resume_001/oe_test_iSula_pause_resume_001.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash +#copyright (c) [2020] Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @Casename : oe_test_iSula_pause_resume_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : Pause and resume container / query isula information +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + isula run -itd ${Images_name} + CHECK_RESULT $? + container_name=$(isula ps -a | grep ${Images_name} | awk '{print$NF}') + isula inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + + isula pause ${container_name} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${container_name} | grep paused + CHECK_RESULT $? + + isula unpause ${container_name} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + + isula version | grep -i version + CHECK_RESULT $? + + isula info | grep "/var/lib/isula" + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_query_state_001/oe_test_iSula_query_state_001.sh b/testcases/smoke-testing/oe_test_iSula_query_state_001/oe_test_iSula_query_state_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..4a7d414b09c3dd687f859f61e5a487121f483e15 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_query_state_001/oe_test_iSula_query_state_001.sh @@ -0,0 +1,55 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_query_state_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : Querying resources used by containers +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + containerId=$(isula run -itd ${Images_name} /bin/sh -c "while true;do echo hello world;sleep 1;done") + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep running + CHECK_RESULT $? + + isula logs ${containerId} | grep "hello world" + CHECK_RESULT $? + + isula top ${containerId} + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_restart_stop_001/oe_test_iSula_restart_stop_001.sh b/testcases/smoke-testing/oe_test_iSula_restart_stop_001/oe_test_iSula_restart_stop_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..69643f28ddef8ace0610a1ae205f5d4eb3dac857 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_restart_stop_001/oe_test_iSula_restart_stop_001.sh @@ -0,0 +1,66 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_restart_stop_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : restart and stop container +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + run_isulad_container + + isula restart ${containerId} | grep ${containerId} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep running + CHECK_RESULT $? + + isula stop ${containerId} | grep ${containerId} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep exited + CHECK_RESULT $? + + isula start ${containerId} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep running + CHECK_RESULT $? + + isula kill ${containerId} | grep ${containerId} + CHECK_RESULT $? + isula inspect -f {{.State.Status}} ${containerId} | grep exited + CHECK_RESULT $? + LOG_INFO "End of run testcase!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_iSula_search_info_001/oe_test_iSula_search_info_001.sh b/testcases/smoke-testing/oe_test_iSula_search_info_001/oe_test_iSula_search_info_001.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d16d5bfec01d8f6098bf058a192f0870a679ea2 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iSula_search_info_001/oe_test_iSula_search_info_001.sh @@ -0,0 +1,55 @@ +#!/usr/bin/bash + +# Copyright (c) 2020 Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM 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. + +# ############################################# +# @CaseName : oe_test_iSula_search_info_001 +# @Author : duanxuemin +# @Contact : duanxuemin@163.com +# @Date : 2020-06-09 +# @License : Mulan PSL v2 +# @Desc : search container information +# ############################################ + +source ${OET_PATH}/testcases/smoke-testing/common/prepare_isulad.sh +source ${OET_PATH}/libs/locallibs/common_lib.sh +function config_params() { + LOG_INFO "This test case has no config params to load!" +} + +function pre_test() { + LOG_INFO "Start environment preparation." + pre_isulad_env + LOG_INFO "Environmental preparation is over." +} + +function run_test() { + LOG_INFO "Start executing testcase!" + run_isulad_container + + isula ps -a | grep ${Images_name} + CHECK_RESULT $? + + container_name=$(isula ps -a | grep ${Images_name} | awk '{print$NF}') + CHECK_RESULT $? + + isula inspect -f {{.State.Status}} ${container_name} | grep running + CHECK_RESULT $? + LOG_INFO "End of testcase execution!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + clean_isulad_env + DNF_REMOVE "iSulad tar" + LOG_INFO "Finish environment cleanup." +} + +main $@