From 61096e21e96a23543d8cd8294e994d61f6d7bb63 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 May 2018 05:32:53 -0400 Subject: [PATCH 1/3] add test case for xcatprobe detect_dhcpd command --- .../autotest/testcase/probe/detect_dhcpd | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 xCAT-test/autotest/testcase/probe/detect_dhcpd diff --git a/xCAT-test/autotest/testcase/probe/detect_dhcpd b/xCAT-test/autotest/testcase/probe/detect_dhcpd new file mode 100644 index 000000000..9a3097f57 --- /dev/null +++ b/xCAT-test/autotest/testcase/probe/detect_dhcpd @@ -0,0 +1,30 @@ +start:detect_dhcpd_work +description:To test if xcatprobe detect_dhcpd works. This case must run in xcat mn +cmd:if [ -d "/tmp/detect_dhcpd_work" ]; then mv /tmp/detect_dhcpd_work /tmp/detect_dhcpd_work.bak; fi; mkdir -p /tmp/detect_dhcpd_work +#cmd:makedhcp -n +#check:rc == 0 +#cmd:makedhcp $$CN +#check:rc == 0 +#cmd:#!/bin/bash +#if [ -e "/etc/redhat-release" ]; then +# rpm -qa |grep tcpdump +# if [ "$?" != "0" ] ;then +# yum install -y tcpdump +# fi +#elif [ -e "/etc/SuSE-release" ]; then +# rpm -qa |grep tcpdump +# if [ "$?" != "0" ] ;then +# zypper -n install tcpdump +# fi +#elif [ -e "/etc/lsb-release" ]; then +# dpkg -l|grep tcpdump +# if [ "$?" != "0" ] ;then +# apt-get install -y +# fi +#fi +cmd:declare -a array=(`lsdef $$CN -i mac -c|awk -F"=" '{print $2}'|sed 's/|/ /g'`);for i in "${array[@]}"; do if ! echo $i|grep -q NOIP;then echo "$i" > /tmp/detect_dhcpd_work/mac;break;fi;done; +cmd:mac=`cat /tmp/detect_dhcpd_work/mac`; mn=`lsdef -t site -i master -c|awk -F"=" '{print $2}'`;nic=`ip -4 -o a|grep $mn|awk -F" " '{print $2}'`;xcatprobe detect_dhcpd -i $nic -m $mac +check:output !~ There are 0 servers replied to dhcp discover +check:output =~ The next server is +#cmd:rm -rf /tmp/detect_dhcpd_work; if [ -d "/tmp/detect_dhcpd_work.bak" ]; then mv /tmp/detect_dhcpd_work.bak /tmp/detect_dhcpd_work;fi +end From ff8202a13b5395872020f3857e26fdf5f0b6bfe5 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 May 2018 21:33:10 -0400 Subject: [PATCH 2/3] add test case for xcatprobe detect_dhcpd command --- .../autotest/testcase/probe/detect_dhcpd | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/xCAT-test/autotest/testcase/probe/detect_dhcpd b/xCAT-test/autotest/testcase/probe/detect_dhcpd index 9a3097f57..b3eccc0fd 100644 --- a/xCAT-test/autotest/testcase/probe/detect_dhcpd +++ b/xCAT-test/autotest/testcase/probe/detect_dhcpd @@ -1,30 +1,45 @@ start:detect_dhcpd_work description:To test if xcatprobe detect_dhcpd works. This case must run in xcat mn cmd:if [ -d "/tmp/detect_dhcpd_work" ]; then mv /tmp/detect_dhcpd_work /tmp/detect_dhcpd_work.bak; fi; mkdir -p /tmp/detect_dhcpd_work -#cmd:makedhcp -n -#check:rc == 0 -#cmd:makedhcp $$CN -#check:rc == 0 -#cmd:#!/bin/bash -#if [ -e "/etc/redhat-release" ]; then -# rpm -qa |grep tcpdump -# if [ "$?" != "0" ] ;then -# yum install -y tcpdump -# fi -#elif [ -e "/etc/SuSE-release" ]; then -# rpm -qa |grep tcpdump -# if [ "$?" != "0" ] ;then -# zypper -n install tcpdump -# fi -#elif [ -e "/etc/lsb-release" ]; then -# dpkg -l|grep tcpdump -# if [ "$?" != "0" ] ;then -# apt-get install -y -# fi -#fi -cmd:declare -a array=(`lsdef $$CN -i mac -c|awk -F"=" '{print $2}'|sed 's/|/ /g'`);for i in "${array[@]}"; do if ! echo $i|grep -q NOIP;then echo "$i" > /tmp/detect_dhcpd_work/mac;break;fi;done; -cmd:mac=`cat /tmp/detect_dhcpd_work/mac`; mn=`lsdef -t site -i master -c|awk -F"=" '{print $2}'`;nic=`ip -4 -o a|grep $mn|awk -F" " '{print $2}'`;xcatprobe detect_dhcpd -i $nic -m $mac +cmd:makedhcp -n +check:rc == 0 +cmd:makedhcp $$CN +check:rc == 0 +cmd:#!/bin/bash +if [ -e "/etc/redhat-release" ]; then + rpm -qa |grep tcpdump + if [ "$?" != "0" ] ;then + yum install -y tcpdump + fi +elif [ -e "/etc/SuSE-release" ]; then + rpm -qa |grep tcpdump + if [ "$?" != "0" ] ;then + zypper -n install tcpdump + fi +elif [ -e "/etc/lsb-release" ]; then + dpkg -l|grep tcpdump + if [ "$?" != "0" ] ;then + apt-get install -y + fi +fi +cmd:echo "$$CN" |tee /tmp/detect_dhcpd_work/cn +cmd: #!/bin/bash +cn=`cat /tmp/detect_dhcpd_work/cn` +mac="" +nic="" +declare -a array=(`lsdef $cn -i mac -c|awk -F"=" '{print $2}'|sed 's/|/ /g'`) +for i in "${array[@]}" +do + if ! echo $i|grep -q NOIP + then + mac=$i + break + fi +done +mn=`lsdef -t site -i master -c|awk -F"=" '{print $2}'` +nic=`ip -4 -o a|grep $mn|awk -F" " '{print $2}'` +xcatprobe -w detect_dhcpd -i $nic -m $mac check:output !~ There are 0 servers replied to dhcp discover -check:output =~ The next server is -#cmd:rm -rf /tmp/detect_dhcpd_work; if [ -d "/tmp/detect_dhcpd_work.bak" ]; then mv /tmp/detect_dhcpd_work.bak /tmp/detect_dhcpd_work;fi +check:output =~ Server:__GETTABLEVALUE(key,master,value,site)__ assign IP .+__GETNODEATTR($$CN,ip)__ +cmd:rm -rf /tmp/detect_dhcpd_work; if [ -d "/tmp/detect_dhcpd_work.bak" ]; then mv /tmp/detect_dhcpd_work.bak /tmp/detect_dhcpd_work;fi end From 68cc0c3d65c6553bd97a8153832b002733fa6851 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 May 2018 02:30:02 -0400 Subject: [PATCH 3/3] modify incorrect sentence --- xCAT-test/autotest/testcase/probe/detect_dhcpd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/probe/detect_dhcpd b/xCAT-test/autotest/testcase/probe/detect_dhcpd index b3eccc0fd..f88141463 100644 --- a/xCAT-test/autotest/testcase/probe/detect_dhcpd +++ b/xCAT-test/autotest/testcase/probe/detect_dhcpd @@ -19,7 +19,7 @@ elif [ -e "/etc/SuSE-release" ]; then elif [ -e "/etc/lsb-release" ]; then dpkg -l|grep tcpdump if [ "$?" != "0" ] ;then - apt-get install -y + apt-get install -y tcpdump fi fi cmd:echo "$$CN" |tee /tmp/detect_dhcpd_work/cn