From c3d1bed6977754faea693395353a315b1a525fd6 Mon Sep 17 00:00:00 2001 From: Classicriver <763403775@qq.com> Date: Thu, 30 Jul 2020 10:00:21 +0800 Subject: [PATCH] docker_and_isulad --- suite2cases/smoke-testing | 23 ++++++ .../smoke-testing/common/prepare_docker.sh | 54 +++++++++++++ .../smoke-testing/common/prepare_isulad.sh | 57 +++++++++++++ .../oe_test_docker_attach_001.sh | 60 ++++++++++++++ ...oe_test_docker_commit_export_import_001.sh | 66 +++++++++++++++ .../oe_test_docker_cp_001.sh | 65 +++++++++++++++ .../oe_test_docker_create_001.sh | 50 ++++++++++++ .../oe_test_docker_create_002.sh | 62 ++++++++++++++ .../oe_test_docker_create_003.sh | 52 ++++++++++++ .../oe_test_docker_exec_cmd_001.sh | 60 ++++++++++++++ .../oe_test_docker_image_history_001.sh | 64 +++++++++++++++ .../oe_test_docker_rename_pause_resume_001.sh | 65 +++++++++++++++ .../oe_test_docker_save_load_001.sh | 64 +++++++++++++++ .../oe_test_docker_search_info_001.sh | 59 ++++++++++++++ .../oe_test_docker_start_stop_delete_001.sh | 80 +++++++++++++++++++ .../oe_test_docker_tag_001.sh | 54 +++++++++++++ .../oe_test_iSula_attach_rename_001.sh | 73 +++++++++++++++++ .../oe_test_iSula_cp_001.sh | 59 ++++++++++++++ .../oe_test_iSula_create_start_001.sh | 52 ++++++++++++ .../oe_test_iSula_exec_cmd_001.sh | 66 +++++++++++++++ .../oe_test_iSula_export_001.sh | 60 ++++++++++++++ .../oe_test_iSula_install_deploy_001.sh | 55 +++++++++++++ .../oe_test_iSula_pause_resume_001.sh | 65 +++++++++++++++ .../oe_test_iSula_query_state_001.sh | 55 +++++++++++++ .../oe_test_iSula_restart_stop_001.sh | 66 +++++++++++++++ .../oe_test_iSula_search_info_001.sh | 55 +++++++++++++ 26 files changed, 1541 insertions(+) create mode 100644 testcases/smoke-testing/common/prepare_docker.sh create mode 100644 testcases/smoke-testing/common/prepare_isulad.sh create mode 100644 testcases/smoke-testing/oe_test_docker_attach_001/oe_test_docker_attach_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_commit_export_import_001/oe_test_docker_commit_export_import_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_cp_001/oe_test_docker_cp_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_create_001/oe_test_docker_create_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_create_002/oe_test_docker_create_002.sh create mode 100644 testcases/smoke-testing/oe_test_docker_create_003/oe_test_docker_create_003.sh create mode 100644 testcases/smoke-testing/oe_test_docker_exec_cmd_001/oe_test_docker_exec_cmd_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_image_history_001/oe_test_docker_image_history_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_rename_pause_resume_001/oe_test_docker_rename_pause_resume_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_save_load_001/oe_test_docker_save_load_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_search_info_001/oe_test_docker_search_info_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_start_stop_delete_001/oe_test_docker_start_stop_delete_001.sh create mode 100644 testcases/smoke-testing/oe_test_docker_tag_001/oe_test_docker_tag_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_attach_rename_001/oe_test_iSula_attach_rename_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_cp_001/oe_test_iSula_cp_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_create_start_001/oe_test_iSula_create_start_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_exec_cmd_001/oe_test_iSula_exec_cmd_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_export_001/oe_test_iSula_export_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_install_deploy_001/oe_test_iSula_install_deploy_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_pause_resume_001/oe_test_iSula_pause_resume_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_query_state_001/oe_test_iSula_query_state_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_restart_stop_001/oe_test_iSula_restart_stop_001.sh create mode 100644 testcases/smoke-testing/oe_test_iSula_search_info_001/oe_test_iSula_search_info_001.sh diff --git a/suite2cases/smoke-testing b/suite2cases/smoke-testing index 34b4f49..85bf8fb 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 0000000..b9fe2fa --- /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 0000000..fbef8ca --- /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 0000000..e7cdc1d --- /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 0000000..43e858b --- /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 0000000..85591ec --- /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 0000000..6bc9cd9 --- /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 0000000..40c5872 --- /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 0000000..5b43aa7 --- /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 0000000..30254d6 --- /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 0000000..ae893b7 --- /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 0000000..35144aa --- /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 0000000..cea2408 --- /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 0000000..78197f9 --- /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 0000000..e1da802 --- /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 0000000..7e94312 --- /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 0000000..5563d0e --- /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 0000000..679adc3 --- /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 0000000..4a7d414 --- /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 0000000..69643f2 --- /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 0000000..0d16d5b --- /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 $@ -- GitLab