case1

rpc-gssd服务

要执行rpc.gssd进程,首先要启动rpc-gssd服务:

[ ! -f /etc/krb5.keytab ] &&  touch /etc/krb5.keytab

systemctl start rpc-gssd      systemctl status rpc-gssd

对于会hang住 case:

1.使用timeout命令控制退出,timeout命令的返回值是后面命令的返回值,当命令出错时,timeout会返回一个大于0的随机值

eg:  timeout 300 mount -o vers=4.0 xxxx

       [ $? -eq 0 ] && umount $nfsmp   

2.在MAKEFILE 文件中有一个默认的退出时间

减少复杂的环境控制:

ssh $SERVER service nfslock restart

双机测试时,需要打开set_ssh_whitout_passwd

手动测试时使用公私钥免密码登陆

 

简化的if判断:

lockp=lockd

[[ $V = 4* ]] && lockp=nfsd

run "ssh $SERVER $lsLocks | grep $lockp"

 

SCREEN在case中的应用:

run "screen -dm bash -c "which true; do timeout 3 ./test_lcok $nfsmp/stats; sleep 1; done &>screen.log"   

#将程序放在screen中执行,将错误放到log中记录起来

run "ps aux | grep -v grep | grep SCREEN"

if [ $? -ne 0 ]; then

  run "cat screen.log"

fi

将指定命令循环执行,当出现要达到的结果时结束循环

run "while :; do $lsLocks | grep -q test_lock && break; done"

git clone uptream的包:

mkdir upstream

cd upstream

git clone git://git.linux-nfs.org/projects/steved/nfs-utils.git   #nfs-utils的upstream repo

git clone git://git.app.eng.bos.redhat.com/linux.git              #kernel的upstream repo

 

nfs-utils版本比较方法:

vercmp "$(rpm -q nfs-utils)"  '>'  "nfs-utils-1.3.0"          #rhel6安装的nfs-utils版本nfs-utils-1.3.0

nfs 版本比较的方法:

[ "${V:0:2}" == "4." ]      #将版本号按照字符串来处理

[[ "$V" < 4 ]]       #模式匹配

[[ $V = 4* ]]         #模式匹配

 

kernel版本号比较的方法:

if  vercmp "$(uname -r)"  '>='  "4.11";  then...

elif vercmp "$(uname -r)"  '>='  "3.10";    then...

else   ....

fi

当不同的rhel对应参数不同时,在case开始前用if进行判断对参数进行赋值

#rhel7 uses lslocks provided by util-linux

if which lslocks >/dev/null 2>&1; then

  lsLocks=lslocks

#rhel6 uses lslk from package lslk

elif which lslk >/dev/null 2>&1; then

  lsLocks=lslk

else

  echo "{Warn} Need to use tool lslocks or lslk to execute this test."

  report_result $TEST FAIL

  exit 1

fi

 

 

查看某一服务的状态,并开启服务

service_nfsconfig status &> /dev/null && service_nfsconfig restart

从一个已知文件读取其中一部分内容

read u g  nil <<<"$(awk -F: '$1=="nfsnobody" {print $3, $4}' /etc/passwd)"    #切割/etc/passwd中$1=nfsbody那一行的$3,$4的内容,并读入u,g

test "$u:s4g = 65534:65534"       #测试

对照case结果bkr-autorun-diff

fs-qe.usersys.redhat.com机器上不同数据库的比较:

bkr-autorun-diff --db /home/yoyang/.testrundb/testrun.db --db /home/yieli/.testrundb/testrun.db --diff

同一数据库的比较:

bkr-autorun-diff --db /home/yieli/.testrundb/testrun.db --diff

原文地址:https://www.cnblogs.com/yieli/p/7678508.html