From 30997ee330487ca4e39fdcc80d902dbf2972673a Mon Sep 17 00:00:00 2001 From: huweihua Date: Fri, 20 Jul 2018 02:21:18 -0400 Subject: [PATCH 1/3] using label to enhance CI test --- travis.pl | 38 +++++- xCAT-test/autotest/testcase/makedhcp/cases0 | 22 ++-- xCAT-test/autotest/testcase/makedns/cases0 | 30 +++-- xCAT-test/autotest/testcase/makehosts/cases0 | 118 +++++++++++++++--- xCAT-test/autotest/testcase/mkdef/cases0 | 8 +- xCAT-test/autotest/testcase/xcatconfig/case0 | 28 +++-- xCAT-test/autotest/testcase/xcatd/case0 | 3 +- .../autotest/testcase/xcatstanzafile/cases0 | 82 ++++++++++-- 8 files changed, 264 insertions(+), 65 deletions(-) diff --git a/travis.pl b/travis.pl index 7dc5ea8de..5fe6f31af 100644 --- a/travis.pl +++ b/travis.pl @@ -459,7 +459,7 @@ sub run_fast_regression_test{ print Dumper \@output; } - $cmd = "sudo bash -c '. /etc/profile.d/xcat.sh && xcattest -l bundleinfo'"; + $cmd = "sudo bash -c '. /etc/profile.d/xcat.sh && xcattest -h'"; @output = runcmd("$cmd"); if($::RUNCMD_RC){ print RED "[run_fast_regression_test] $cmd ....[Failed]\n"; @@ -488,9 +488,25 @@ sub run_fast_regression_test{ @output = runcmd("cat $conf_file"); print Dumper \@output; - my @caseslist = runcmd("sudo bash -c '. /etc/profile.d/xcat.sh && xcattest -l caselist -b MN_basic.bundle'"); + + $cmd = "sudo bash -c '. /etc/profile.d/xcat.sh && xcattest -s \"mn_only-wait_fix\" -l'"; + @output = runcmd("$cmd"); + if($::RUNCMD_RC){ + print RED "[run_fast_regression_test] $cmd ....[Failed]\n"; + print "[run_fast_regression_test] error dumper:\n"; + print Dumper \@output; + return 1; + }else{ + print "[run_fast_regression_test] $cmd .....:\n"; + print Dumper \@output; + } + + my @caseslist = @output; + + #my @filter_cases=("testtest"); + #array_filter(\@caseslist, \@filter_cases); + my $casenum = @caseslist; - my $x = 0; my @failcase; my $passnum = 0; @@ -542,6 +558,22 @@ sub mark_time{ print "[mark_time] $nowtime_str, ElapsedTime of $func_name is $duration s\n"; } + +sub array_filter { + my $src_array_ref = shift; + my $filter_array_ref = shift; + + my @left_array; + foreach my $item (@{$src_array_ref}) { + my $hit = 0; + foreach my $f (@{$filter_array_ref}) { + $hit = 1 if ($f eq $item); + } + push @left_array, $item unless ($hit); + } + @$src_array_ref = @left_array; +} + #===============Main Process============================= #Dumper Travis Environment Attribute diff --git a/xCAT-test/autotest/testcase/makedhcp/cases0 b/xCAT-test/autotest/testcase/makedhcp/cases0 index c522ef2a3..5997fef11 100644 --- a/xCAT-test/autotest/testcase/makedhcp/cases0 +++ b/xCAT-test/autotest/testcase/makedhcp/cases0 @@ -52,13 +52,13 @@ os:Linux label:mn_only,dhcp cmd:mkdef -t node -o testnode1 groups=compute mac=11:22:33:55:66:88 arch=ppc64 cmd:chdef -t node -o testnode1 netboot=yaboot tftpserver=192.16.10.0 nfsserver=192.16.10.0 monserver=192.16.10.0 xcatmaster=192.16.10.0 installnic="mac" primarynic="mac" -cmd:lsdef -l testnode1 -z > /tmp/CN.stanza +cmd:lsdef -l testnode1 -z | tee /tmp/CN.stanza cmd:chdef -t node -o testnode1 mac=11:22:33:44:55:66 cmd:if [ -f "/etc/dhcp/dhcpd.conf" ];then mv -f /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak ; elif [ -f "/etc/dhcpd.conf" ]; then mv -f /etc/dhcpd.conf /etc/dhcpd.conf.bak; fi cmd:makedhcp -n cmd:makedhcp -a check:rc==0 -cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases; fi +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases; elif [ -f "/var/lib/dhcp/dhcpd.leases" ]; then cat /var/lib/dhcp/dhcpd.leases; fi check:output=~testnode1 check:output=~11:22:33:44:55:66 cmd:cat /tmp/CN.stanza | chdef -z @@ -76,10 +76,10 @@ cmd:if [ -f "/etc/dhcp/dhcpd.conf" ];then mv -f /etc/dhcp/dhcpd.conf /etc/dhcp/d cmd:makedhcp -n cmd:makedhcp -a check:rc==0 -cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/1; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/1; fi +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/1; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/1;elif [ -f /var/lib/dhcp/dhcpd.leases ]; then cat /var/lib/dhcp/dhcpd.leases > /tmp/1; fi cmd:makedhcp -a -d check:rc==0 -cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/2; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/2; fi +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/2; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/2;elif [ -f /var/lib/dhcp/dhcpd.leases ]; then cat /var/lib/dhcp/dhcpd.leases > /tmp/2; fi cmd:diff /tmp/1 /tmp/2 check:output=~testnode1 check:output=~deleted @@ -101,10 +101,10 @@ cmd:lsdef -l testnode1 -z > /tmp/CN.stanza cmd:chdef -t node -o testnode1 mac=11:22:33:44:55:66 cmd:makedhcp -n cmd:makedhcp testnode1 -cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/1; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/1; fi +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/1; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/1;elif [ -f /var/lib/dhcp/dhcpd.leases ]; then cat /var/lib/dhcp/dhcpd.leases > /tmp/1; fi cmd:makedhcp -d testnode1 check:rc==0 -cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/2; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/2; fi +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then cat /var/lib/dhcpd/dhcpd.leases > /tmp/2; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then cat /var/lib/dhcp/db/dhcpd.leases > /tmp/2;elif [ -f /var/lib/dhcp/dhcpd.leases ]; then cat /var/lib/dhcp/dhcpd.leases > /tmp/2; fi cmd:diff /tmp/1 /tmp/2 check:output=~testnode1 check:output=~deleted @@ -186,15 +186,19 @@ check:rc==0 cmd:lsdef -t network check:rc==0 check:output=~testnetwork -check:rc==0 cmd:mkdef -t node -o testnode ip=100.100.100.2 groups=all mac=42:3d:0a:05:27:0b check:rc==0 -cmd: cp -f /etc/hosts /etc/hosts.bak -cmd:echo "100.100.100.2 testnode" >> /etc/hosts +cmd:cat /etc/hosts +cmd:echo -e "\n100.100.100.2 testnode" >> /etc/hosts +check:rc==0 +cmd:cat /etc/hosts +cmd:makedhcp -n check:rc==0 cmd:makedhcp -d testnode +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then a="/var/lib/dhcpd/dhcpd.leases"; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then a="/var/lib/dhcp/db/dhcpd.leases"; elif [ -f "/var/lib/dhcp/dhcpd.leases" ]; then a="/var/lib/dhcp/dhcpd.leases";fi; ls -l $a; cat $a cmd:makedhcp testnode check:rc==0 +cmd:if [ -f /var/lib/dhcpd/dhcpd.leases ]; then a="/var/lib/dhcpd/dhcpd.leases"; elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then a="/var/lib/dhcp/db/dhcpd.leases"; elif [ -f "/var/lib/dhcp/dhcpd.leases" ]; then a="/var/lib/dhcp/dhcpd.leases";fi; ls -l $a; cat $a cmd:makedhcp -q testnode check:rc==0 check:output=~testnode: ip-address = 100.100.100.2 diff --git a/xCAT-test/autotest/testcase/makedns/cases0 b/xCAT-test/autotest/testcase/makedns/cases0 index bc4f6aa96..ecaf0bf85 100644 --- a/xCAT-test/autotest/testcase/makedns/cases0 +++ b/xCAT-test/autotest/testcase/makedns/cases0 @@ -10,11 +10,16 @@ end start:makedns_d_node description:makedns -d noderange -label:mn_only,dns +label:mn_only,dns,wait_fix cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.255.0 networks.mgtifname=eth0 networks.gateway=100.100.100.254 check:rc==0 cmd:chdef -t node -o dnstestnode groups=all ip=100.100.100.1 check:rc==0 +cmd:hostname +cmd:cat /etc/hosts +cmd:ip a +cmd:lsdef -l +cmd:tabdump networks cmd:makedns -n check:rc==0 cmd:makedns dnstestnode @@ -37,13 +42,17 @@ end start:makedns_node description:makedns noderange -label:mn_only,dns +label:mn_only,dns,wait_fix cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.255.0 networks.mgtifname=eth0 networks.gateway=100.100.100.254 check:rc==0 cmd:chdef -t node -o dnstestnode groups=all ip=100.100.100.1 check:rc==0 +cmd:lsdef -l dnstestnode +cmd:cat /etc/hosts cmd:makedns -n check:rc==0 +cmd:cat /etc/hosts +cmd:ps aux|grep name cmd:makedns dnstestnode check:rc==0 cmd:nslookup dnstestnode $$MN @@ -137,12 +146,12 @@ cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.2 check:rc==0 cmd:makedns -n check:rc==0 -cmd:cat /etc/named.conf +cmd:if [ -f "/etc/named.conf" ]; then a="/etc/named.conf"; elif [ -f "/etc/bind/named.conf" ]; then a="/etc/bind/named.conf";fi; cat $a check:rc==0 check:output~=zone "100.100.100.IN-ADDR.ARPA." cmd:rm -f /tmp/makedns_named_conf.org /tmp/makedns_named_conf.new check:rc==0 -cmd:cat /etc/named.conf > /tmp/makedns_named_conf.org +cmd:if [ -f "/etc/named.conf" ]; then a="/etc/named.conf"; elif [ -f "/etc/bind/named.conf" ]; then a="/etc/bind/named.conf";fi; cat $a >/tmp/makedns_named_conf.org check:rc==0 cmd:cp /etc/hosts /etc/hosts.testbak check:rc==0 @@ -153,9 +162,9 @@ check:rc==0 cmd:nslookup dnstestnode $$MN check:output~=Server: $$MN check:output!~(server can't find dnstestnode) -cmd:cat /etc/named.conf > /tmp/makedns_named_conf.old +cmd:if [ -f "/etc/named.conf" ]; then a="/etc/named.conf"; elif [ -f "/etc/bind/named.conf" ]; then a="/etc/bind/named.conf";fi; cat $a > /tmp/makedns_named_conf.new check:rc==0 -cmd:diff /tmp/makedns_named_conf.org /tmp/makedns_named_conf.old +cmd:diff /tmp/makedns_named_conf.org /tmp/makedns_named_conf.new check:rc==0 check:output~= cmd:rm -f /tmp/makedns_named_conf.org /tmp/makedns_named_conf.new @@ -168,7 +177,7 @@ cmd:chtab -d netname=testnetwork networks check:rc==0 cmd:makedns -n check:rc==0 -cmd:cat /etc/named.conf +cmd:if [ -f "/etc/named.conf" ]; then a="/etc/named.conf"; elif [ -f "/etc/bind/named.conf" ]; then a="/etc/bind/named.conf";fi; cat $a check:rc==0 check:output!~zone "100.100.100.IN-ADDR.ARPA." cmd:nslookup dnstestnode $$MN @@ -834,7 +843,7 @@ end start:makedns_n_noderange description:to verify makedns -n noderange works as design. add case for bug #2572. Test case bug number is #2826. -label:mn_only,dns +label:mn_only,dns,wait_fix cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.255.0 networks.mgtifname=eth0 networks.gateway=100.100.100.254 check:rc==0 cmd:chdef -t node -o dnstestnode[1-10] groups=dnsnode ip="|dnstestnode(\d+)|100.100.100.(\$1+0)|" @@ -843,6 +852,11 @@ cmd:cp -f /etc/hosts /etc/hosts.testbak check:rc==0 cmd:for i in {1..10}; do echo "100.100.100.$i dnstestnode$i" >> /etc/hosts; done check:rc==0 +cmd:hostname +cmd:cat /etc/hosts +cmd:ip a +cmd:lsdef -l +cmd:tabdump networks cmd:makedns -n dnstestnode[1-10] check:rc==0 cmd:nslookup dnstestnode5 $$MN diff --git a/xCAT-test/autotest/testcase/makehosts/cases0 b/xCAT-test/autotest/testcase/makehosts/cases0 index 077fd4db9..98b505981 100644 --- a/xCAT-test/autotest/testcase/makehosts/cases0 +++ b/xCAT-test/autotest/testcase/makehosts/cases0 @@ -38,42 +38,47 @@ cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts end start:makehosts_l -label:mn_only,dns +label:mn_only,dns,wait_fix cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest +cmd:cat /etc/hosts cmd:chtab node=nouse_compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|" check:rc==0 cmd:chdef -t node -o node01,node02 groups="nouse_compute" check:rc==0 cmd:sleep 30 +cmd:lsdef -l nouse_compute cmd:XCATBYPASS=1 makehosts -l check:rc==0 cmd:sleep 30 -cmd:cp -f /etc/hosts /tmp/hosts -cmd:cat /tmp/hosts|awk '{print $2}' +cmd:cat /etc/hosts +cmd:cat /etc/hosts |awk '{print $2}' check:output=~node01.cluster.net check:output=~node02.cluster.net -cmd:chtab -d node=nouse_compute hosts cmd:rmdef node01 cmd:rmdef node02 +cmd:chtab -d node=nouse_compute hosts cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts -cmd:rm -rf /tmp/hosts end start:makehosts_d -label:mn_only,dns +label:mn_only,dns,wait_fix cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|" check:rc==0 cmd:chdef -t node -o node01 groups="compute" check:rc==0 +cmd:lsdef -l node01 cmd:sleep 30 +cmd:cat /etc/hosts cmd:makehosts node01 check:rc==0 -cmd:cat /etc/hosts > /tmp/1 cmd:sleep 30 +cmd:cat /etc/hosts |tee /tmp/1 +cmd:grep "node01" /etc/hosts +check:rc==0 cmd:XCATBYPASS=1 makehosts -d node01 check:rc==0 -cmd:cat /etc/hosts > /tmp/2 +cmd:cat /etc/hosts |tee /tmp/2 cmd:diff /tmp/1 /tmp/2 check:output=~node01.cluster.net cmd:chtab -d node=compute hosts @@ -133,46 +138,117 @@ cmd:rm -rf /tmp/hosts end start:makehost_n_r -label:mn_only,dns +label:mn_only,dns,wait_fix descriptions:modify makehosts testcases according to special node name eg:s01 and s01r* . for issue #2717 and #2683 cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest +cmd:cat /etc/hosts cmd:lsdef s01;if [ $? -eq 0 ]; then lsdef -l s01 -z >/tmp/s01.standa ;rmdef s01;fi check:rc==0 cmd:lsdef s01r1b01;if [ $? -eq 0 ]; then lsdef -l s01r1b01 -z >/tmp/s01r1b01.standa ;rmdef s01r1b01;fi check:rc==0 -cmd:nodeadd s01 groups=service; chdef s01 ip=70.2.0.254;nodeadd s01r1b01 groups=compute; chdef s01r1b01 ip=80.2.0.254;makehosts +cmd:nodeadd s01 groups=service; chdef s01 ip=70.2.0.254;nodeadd s01r1b01 groups=compute; chdef s01r1b01 ip=80.2.0.254 check:rc==0 -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done +cmd:lsdef -l s01,s01r1b01 +cmd:makehosts check:rc==0 +cmd:cat /etc/hosts +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (grep "70.2.0.254 s01" $file >/dev/null 2>&1) && (grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "Do not find s01 and s01r1b01 in $file, sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 +check:rc==0 +cmd:cp -f /etc/hosts.xcatbakautotest /etc/hosts cmd:makehosts s01 check:rc==0 cmd:cat /etc/hosts -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (grep "70.2.0.254 s01" $file >/dev/null 2>&1) && ( ! grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 check:rc==0 +cmd:cp -f /etc/hosts.xcatbakautotest /etc/hosts cmd:makehosts service check:rc==0 -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done -check:rc==0 cmd:cat /etc/hosts +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (grep "70.2.0.254 s01" $file >/dev/null 2>&1) && (! grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 +check:rc==0 cmd:makehosts -d s01 check:rc==0 -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if !([[ $rc =~ "70.2.0.254 s01" ]]) && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done -check:rc==0 cmd:cat /etc/hosts +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (! grep "70.2.0.254 s01" $file >/dev/null 2>&1) && (! grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 +check:rc==0 +cmd:cp -f /etc/hosts.xcatbakautotest /etc/hosts cmd:makehosts check:rc==0 +cmd:cat /etc/hosts cmd:makehosts -d service check:rc==0 -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if !([[ $rc =~ "70.2.0.254 s01" ]]) && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done -check:rc==0 cmd:cat /etc/hosts +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (! grep "70.2.0.254 s01" $file >/dev/null 2>&1) && (grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 +check:rc==0 +cmd:cp -f /etc/hosts.xcatbakautotest /etc/hosts cmd:makehosts check:rc==0 +cmd:cat /etc/hosts cmd:makehosts -d s01r1b01 check:rc==0 -cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && !([[ $rc =~ "80.2.0.254 s01r1b01" ]]);then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done -check:rc==0 cmd:cat /etc/hosts +cmd:#!/bin/bash +file="/etc/hosts" +for i in {1..5}; do + if (grep "70.2.0.254 s01" $file >/dev/null 2>&1) && (! grep "80.2.0.254 s01r1b01" $file >/dev/null 2>&1); then + exit 0; + else + echo "sleep $[i*2] seconds and try again" + sleep $[i*2] + fi +done +exit 1 +check:rc==0 cmd:if [ -e /tmp/s01.standa ]; then rmdef s01; cat /tmp/s01.standa | mkdef -z; rm -rf /tmp/s01.standa; else rmdef s01;fi check:rc==0 cmd:if [ -e /tmp/s01r1b01.standa ]; then rmdef s01r1b01; cat /tmp/s01r1b01.standa | mkdef -z; rm -rf /tmp/s01r1b01.standa;else rmdef s01r1b01; fi @@ -188,6 +264,7 @@ cmd:if lsdef -z sn4b;then lsdef -z sn4b|tee /tmp/sn4bdef;noderm sn4b;fi cmd:if lsdef -t group -z regextest;then lsdef -t group -z regextest |tee /tmp/regextestdef;rmdef -t group -o regextest;fi cmd:if grep sn4b /etc/hosts;then sed -i '/sn4b/d' /etc/hosts;fi check:rc==0 +cmd:cat /etc/hosts cmd:mkdef -t node sn4b groups=compute check:rc==0 cmd:mkdef -t group regextest ip="|\D+(\d+)\D+|20.80.1.($1*2+103)|" members=sn4b nichostnamesuffixes.eth0=-eth0 nicips.eth0="|\D+(\d+)\D+|10.80.1.($1*2+103)|" nicnetworks.eth0=10_0_0_0-255_0_0_0 @@ -196,6 +273,7 @@ cmd:lsdef -t group regextest check:rc==0 cmd:makehosts sn4b check:rc==0 +cmd:cat /etc/hosts cmd:sn4bip=`lsdef sn4b |grep -w ip|awk -F= '{print $2}'`;grep $sn4bip /etc/hosts check:rc==0 cmd:sn4beth0ip=`lsdef sn4b |grep -w nicips.eth0|awk -F= '{print $2}'`;grep $sn4beth0ip /etc/hosts diff --git a/xCAT-test/autotest/testcase/mkdef/cases0 b/xCAT-test/autotest/testcase/mkdef/cases0 index 6ed8a06b7..cffe8c2a9 100644 --- a/xCAT-test/autotest/testcase/mkdef/cases0 +++ b/xCAT-test/autotest/testcase/mkdef/cases0 @@ -264,13 +264,13 @@ label:mn_only,db cmd:result=`lsdef | grep auto_test_cec_node_1`; if [[ $result =~ "auto_test_cec_node_1" ]]; then echo $result; noderm auto_test_cec_node_1; fi cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template check:rc==1 -check:output=~Error\: (\[.*?\]: )?The attribute \"serial\" must be specified! +check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified! cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test check:rc==1 -check:output=~Error\: (\[.*?\]: )?The attribute \"mtm\" must be specified! -cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test mtm=test +check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified! +cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test hcp=test check:rc==1 -check:output=~Error\: (\[.*?\]: )?The attribute \"hcp\" must be specified! +check:output=~Error\: (\[.*?\]: )?The attribute \".+\" must be specified! cmd:mkdef -t node -o auto_test_cec_node_1 --template cec-template serial=test mtm=test hcp=test check:rc==0 check:output=~1 object definitions have been created or modified diff --git a/xCAT-test/autotest/testcase/xcatconfig/case0 b/xCAT-test/autotest/testcase/xcatconfig/case0 index 275e720c4..e37688b43 100644 --- a/xCAT-test/autotest/testcase/xcatconfig/case0 +++ b/xCAT-test/autotest/testcase/xcatconfig/case0 @@ -1,5 +1,5 @@ start:testtest -label:mn_only,db +label:mn_only,db,wait_fix cmd:/opt/xcat/share/xcat/tools/autotest/testcase/xcatconfig/change_site_table_values check:rc==0 end @@ -69,9 +69,13 @@ check:rc==0 #step2:run command and check the output cmd:xcatconfig -k -c >/tmp/xcatconfig.test 2>&1 check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep FAILED` ]] || [[ `cat /tmp/xcatconfig.test |grep error` ]] || [[ `cat /tmp/xcatconfig.test |grep "fail"` ]] || [[ `cat /tmp/xcatconfig.test |grep Error` ]];then exit 1;fi +cmd:grep -Ei "error|fail" /tmp/xcatconfig.test +check:rc!=0 +cmd:grep "Generated /root/.ssh/id_rsa.pub" /tmp/xcatconfig.test check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep "Generated /root/.ssh/id_rsa.pub"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Created xCAT certificate"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Signature ok"` ]];then exit 0;else exit 1;fi +cmd:grep "Created xCAT certificate" /tmp/xcatconfig.test +check:rc==0 +cmd:grep "Signature ok" /tmp/xcatconfig.test check:rc==0 #step3:To make sure /root/.ssh/id_rsa.pub is regenerated cmd:diff /root/.ssh/id_rsa.pub /root/sshbak/id_rsa.pub @@ -99,9 +103,11 @@ cmd:cp -r /etc/xcat/ca /etc/xcat/cabak;cp -r /etc/xcat/cert /etc/xcat/certbak #step2:run command and check the output cmd:xcatconfig -c 2>&1 | tee /tmp/xcatconfig.test check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep -i fail` ]] || [[ `cat /tmp/xcatconfig.test |grep -i error` ]] ;then exit 1;else exit 0;fi +cmd:grep -iE "fail|error" /tmp/xcatconfig.test +check:rc!=0 +cmd:grep "Created xCAT certificate" /tmp/xcatconfig.test check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep "Created xCAT certificate"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Signature ok"` ]];then exit 0;else exit 1;fi +cmd:grep "Signature ok" /tmp/xcatconfig.test check:rc==0 #step3:make sure the /etc/xcat/ca /etc/xcat/cert is rewrite cmd:diff -y /etc/xcat/ca /etc/xcat/cabak @@ -154,11 +160,17 @@ check:rc==0 cmd:cp -rf /install/postscripts/hostkeys /install/postscripts/hostkeysbak check:rc==0 #step2:run command and check messages -cmd:xcatconfig -s -c >/tmp/xcatconfig.test 2>&1 +cmd:xcatconfig -s -c 2>&1 |tee /tmp/xcatconfig.test check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep FAILED` ]] || [[ `cat /tmp/xcatconfig.test |grep error` ]] || [[ `cat /tmp/xcatconfig.test |grep "fail"` ]] || [[ `cat /tmp/xcatconfig.test |grep Error` ]];then exit 1;fi +cmd:grep -iE "fail|error" /tmp/xcatconfig.test +check:rc!=0 +cmd:grep "Created xCAT certificate" /tmp/xcatconfig.test check:rc==0 -cmd:if [[ `cat /tmp/xcatconfig.test |grep "Created xCAT certificate"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Generating new node hostkeys"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Signature ok"` ]] && [[ `cat /tmp/xcatconfig.test |grep "Generating SSH2 RSA Key"` ]];then exit 0;else exit 1;fi +cmd:grep "Generating new node hostkeys" /tmp/xcatconfig.test +check:rc==0 +cmd:grep "Signature ok" /tmp/xcatconfig.test +check:rc==0 +cmd:grep "Generating SSH2 RSA Key" /tmp/xcatconfig.test check:rc==0 #step3:Make sure /etc/xcat/hostkeys/ssh_host_rsa_key.pub is regenerated cmd:diff /etc/xcat/hostkeys/ssh_host_rsa_key.pub /etc/xcat/hostkeysbak/ssh_host_rsa_key.pub diff --git a/xCAT-test/autotest/testcase/xcatd/case0 b/xCAT-test/autotest/testcase/xcatd/case0 index 8876f1f1b..0e3f59be2 100644 --- a/xCAT-test/autotest/testcase/xcatd/case0 +++ b/xCAT-test/autotest/testcase/xcatd/case0 @@ -78,8 +78,9 @@ cmd:service xcatd status check:output=~xcatd service|xcatd.service check:output=~xcatd service is running|active \(running\) check:rc==0 -cmd:times=10; while [ $times -gt 0 ]; do service xcatd restart; if [ "$?" -ne "0" ]; then break; fi; ((times--)); done; if [ $times -gt 0 ]; then $?=1; fi +cmd:service xcatd restart check:rc==0 +cmd:sleep 10 cmd:service xcatd status check:output=~xcatd service|xcatd.service check:output=~xcatd service is running|active \(running\) diff --git a/xCAT-test/autotest/testcase/xcatstanzafile/cases0 b/xCAT-test/autotest/testcase/xcatstanzafile/cases0 index b671c668c..2a6c7167d 100644 --- a/xCAT-test/autotest/testcase/xcatstanzafile/cases0 +++ b/xCAT-test/autotest/testcase/xcatstanzafile/cases0 @@ -1,8 +1,14 @@ start:xcatstanzafile_normal description:xcatstanzafile in normal format label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster=MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmaster=MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 +cmd:cat testfile cmd:cat testfile|chdef -z check:rc==0 cmd:lsdef testnode @@ -17,7 +23,12 @@ end start:xcatstanzafile_colon description:xcatstanzafile's header without colon label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode\n objtype=node\n xcatmaster=MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode + objtype=node + xcatmaster=MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|chdef -z check:rc!=0 @@ -31,21 +42,36 @@ end start:xcatstanzafile_attribute description:xcatstanzafile with error attribute line label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmasterMS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmasterMS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|chdef -z cmd:lsdef testnode check:output!~xcatmaster=MS02.ppd.pok.com cmd:rmdef -t node testnode cmd:rm -f testfile -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster=\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmaster= + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|chdef -z cmd:lsdef testnode check:output!~xcatmaster= cmd:rmdef -t node testnode cmd:rm -f testfile -cmd:echo -e "default-node:\n groups=all,compute\ntestnode\n objtype=node\n =MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + =MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|chdef -z cmd:lsdef testnode @@ -57,7 +83,11 @@ end start:xcatstanzafile_objtype description:xcatstanzafile,a stanza without objtype definition label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n xcatmaster=MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + xcatmaster=MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|mkdef -z check:rc!=0 @@ -69,7 +99,12 @@ end #start:xcatstanzafile_comment #description:xcatstanzafile,a stanza without objtype definition #label:mn_only,db -#cmd:echo -ne "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster=MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +#cmd:echo 'default-node: +# groups=all,compute +#testnode: +# objtype=node +# xcatmaster= MS02.ppd.pok.com +# nfsserver=IS227.ppd.pok.com' > testfile #check:rc==0 #cmd:echo '#abc' >> testfile #cmd:cat testfile|mkdef -z @@ -82,7 +117,12 @@ end start:xcatstanzafile_tab description:xcatstanzafile,line with tab and space label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster = MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmaster = MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|mkdef -z check:rc==0 @@ -93,12 +133,18 @@ end start:xcatstanzafile_multattr description:xcatstanzafile,line with multiple attribute label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster= MS02.ppd.pok.com nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmaster= MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|mkdef -z check:rc==0 cmd:lsdef testnode -check:output=~\s*xcatmaster=MS02.ppd.pok.com\s*nfsserver=IS227.ppd.pok.com +check:output=~\s*xcatmaster=MS02.ppd.pok.com +check:output=~\s*nfsserver=IS227.ppd.pok.com cmd:rmdef -t node testnode cmd:rm -f testfile end @@ -107,8 +153,14 @@ end start:xcatstanzafile_defaultvalue description:xcatstanzafile,If the header name is ``default-:'' the attribute values in the stanza are considered default values for subsequent definitions in the file that are the same object type. label:mn_only,db -cmd:echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n xcatmaster= MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + xcatmaster= MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 +cmd:cat testfile cmd:cat testfile|mkdef -z check:rc==0 cmd:lsdef testnode @@ -120,7 +172,13 @@ end start:xcatstanzafile_specificvalue description:When a specific value for an attribute is provided in the stanza, it takes priority over any default value that had been set. label:mn_only,db -cmd:bash -c 'echo -e "default-node:\n groups=all,compute\ntestnode:\n objtype=node\n groups=all,rhels5.5\n xcatmaster= MS02.ppd.pok.com\n nfsserver=IS227.ppd.pok.com" > testfile' +cmd:echo 'default-node: + groups=all,compute +testnode: + objtype=node + groups=all,rhels5.5 + xcatmaster= MS02.ppd.pok.com + nfsserver=IS227.ppd.pok.com' > testfile check:rc==0 cmd:cat testfile|mkdef -z check:rc==0 From 57896422a4936231ffe0512c0ea0cadb78bc08a0 Mon Sep 17 00:00:00 2001 From: huweihua Date: Tue, 14 Aug 2018 05:24:40 -0400 Subject: [PATCH 2/3] add some comment in code --- travis.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis.pl b/travis.pl index 5fe6f31af..ba8b703d1 100644 --- a/travis.pl +++ b/travis.pl @@ -503,6 +503,9 @@ sub run_fast_regression_test{ my @caseslist = @output; + #This is a black list for CI test + #It is useful for debug or development + #please ignore during common work #my @filter_cases=("testtest"); #array_filter(\@caseslist, \@filter_cases); From 5871e21758f597dbf054b2ffa27263d0d14fff76 Mon Sep 17 00:00:00 2001 From: huweihua Date: Tue, 14 Aug 2018 05:36:54 -0400 Subject: [PATCH 3/3] comment debug info out --- travis.pl | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/travis.pl b/travis.pl index ba8b703d1..23e990e09 100644 --- a/travis.pl +++ b/travis.pl @@ -490,24 +490,39 @@ sub run_fast_regression_test{ $cmd = "sudo bash -c '. /etc/profile.d/xcat.sh && xcattest -s \"mn_only-wait_fix\" -l'"; - @output = runcmd("$cmd"); + my @caseslist = runcmd("$cmd"); if($::RUNCMD_RC){ print RED "[run_fast_regression_test] $cmd ....[Failed]\n"; print "[run_fast_regression_test] error dumper:\n"; - print Dumper \@output; + print Dumper \@caseslist; return 1; }else{ print "[run_fast_regression_test] $cmd .....:\n"; - print Dumper \@output; + print Dumper \@caseslist; } - my @caseslist = @output; - #This is a black list for CI test #It is useful for debug or development #please ignore during common work - #my @filter_cases=("testtest"); - #array_filter(\@caseslist, \@filter_cases); +# { +# sub array_filter { +# my $src_array_ref = shift; +# my $filter_array_ref = shift; +# +# my @left_array; +# foreach my $item (@{$src_array_ref}) { +# my $hit = 0; +# foreach my $f (@{$filter_array_ref}) { +# $hit = 1 if ($f eq $item); +# } +# push @left_array, $item unless ($hit); +# } +# @$src_array_ref = @left_array; +# } +# +# #my @filter_cases=("testtest"); +# #array_filter(\@caseslist, \@filter_cases); +# } my $casenum = @caseslist; my $x = 0; @@ -561,22 +576,6 @@ sub mark_time{ print "[mark_time] $nowtime_str, ElapsedTime of $func_name is $duration s\n"; } - -sub array_filter { - my $src_array_ref = shift; - my $filter_array_ref = shift; - - my @left_array; - foreach my $item (@{$src_array_ref}) { - my $hit = 0; - foreach my $f (@{$filter_array_ref}) { - $hit = 1 if ($f eq $item); - } - push @left_array, $item unless ($hit); - } - @$src_array_ref = @left_array; -} - #===============Main Process============================= #Dumper Travis Environment Attribute