From f1c3a7ae0eac90a4cc8ffc6c9d019c60eb766634 Mon Sep 17 00:00:00 2001 From: lutianxiong Date: Thu, 23 Jul 2020 16:08:19 +0800 Subject: [PATCH] add new testcase --- suite2cases/smoke-testing | 3 + .../oe_test_iscsi/oe_test_iscsi.sh | 79 +++++++++++++++++++ .../smoke-testing/oe_test_nfs/oe_test_nfs.sh | 63 +++++++++++++++ .../oe_test_pciutils/oe_test_pciutils.sh | 38 +++++++++ 4 files changed, 183 insertions(+) create mode 100644 testcases/smoke-testing/oe_test_iscsi/oe_test_iscsi.sh create mode 100644 testcases/smoke-testing/oe_test_nfs/oe_test_nfs.sh create mode 100644 testcases/smoke-testing/oe_test_pciutils/oe_test_pciutils.sh diff --git a/suite2cases/smoke-testing b/suite2cases/smoke-testing index 34b4f49..5f0f024 100644 --- a/suite2cases/smoke-testing +++ b/suite2cases/smoke-testing @@ -35,3 +35,6 @@ oe_test_syslog_journalctl_002 oe_test_syslog_journald_001 oe_test_syslog_logrotate_001 oe_test_syslog_messages_001 +oe_test_iscsi +oe_test_nfs +oe_test_pciutils diff --git a/testcases/smoke-testing/oe_test_iscsi/oe_test_iscsi.sh b/testcases/smoke-testing/oe_test_iscsi/oe_test_iscsi.sh new file mode 100644 index 0000000..dce6860 --- /dev/null +++ b/testcases/smoke-testing/oe_test_iscsi/oe_test_iscsi.sh @@ -0,0 +1,79 @@ +#!/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. + +# ############################################# +# @Author : lutianxiong +# @Contact : lutianxiong@huawei.com +# @Date : 2020-07-20 +# @License : Mulan PSL v2 +# @Desc : open-iscsi & multipath-tools & target test +# ############################################ + +set -eo pipefail +source "$OET_PATH/libs/locallibs/common_lib.sh" +lun1=/home/iscsi_lun1_$$ +lun2=/home/iscsi_lun2_$$ +local_addr="127.0.0.1" +iscsi_name="iqn.2020-07.org.openeuler:iscsi$$" +firewall_status=0 + +function pre_test() { + dnf install -y open-iscsi multipath-tools target-restore targetcli + dd if=/dev/zero of=$lun1 count=10 bs=1M + dd if=/dev/zero of=$lun2 count=10 bs=1M + systemctl status --no-pager firewalld && firewall_status=1 + systemctl stop firewalld + mv /etc/iscsi/initiatorname.iscsi . +} + +function run_test() { + echo -e "cd /\n clearconfig confirm=true\n" | targetcli + echo -e "cd /backstores/fileio\n create name=disk1 file_or_dev=${lun1}\n" | targetcli + echo -e "cd /backstores/fileio\n create name=disk2 file_or_dev=${lun2}\n" | targetcli + echo -e "cd /iscsi\n create ${iscsi_name}\n" | targetcli + echo -e "cd /iscsi/${iscsi_name}/tpg1/acls\n create ${iscsi_name}:client\n" | targetcli + echo -e "cd /iscsi/${iscsi_name}/tpg1/luns\n create /backstores/fileio/disk1 lun1\n" | targetcli + echo -e "cd /iscsi/${iscsi_name}/tpg1/luns\n create /backstores/fileio/disk2 lun2\n" | targetcli + systemctl restart target + + echo "InitiatorName=${iscsi_name}:client" > /etc/iscsi/initiatorname.iscsi + systemctl restart iscsid + iscsiadm -m discovery -t st -p ${local_addr} + iscsiadm -m node -p ${local_addr} -l + + systemctl restart multipathd + path1=$(multipath -ll | grep disk1 | awk '{print $1}') + path2=$(multipath -ll | grep disk2 | awk '{print $1}') + test -n "$path1" && test -n "$path2" || return 1 + mkfs.ext4 -F /dev/mapper/$path1 + mkfs.ext4 -F /dev/mapper/$path2 + + iscsiadm -m node -p ${local_addr} -u + iscsiadm -m node -o delete -p ${local_addr} + systemctl stop multipathd + systemctl stop iscsid + systemctl stop target +} + +function post_test() { + set +e + iscsiadm -m node -p ${local_addr} -u + iscsiadm -m node -o delete -p ${local_addr} + systemctl stop multipathd + systemctl stop iscsid + systemctl stop target + echo -e "cd /\n clearconfig confirm=true\n" | targetcli + test -f initiatorname.iscsi && mv initiatorname.iscsi /etc/iscsi/initiatorname.iscsi + rm -rf $lun1 $lun2 + test ${firewall_status} -eq 1 && systemctl restart firewalld +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_nfs/oe_test_nfs.sh b/testcases/smoke-testing/oe_test_nfs/oe_test_nfs.sh new file mode 100644 index 0000000..237cbff --- /dev/null +++ b/testcases/smoke-testing/oe_test_nfs/oe_test_nfs.sh @@ -0,0 +1,63 @@ +#!/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. + +# ############################################# +# @Author : lutianxiong +# @Contact : lutianxiong@huawei.com +# @Date : 2020-07-20 +# @License : Mulan PSL v2 +# @Desc : nfs test +# ############################################ + +set -eo pipefail +source "$OET_PATH/libs/locallibs/common_lib.sh" +test_user=nfs_test_$$ +server_dir=/home/nfs_server_$$ +client_dir=/home/nfs_client_$$ + +function pre_test() { + dnf install -y nfs-utils nfs4-acl-tools + useradd $test_user + mkdir $server_dir $client_dir + test -f /etc/exports && cp /etc/exports . + return 0 +} + +function run_test() { + echo "$server_dir *(rw,sync,no_root_squash)" >> /etc/exports + systemctl restart nfs-server + showmount -e localhost | grep -w "$server_dir" + mount -t nfs4 localhost:$server_dir $client_dir + + echo "$$" > $client_dir/file + diff $server_dir/file $client_dir/file + + chmod 640 $client_dir/file + sudo -u $test_user cat $client_dir/file 2> error.log && return 1 + cat error.log | grep "Permission denied" + + uid=$(id -u $test_user) + nfs4_setfacl -a "A::${uid}:r" $client_dir/file + nfs4_getfacl $client_dir/file | grep "A::${uid}:r" + sudo -u $test_user cat $client_dir/file + umount $client_dir +} + +function post_test() { + set +e + umount $client_dir + rm -rf $client_dir $server_dir + userdel -r $test_user + rm -f error.log + test -f exports && mv exports /etc/exports +} + +main $@ diff --git a/testcases/smoke-testing/oe_test_pciutils/oe_test_pciutils.sh b/testcases/smoke-testing/oe_test_pciutils/oe_test_pciutils.sh new file mode 100644 index 0000000..cd908b8 --- /dev/null +++ b/testcases/smoke-testing/oe_test_pciutils/oe_test_pciutils.sh @@ -0,0 +1,38 @@ +#!/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. + +# ############################################# +# @Author : lutianxiong +# @Contact : lutianxiong@huawei.com +# @Date : 2020-07-20 +# @License : Mulan PSL v2 +# @Desc : pciutils test +# ############################################ + +set -eo pipefail +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + dnf install -y pciutils +} + +function run_test() { + lspci 2> error.log + test -s error.log && return 1 + update-pciids + lspci | grep "PCI bridge" +} + +function post_test() { + test -f error.log && cat error.log && rm -f error.log +} + +main $@ -- GitLab