提交 f1c3a7ae 编写于 作者: L lutianxiong

add new testcase

上级 2b59e1b3
......@@ -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
#!/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 $@
#!/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 $@
#!/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 $@
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册