mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-29 09:13:08 +00:00
update after review V1
This commit is contained in:
parent
07f6eba13e
commit
06109e8dff
@ -8,6 +8,8 @@ cmd:cp /core-*-snap.tar.bz2 /xcat-core.tar.bz2
|
||||
check:rc==0
|
||||
cmd:cp /xcat-dep*.tar.bz2 /xcat-dep.tar.bz2
|
||||
check:rc==0
|
||||
cmd:ls /go-xcat
|
||||
check:rc==0
|
||||
cmd:cd /; ./go-xcat --xcat-core=/xcat-core.tar.bz2 --xcat-dep=/xcat-dep.tar.bz2 -y install;
|
||||
check:rc==0
|
||||
cmd:source "/etc/profile.d/xcat.sh"
|
||||
@ -32,7 +34,9 @@ cmd:cp /core-*-snap.tar.bz2 /xcat-core.tar.bz2
|
||||
check:rc==0
|
||||
cmd:cp /xcat-dep*.tar.bz2 /xcat-dep.tar.bz2
|
||||
check:rc==0
|
||||
cmd:./go-xcat --xcat-core=/xcat-core.tar.bz2 --xcat-dep=/xcat-dep.tar.bz2 -y install;
|
||||
cmd:ls /go-xcat
|
||||
check:rc==0
|
||||
cmd:cd /; ./go-xcat --xcat-core=/xcat-core.tar.bz2 --xcat-dep=/xcat-dep.tar.bz2 -y install;
|
||||
check:rc==0
|
||||
cmd:source "/etc/profile.d/xcat.sh"
|
||||
check:rc==0
|
||||
|
@ -16,28 +16,33 @@ my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
|
||||
my $needhelp = 0;
|
||||
my $configinfo = undef;
|
||||
my $configfile = "$rootdir/default.conf";
|
||||
my $initallabel = undef;
|
||||
my $casedir = "$rootdir/testcase";
|
||||
my $bundledir = "$rootdir/bundle";
|
||||
my $resultdir = "$rootdir/result";
|
||||
my $bundlelist = undef;
|
||||
my $caselist = undef;
|
||||
my $cmdlist = undef;
|
||||
my $showbundlesorcommands = undef;
|
||||
my $needshow = 0;
|
||||
my $showbundlefiles = undef;
|
||||
my $showcommandslist= undef;
|
||||
my $restore = 0;
|
||||
my $ret = 0;
|
||||
my $string1 = undef;
|
||||
#below System label means: only load the [System] aspects in config file
|
||||
#this usage is only for the first install_xCAT cases used for xCAT daily regression
|
||||
#it is a workaround to avoid change the xcattest structure, so no need to public
|
||||
my $initallabel = undef;
|
||||
my $loadsysteminfo = "System";
|
||||
|
||||
my $resultdir = "$rootdir/result";
|
||||
my $showbundlefiles = 0;
|
||||
my $showcommandslist = 0;
|
||||
my $stop_to_keep_env = 0;
|
||||
|
||||
|
||||
#Create result directory
|
||||
mkdir $resultdir unless -d $resultdir;
|
||||
|
||||
# create a log
|
||||
# create a log for xcattest -h,-s,-l related
|
||||
my $timestamp = `date +"%Y%m%d%H%M%S"`;
|
||||
open(LOG, ">$resultdir/xcattest.log.$timestamp")
|
||||
open(LOG, ">$resultdir/command.logs.$timestamp")
|
||||
or die "Can't open logfile for writing: $!";
|
||||
|
||||
if (
|
||||
@ -46,9 +51,8 @@ if (
|
||||
"b=s" => \$bundlelist,
|
||||
"t=s" => \$caselist,
|
||||
"c=s" => \$cmdlist,
|
||||
"s=s" => \$showbundlesorcommands,
|
||||
"l" => \$needshow,
|
||||
"bl" => \$showbundlefiles,
|
||||
"cl" => \$showcommandslist,
|
||||
"restore" => \$restore)
|
||||
)
|
||||
{
|
||||
@ -69,12 +73,15 @@ if (&checkoptions)
|
||||
exit 1;
|
||||
}
|
||||
|
||||
#show bundle files under $bundledir with .bundle as file suffix
|
||||
my %bundlefilesinfo = ();
|
||||
if ($showbundlefiles)
|
||||
{
|
||||
&listbundlefiles;
|
||||
&undlefiles;
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
#show commands, which is the folder name $casedir, with case* files and test cases
|
||||
if ($showcommandslist)
|
||||
{
|
||||
&listcommands;
|
||||
@ -97,11 +104,19 @@ if ($needshow) {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
# create a log for run test cases
|
||||
$timestamp = `date +"%Y%m%d%H%M%S"`;
|
||||
open(LOG, ">$resultdir/xcattest.log.$timestamp")
|
||||
or die "Can't open logfile for writing: $!";
|
||||
&log_this("xCAT automated test started at " . scalar(localtime()));
|
||||
open(LOG_ERR, ">$resultdir/failedcases.$timestamp")
|
||||
or die "Can't open error logfile for writing: $!";
|
||||
|
||||
|
||||
#read config file
|
||||
log_this("******************************");
|
||||
log_this("Reading Configure");
|
||||
log_this("******************************");
|
||||
#config{object}{type}{name}{attr}
|
||||
#config{table}{name}{entry}{key}
|
||||
#config{script_prev}->[]
|
||||
@ -113,28 +128,42 @@ if ($ret != 0) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
#if not only load System aspects from config file, then init test enviroment
|
||||
if (!defined($initallabel)){
|
||||
log_this("******************************");
|
||||
log_this("Initialize xCAT test evironment");
|
||||
log_this("******************************");
|
||||
$ret = &init;
|
||||
if ($ret != 0) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
my @filespath = ();
|
||||
|
||||
my @filespath = ();
|
||||
#loading and check cases
|
||||
log_this("******************************");
|
||||
log_this("loading test cases");
|
||||
log_this("******************************");
|
||||
$ret = &loadcase;
|
||||
if ($ret != 0) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
#run case
|
||||
log_this("******************************");
|
||||
log_this("Start to run test cases");
|
||||
log_this("******************************");
|
||||
&reordercases if (defined($bundlelist) || defined($caselist));
|
||||
&runcase;
|
||||
|
||||
EXIT:
|
||||
log_this("******************************");
|
||||
log_this("un-initialize xCAT test evironment");
|
||||
log_this("******************************");
|
||||
if ($restore) {
|
||||
&uninit;
|
||||
}
|
||||
|
||||
&log_this("\nxCAT automated test finished at " . scalar(localtime()));
|
||||
&log_this("Please check results in the $resultdir, \nand see $resultdir/failedcases.$timestamp file for failed cases.\nsee $resultdir/performance.report.$timestamp file for time consumption");
|
||||
close(LOG);
|
||||
@ -175,10 +204,6 @@ sub log_error
|
||||
|
||||
sub getConfig
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("Reading Configure");
|
||||
log_this("******************************");
|
||||
|
||||
my $type = undef; #Script_Prev,Script_Post,Table,Object,System,Custom
|
||||
my $sub_type = undef; # The string after $type_
|
||||
# Script-->
|
||||
@ -343,9 +368,6 @@ sub init
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
log_this("******************************");
|
||||
log_this("Initialize xCAT test evironment");
|
||||
log_this("******************************");
|
||||
my $cmd = undef;
|
||||
foreach $cmd (@{ $config{script_prev} }) {
|
||||
log_this("$cmd");
|
||||
@ -427,9 +449,6 @@ sub init
|
||||
|
||||
sub uninit
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("un-initialize xCAT test evironment");
|
||||
log_this("******************************");
|
||||
my $cmd = undef;
|
||||
|
||||
# if(exists $config{object}){
|
||||
@ -503,10 +522,6 @@ sub Get_Files_Recursive
|
||||
|
||||
sub loadcase
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("loading test cases");
|
||||
log_this("******************************");
|
||||
my $casedir = "/opt/xcat/share/xcat/tools/autotest/testcase";
|
||||
my @files = ();
|
||||
|
||||
#if($cmdlist){
|
||||
@ -548,8 +563,8 @@ sub loadcase
|
||||
if ($bundlelist) {
|
||||
my @bundles = split /,/, $bundlelist;
|
||||
foreach my $bundle (@bundles) {
|
||||
if (!open(FILE, "<$rootdir/bundle/$bundle")) {
|
||||
log_this("can't open $rootdir/bundle/$bundle");
|
||||
if (!open(FILE, "<$bundledir/$bundle")) {
|
||||
log_this("can't open $bundledir/$bundle");
|
||||
return 1;
|
||||
}
|
||||
while ($line = <FILE>) {
|
||||
@ -697,12 +712,13 @@ sub loadcase
|
||||
foreach my $case (@cases) {
|
||||
log_this("$case->{name}");
|
||||
}
|
||||
}else{
|
||||
log_this("*To run:", @rightcase);
|
||||
log_this("*Not to run:", @notrightcase);
|
||||
log_this("*Case name not supported:", @wrongnamecase);
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_this("*Case name not supported, please use 'a-zA-Z0-9_-' :", @wrongnamecase);
|
||||
log_this("*To run:", @rightcase) if (@rightcase);
|
||||
log_this("*Not to run:", @notrightcase) if (@notrightcase);
|
||||
log_this("*Case name not supported:", @wrongnamecase) if (@wrongnamecase);
|
||||
return 0;
|
||||
}
|
||||
sub getnodeattr
|
||||
@ -797,9 +813,6 @@ sub getfunc
|
||||
|
||||
sub runcase
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("Start to run test cases");
|
||||
log_this("******************************");
|
||||
my @output = ();
|
||||
my $rc = 0;
|
||||
my $j = 0;
|
||||
@ -975,30 +988,22 @@ sub runcmd
|
||||
|
||||
sub usage
|
||||
{
|
||||
log_this("Usage:");
|
||||
log_this("Run xcat test cases:");
|
||||
log_this("Usage:Run xcat test cases:");
|
||||
log_this(" xcattest [-?|-h]");
|
||||
log_this(" xcattest [-f configure file] [-b case bundle files]");
|
||||
log_this(" xcattest [-f configure file] [-t cases list]");
|
||||
log_this(" xcattest [-f configure file] [-c cmds list]");
|
||||
log_this(" xcattest [-f configure file:System] [-t case list]");
|
||||
log_this("Show xcat test cases, bundle files, commands lists:");
|
||||
log_this(" xcattest [-f configure file] [-b case bundle files] [-l]");
|
||||
log_this(" xcattest [-f configure file] [-t cases list] [-l]");
|
||||
log_this(" xcattest [-f configure file] [-c cmds list] [-l]");
|
||||
log_this(" xcattest [-bl]");
|
||||
log_this(" xcattest [-cl]");
|
||||
log_this(" xcattest [-s command|bundle]");
|
||||
log_this("");
|
||||
return;
|
||||
}
|
||||
|
||||
sub listbundlefiles
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("show bundle files and descriptions");
|
||||
log_this("******************************");
|
||||
|
||||
my %bundlefilesinfo = ();
|
||||
my @bundlefiles = ();
|
||||
|
||||
#get all .bundle files from /opt/xcat/share/xcat/tools/autotest/bundle/
|
||||
@ -1017,7 +1022,8 @@ sub listbundlefiles
|
||||
my $line;
|
||||
foreach my $bundlefile (@bundlefiles) {
|
||||
if (!open(FILE, "<$bundledir/$bundlefile")) {
|
||||
log_this("Error: Can't open $bundlefile");
|
||||
log_this("Error: Can't open bundle file: $bundlefile");
|
||||
log_this("Use 'xcattest -s bundle' to list out available bundles");
|
||||
return 1;
|
||||
}
|
||||
$skip = 0;
|
||||
@ -1036,25 +1042,57 @@ sub listbundlefiles
|
||||
}
|
||||
|
||||
if (!$skip){
|
||||
$bundlefilesinfo{$bundlefile} = "No description, add with \"description: details\" in this bundle file";
|
||||
$bundlefilesinfo{$bundlefile} = "No description, add \"description: details\" in this bundle file";
|
||||
}
|
||||
}
|
||||
|
||||
while (my ($file, $description) = each (%bundlefilesinfo)){
|
||||
print "\nFile: $file \n";
|
||||
print "Description: $description \n";
|
||||
}
|
||||
&listformatbundleinfo(%bundlefilesinfo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub listformatbundleinfo
|
||||
{
|
||||
my $maxlen = 0;
|
||||
foreach my $filename (keys %bundlefilesinfo) {
|
||||
$maxlen = length($filename) if (length($filename) > $maxlen);
|
||||
}
|
||||
$maxlen += 4;
|
||||
|
||||
my $desiredwidth = 120;
|
||||
my $screenwidth = (`tput cols` + 0);
|
||||
my $finallen = ($screenwidth > $desiredwidth ? $desiredwidth : $screenwidth);
|
||||
|
||||
print "bundle files and descriptions:\n";
|
||||
|
||||
foreach my $filename (keys %bundlefilesinfo) {
|
||||
my @desc = split(" ", $bundlefilesinfo{$filename});
|
||||
my $str = "";
|
||||
my @formatdesc = ();
|
||||
foreach my $word (@desc) {
|
||||
if (length($str) + length($word) > $finallen - $maxlen) {
|
||||
$str =~ s/([^\s]+)\s$/$1/g;
|
||||
push @formatdesc, $str;
|
||||
$str = "";
|
||||
}
|
||||
$str .= $word . " ";
|
||||
}
|
||||
$str =~ s/([^\s]+)\s$/$1/g;
|
||||
push @formatdesc, $str;
|
||||
|
||||
print "$filename";
|
||||
|
||||
my $space = " " x ($maxlen - length($filename));
|
||||
print "$space$formatdesc[0]\n";
|
||||
delete $formatdesc[0];
|
||||
$space = " " x $maxlen;
|
||||
foreach my $line (@formatdesc) {
|
||||
print "$space$line\n" if (length($line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub listcommands
|
||||
{
|
||||
log_this("******************************");
|
||||
log_this("show commands list");
|
||||
log_this("******************************");
|
||||
|
||||
my $casedir = "/opt/xcat/share/xcat/tools/autotest/testcase";
|
||||
my @files = ();
|
||||
|
||||
Get_Files_Recursive("$casedir");
|
||||
@ -1087,7 +1125,8 @@ sub getreport
|
||||
}
|
||||
|
||||
|
||||
sub reordercases {
|
||||
sub reordercases
|
||||
{
|
||||
my @caserange = ();
|
||||
my $line;
|
||||
if ($bundlelist) {
|
||||
@ -1126,50 +1165,66 @@ sub reordercases {
|
||||
@cases = @tmpcases;
|
||||
}
|
||||
|
||||
sub checkoptions{
|
||||
#-b,-c,-t,-bl,-cl should be defined at least one
|
||||
if (!defined($bundlelist) && !defined($caselist) && !defined($cmdlist) && !defined($showbundlefiles) && !defined($showcommandslist)){
|
||||
sub checkoptions
|
||||
{
|
||||
#print "$showbundlesorcommands\n";
|
||||
#print "$needshow\n";
|
||||
#-b,-c,-t,-s should be defined at least one
|
||||
if (!defined($bundlelist) && !defined($caselist) && !defined($cmdlist) && !defined($showbundlesorcommands)) {
|
||||
log_this("Error: please define options correctly");
|
||||
return 1;
|
||||
}elsif ((defined($showbundlefiles) || defined($showcommandslist)) && (defined($bundlelist) || defined($caselist) || defined($cmdlist))){
|
||||
# -bl or -cl can't be used together with -c,-b,-t
|
||||
log_this("Error: -b,-c or -t can't be used together with -bl or -cl");
|
||||
}elsif (defined($showbundlesorcommands) && (defined($bundlelist) || defined($caselist) || defined($cmdlist))) {
|
||||
# -s can't be used together with -c,-b,-t
|
||||
log_this("Error: -b,-c or -t can't be used together with -s");
|
||||
return 1;
|
||||
}elsif ((defined($showbundlefiles) && defined($showcommandslist)) || (defined($showbundlefiles) && $needshow) || ($needshow && defined($showcommandslist))){
|
||||
log_this("Error: -bl, -cl, -l can't be used together");
|
||||
}elsif (defined($showbundlesorcommands) && $needshow) {
|
||||
log_this("Error: -s, -l can't be used together");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#check the L option, it only should be bundle or command
|
||||
if (defined($showbundlesorcommands)) {
|
||||
if (($showbundlesorcommands ne "bundle") && ($showbundlesorcommands ne "command")) {
|
||||
log_this("Error: please use \"bundle\" or \"command\" as the \-s value");
|
||||
return 1;
|
||||
}elsif ($showbundlesorcommands eq "bundle") {
|
||||
$showbundlefiles = 1;
|
||||
}else {
|
||||
}
|
||||
$showcommandslist= 1;
|
||||
}
|
||||
#get and check config file and System label
|
||||
#this System label means only the [System] variable will be loaded
|
||||
if ($configinfo){
|
||||
if ($configinfo =~ /(.*):(.*)/){
|
||||
if ($configinfo) {
|
||||
if ($configinfo =~ /(.*):(.*)/) {
|
||||
$configfile = $1;
|
||||
$initallabel = $2;
|
||||
if ($initallabel ne $loadsysteminfo){
|
||||
log_this("Error: $initallabel is not supported, please use $loadsysteminfo");
|
||||
if ($initallabel ne $loadsysteminfo) {
|
||||
log_this("Error: $initallabel is not supported!");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
}else {
|
||||
$configfile = $configinfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(-e $configfile)) {
|
||||
log_this("Error: Can't open config file: $configfile");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#check bundle files
|
||||
if ($bundlelist){
|
||||
if (defined($bundlelist)) {
|
||||
my @bundles = split /,/, $bundlelist;
|
||||
foreach my $bundle (@bundles){
|
||||
if ("$bundledir/$bundle" !~ /\.bundle$/){
|
||||
if ("$bundledir/$bundle" !~ /\.bundle$/) {
|
||||
log_this("Error: please input the .bundle file");
|
||||
log_this("Use 'xcattest -s bundle' to list out available bundles");
|
||||
return 1;
|
||||
}
|
||||
if (!(-e "$bundledir/$bundle")) {
|
||||
log_this("Error: Can't open bundle file: $bundle");
|
||||
log_this("Use 'xcattest -bl' to list out available bundles");
|
||||
log_this("Use 'xcattest -b bundle' to list out available bundles");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1177,3 +1232,5 @@ sub checkoptions{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user