From 0691b8a5bbdb30658033960faeec9885e8d55ff7 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 18 Jul 2016 06:38:05 -0400 Subject: [PATCH] modify pkg testcase according to comments --- xCAT-test/autotest/testcase/pkg/cases0 | 48 ++++++++++------ xCAT-test/autotest/testcase/pkg/pkgtest.pl | 66 ++++++++++++++-------- 2 files changed, 73 insertions(+), 41 deletions(-) diff --git a/xCAT-test/autotest/testcase/pkg/cases0 b/xCAT-test/autotest/testcase/pkg/cases0 index c38a9fa81..47f81c176 100644 --- a/xCAT-test/autotest/testcase/pkg/cases0 +++ b/xCAT-test/autotest/testcase/pkg/cases0 @@ -1,35 +1,40 @@ start:del_ospkg descreption:del ospkg -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:copycds $$ISO check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ cmd:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm" |grep "package manager for RPM";else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc!=0 cmd:copycds $$ISO check:rc==0 end + start:add_ospkg_updatenode descreption:add ospkg -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM";else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r rpm; else xdsh $$CN rpm -e xCAT-test; fi check:rc==0 @@ -38,15 +43,18 @@ check:rc!=0 cmd:copycds $$ISO check:rc==0 end + start:add_includeospkg_updatenode descreption:add include ospkg list -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -g $$osimage -t pkglist -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r rpm; else xdsh $$CN rpm -e xCAT-test; fi check:rc==0 @@ -55,14 +63,17 @@ check:rc!=0 cmd:copycds $$ISO check:rc==0 end + start:add_other_pkg descreption:add other pkg -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r xcat-test; else xdsh $$CN rpm -e xCAT-test; fi check:rc==0 @@ -74,7 +85,9 @@ end start:del_other_pkg descreption:del other pkg -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 @@ -82,30 +95,33 @@ cmd:sleep 10 check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:copycds $$ISO check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc!=0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:copycds $$ISO check:rc==0 end + start:add_other_pkg_include descreption:add other pkg include other list -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:copycds $$ISO +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:updatenode $$CN -S check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o -g $$osimage -t otherpkgdir -v __GETNODEATTR($$CN,os)__ check:rc==0 cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r xcat-test; else xdsh $$CN rpm -e xCAT-test; fi check:rc==0 diff --git a/xCAT-test/autotest/testcase/pkg/pkgtest.pl b/xCAT-test/autotest/testcase/pkg/pkgtest.pl index bd91ff631..b1f9ca2e4 100755 --- a/xCAT-test/autotest/testcase/pkg/pkgtest.pl +++ b/xCAT-test/autotest/testcase/pkg/pkgtest.pl @@ -4,7 +4,7 @@ use strict; use warnings; use Getopt::Long; -use Data::Dumper; +use Data::Dumper; use Term::ANSIColor; use Time::Local; BEGIN @@ -20,6 +20,8 @@ my $clearenv = 0; my $setupenvinclude = 0; my $removerpm = 0; my $ospkg = 0; +my $osimg; +my $attr; my $int; if ( !GetOptions("h|?" => \$needhelp, @@ -27,7 +29,10 @@ if ( "c"=>\$clearenv, "i"=>\$setupenvinclude, "r"=>\$removerpm, - "o"=>\$ospkg) + "o"=>\$ospkg, + "g=s"=>\$::OSIMG, + "t=s"=>\$::ATTR, + "v=s"=>\$::OSVERSION) ) { &usage; @@ -36,20 +41,20 @@ if ( sub usage { - print "Usage:pkg - Run xcat pkg test cases.\n"; - print " pkg [-?|-h]\n"; - print " pkgtest [-s] [osimage] [attribute] [os] set up package test environment \n"; - print " pkgtest [-i] [osimage] [attribute] [os] set up package test environment using include package list\n"; - print " pkgtest [-r] [osimage] [attribute] [os] remove package \n"; - print " pkgtest [-c] [osimage] [attribute] [os] clear package test environment \n"; - print " pkgtest [-o] [osimage] [attribute] [os] other package test \n"; + print "Usage:pkgtest.pl - Run xcat pkg test cases.\n"; + print " pkgtest.pl [-?|-h]\n"; + print " pkgtest.pl [-s] [-g osimage] [-t attribute] [-v os] set up package test environment \n"; + print " pkgtest.pl [-i] [-g osimage] [-t attribute] [-v os] set up package test environment using include package list\n"; + print " pkgtest.pl [-r] [-g osimage] [-t attribute] [-v os] remove package \n"; + print " pkgtest.pl [-c] [-g osimage] [-t attribute] [-v os] clear package test environment \n"; + print " pkgtest.pl [-o] [-g osimage] [-t attribute] [-v os] other package test \n"; print "\n"; return; } sub getimgattr { - my @output = `lsdef -t osimage -o $ARGV[0] -i $ARGV[1]`; + my @output = `lsdef -t osimage -o $osimg -i $attr`; my $pkglistvalue; print " output is @output \n"; if($?){ @@ -58,8 +63,8 @@ sub getimgattr } if($? == 0){ foreach my $output1 (@output){ - if($output1 =~ /$ARGV[1]=(.*)/){ - print "output1 is $output1 ,attrs is $ARGV[1] value is $1 \n"; + if($output1 =~ /$attr=(.*)/){ + print "output1 is $output1 ,attrs is value is $1 \n"; $pkglistvalue = $1 ; } } } @@ -75,7 +80,7 @@ sub setupenv }else{ `cat "$int" >> /tmp/pkgtest.bak`; } - if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){ + if (($osver =~ /ubuntu/)&&($ospkg ==0)){ `echo "rpm" >>/tmp/pkgtest.bak `; }else{ `echo "xCAT-test" >>/tmp/pkgtest.bak `; @@ -102,7 +107,7 @@ sub setupenvinclude }else{ ` cat $int >> /tmp/pkgtest.bak`; } - if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){ + if (($osver =~ /ubuntu/)&&($ospkg ==0)){ `echo "rpm" >>/tmp/pkgtest.bak `; }else{ `echo "xCAT-test" >> /tmp/pkgtest.includelist `; @@ -118,9 +123,9 @@ sub removerpm }else{ `cat "$int" >> /tmp/pkgtest.bak`; } - if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){ + if (($osver =~ /ubuntu/)&&($ospkg ==0)){ `echo "-rpm" >>/tmp/pkgtest.bak `; - }elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg !=0)){ + }elsif(($osver =~ /ubuntu/)&&($ospkg !=0)){ `echo "-xcat-test">>/tmp/pkgtest.bak`; }else{ `echo "-xCAT-test" >>/tmp/pkgtest.bak`; @@ -132,7 +137,18 @@ if ($needhelp) &usage; exit 0; } - +if($::OSIMG) +{ + $osimg = $::OSIMG; +} +if($::ATTR) +{ + $attr = $::ATTR; +} +if($::OSVERSION) +{ + $osver = $::OSVERSION; +} $int = getimgattr; if ( ($setupenv) || ($setupenvinclude) ||($removerpm)) { @@ -171,14 +187,14 @@ if (($setupenv) || ($setupenvinclude) ||($removerpm)) { `mkdir -p /install/pkgtest`; `cp -rf /xcat-core/* /install/pkgtest`; - if (($ARGV[2] !~ /ubuntu/)&&($ospkg ==0)){ - `chdef -t osimage -o $ARGV[0] pkgdir=/install/pkgtest pkglist=/tmp/pkgtest.bak `; - }elsif (($ARGV[2] !~ /ubuntu/)&&($ospkg !=0)){ - `chdef -t osimage -o $ARGV[0] otherpkglist=/tmp/pkgtest.bak`; - }elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg !=0)){ - `chdef -t osimage -o $ARGV[0] otherpkglist="/tmp/pkgtest.bak" otherpkgdir="http://xcat.org/files/xcat/repos/apt/2.12/xcat-core trusty main"`; - }elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){ - `chdef -t osimage -o $ARGV[0] pkglist=/tmp/pkgtest.bak`; + if (($osver !~ /ubuntu/)&&($ospkg ==0)){ + `chdef -t osimage -o $osimg pkgdir=/install/pkgtest pkglist=/tmp/pkgtest.bak `; + }elsif (($osver !~ /ubuntu/)&&($ospkg !=0)){ + `chdef -t osimage -o $osimg otherpkglist=/tmp/pkgtest.bak`; + }elsif(($osver =~ /ubuntu/)&&($ospkg !=0)){ + `chdef -t osimage -o $osimg otherpkglist="/tmp/pkgtest.bak" otherpkgdir="http://xcat.org/files/xcat/repos/apt/2.12/xcat-core trusty main"`; + }elsif(($osver =~ /ubuntu/)&&($ospkg ==0)){ + `chdef -t osimage -o $osimg pkglist=/tmp/pkgtest.bak`; } } if ($?)