2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-08-21 02:30:21 +00:00

version 1 after review

This commit is contained in:
caomengmeng
2016-09-05 05:37:03 -04:00
parent 05d2fbae70
commit ae51b3358d
2 changed files with 196 additions and 77 deletions

View File

@@ -0,0 +1,46 @@
start:install_xCAT_on_rhels_sles
description:install xCAT with go-xcat tool in a fresh environment for rhels and sles
os:Linux
stop:yes
cmd:if grep "Red Hat" /etc/*release >/dev/null; then yum install -y yum-utils bzip2; fi
check:rc==0
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: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
cmd:lsxcatd -v
check:rc==0
check:output=~Version
cmd:service xcatd status
check:rc==0
check:output=~running
cmd:rm -rf /xcat-core.tar.bz2 /xcat-dep.tar.bz2
end
start:install_xCAT_on_ubuntu
description:install xCAT with go-xcat tool in a fresh environment for ubuntu
os:Linux
stop:yes
cmd:arc_all=`uname -a`; code=`lsb_release -sc`;if [[ $arc_all =~ "ppc64le" ]]; then arch="ppc64el";else arch="x86_64";fi; cp "/opt/xcat/share/xcat/tools/autotest/testcase/go-xcat/$code-$arch.sources.list" "/etc/apt/sources.list"
cmd:apt-get clean;apt-get update
check:rc==0
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;
check:rc==0
cmd:source "/etc/profile.d/xcat.sh"
check:rc==0
cmd:lsxcatd -v
check:rc==0
check:output=~Version
cmd:service xcatd status
check:rc==0
check:output=~running
cmd:rm -rf /xcat-core.tar.bz2 /xcat-dep.tar.bz2
end

View File

@@ -12,23 +12,30 @@ BEGIN
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use lib "$::XCATROOT/lib/perl";
my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
my $needhelp = 0;
my $config_info = "$rootdir/default.conf";
my $bundle_list = undef;
my $case_list = undef;
my $cmd_list = undef;
my $needshow = 0;
my $restore = 0;
my $ret = 0;
my $string1 = undef;
my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
my $needhelp = 0;
my $configinfo = undef;
my $configfile = "$rootdir/default.conf";;
my $initallabel = 0;
my $bundledir = "$rootdir/bundle";
my $bundlelist = undef;
my $caselist = undef;
my $cmdlist = undef;
my $needshow = 0;
my $showbundlefiles = 0;
my $restore = 0;
my $ret = 0;
my $string1 = undef;
my $loadsysteminfo = "System";
if (
!GetOptions("h|?" => \$needhelp,
"f=s" => \$config_info,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"f=s" => \$configinfo,
"b=s" => \$bundlelist,
"t=s" => \$caselist,
"c=s" => \$cmdlist,
"l" => \$needshow,
"bl" => \$showbundlefiles,
"restore" => \$restore)
)
{
@@ -36,48 +43,24 @@ if (
exit 1;
}
unless(defined($bundle_list) || defined($case_list) || defined($cmd_list) || defined($needshow)){
&usage;
exit 1;
}
if ($needhelp)
{
&usage;
exit 0;
}
#check config file and system label
my $configfile = undef;
my $inital_info = undef;
if ($config_info){
if ($config_info =~ /:/){
my @config_info = split /:/, $config_info;
$configfile = $config_info[0];
$inital_info = $config_info[1];
if ($inital_info ne "system"){
print "Failed: $inital_info in $config_info is not supported!\n";
exit 1;
}
}else{
$configfile = $config_info;
}
}
if (!open(FILE, "$configfile")) {
print "can't open config file: $configfile\n";
exit 1;
}
#check bundle files
if ($bundle_list){
my @bundles = split /,/, $bundle_list;
foreach my $bundle (@bundles){
if (!open(FILE, "<$rootdir/bundle/$bundle")) {
print "can't open bundle file: $rootdir/bundle/$bundle\n";
exit 1;
}
}
if (&checkoptions)
{
&usage;
exit 1;
}
if ($showbundlefiles)
{
&listbundlefiles;
exit 0;
}
#load case to $cases
# key type
#$cases[x](x>0): hash
@@ -119,9 +102,11 @@ if ($ret != 0) {
goto EXIT;
}
$ret = &init;
if ($ret != 0) {
goto EXIT;
if ($initallabel){
$ret = &init;
if ($ret != 0) {
goto EXIT;
}
}
my @filespath = ();
@@ -132,7 +117,7 @@ if ($ret != 0) {
}
#run case
&reordercases if (defined($bundle_list) || defined($case_list));
&reordercases if (defined($bundlelist) || defined($caselist));
&runcase;
EXIT:
@@ -203,10 +188,33 @@ sub getConfig
my $value = undef;
my $c = 0;
my $cmd = undef;
my $mgt_name = undef;
if (!open(FILE, "$configfile")) {
log_this("Error: can't open xCAT config file: $configfile");
close(FILE);
return 1;
}
#Only load System information
if (defined($initallabel) && ($initallabel eq $loadsysteminfo)) {
while (my $line = <FILE>) {
$line = &trim($line);
next if (length($line) == 0);
while (my $line = <FILE>) {
#Only read System variable
if ($line =~ /\[System\]/) {
$type = "Varible";
}
if (defined($type) && ($type eq "Varible")) {
if ($line =~ /(\w+)\s*=\s*([\w\.\-\+\/:]+)/) {
$config{var}{$1} = $2;
}
}
}
}else{
#Load all config files information
while (my $line = <FILE>) {
$line = &trim($line);
next if (length($line) == 0);
@@ -262,6 +270,7 @@ sub getConfig
}
}
}
}
if (exists $config{object}) {
foreach my $type (keys %{ $config{object} }) {
@@ -385,7 +394,7 @@ sub init
if (!exists $config{var}{ARCH}) {
if (!exists $config{var}{CN}) {
$config{var}{ARCH} = "Unknown";
log_this("No compute node defined,can't get ARCH of compute node");
log_this("Error: No compute node defined, can't get ARCH of compute node");
} else {
$config{var}{ARCH} = getnodeattr($config{var}{CN}, "arch");
if ($config{var}{ARCH} =~ /ppc/) {
@@ -399,7 +408,7 @@ sub init
if (!exists $config{var}{HCP}) {
if (!exists $config{var}{CN}) {
$config{var}{HCP} = "Unknown";
log_this("No compute node defined,can't get HCP TYPE of compute node");
log_this("Error: No compute node defined, can't get HCP TYPE of compute node");
} else {
$config{var}{HCP} = getnodeattr($config{var}{CN}, "mgt");
log_this("Detecting: HCP = $config{var}{HCP}");
@@ -446,7 +455,7 @@ sub uninit
log_this($cmd);
runcmd($cmd);
if ($::RUNCMD_RC != 0) {
log_this("Fail to run $cmd");
log_this("Error: Fail to run $cmd");
return 1;
}
}
@@ -494,8 +503,8 @@ sub loadcase
my $casedir = "/opt/xcat/share/xcat/tools/autotest/testcase";
my @files = ();
#if($cmd_list){
# my @cmds = split /,/,$cmd_list;
#if($caselist){
# my @cmds = split /,/,$caselist;
# for my $cmd (@cmds){
# push (@files, glob("$casedir/$cmd/*"));
# }
@@ -505,8 +514,8 @@ sub loadcase
Get_Files_Recursive("$casedir");
for (my $countfile = 0 ; $countfile < @filespath ; $countfile++)
{
if ($cmd_list) {
my @cmds = split /,/, $cmd_list;
if ($caselist) {
my @cmds = split /,/, $caselist;
for (my $countcmd = 0 ; $countcmd < @cmds ; $countcmd++) {
if ($filespath[$countfile] =~ m/\/$cmds[$countcmd]\/case/) {
push(@files, glob("$filespath[$countfile]"));
@@ -528,9 +537,14 @@ sub loadcase
my @caserange = ();
my @rightcase = ();
my @notrightcase = ();
if ($bundle_list) {
my @bundles = split /,/, $bundle_list;
if ($bundlelist) {
my @bundles = split /,/, $bundlelist;
foreach my $bundle (@bundles) {
if (!open(FILE, "<$bundledir/$bundle")){
log_this("Error: Can't open bundle file: $bundle");
close(FILE);
return 1;
}
while ($line = <FILE>) {
$line = trim($line);
next if (length($line) == 0);
@@ -539,12 +553,12 @@ sub loadcase
close(FILE);
}
}
if ($case_list) {
@caserange = split /,/, $case_list;
if ($caselist) {
@caserange = split /,/, $caselist;
}
foreach $file (@files) {
if (!open(FILE, "<$file")) {
log_this("can't open $file");
log_this("Error: Can't open $file");
return 1;
}
while ($line = <FILE>) {
@@ -682,7 +696,7 @@ sub getnodeattr
# return "Unknown";
foreach $t (1 .. 40) {
log_this("could not get node attr $attr ");
log_this("Error: could not get node attr $attr ");
@output = runcmd("lsdef -t node -o $node -i $attr");
last if ($::RUNCMD_RC == 0);
}
@@ -728,7 +742,7 @@ sub getvar
if (exists($config{var}{$varname})) {
$str =~ s/\$\$$varname/$config{var}{$varname}/g;
} else {
log_this("Error:can't get varible $varname");
log_this("Error: can't get varible $varname");
return '';
}
}
@@ -945,13 +959,25 @@ sub usage
{
print "Usage:xcattest - Run xcat test cases.\n";
print " xcattest [-?|-h]\n";
print " xcattest [-f configure file] [-b case bundle list] [--restore]\n";
print " xcattest [-f configure file] [-t case list] [--restore]\n";
print " xcattest [-f configure file] [-c cmd list] [-l] [--restore]\n";
print " xcattest [-f configure file] [-b case bundle list]\n";
print " xcattest [-f configure file] [-t case list]\n";
print " xcattest [-f configure file] [-c cmd list]\n";
print " xcattest [-f configure file:System] [-t case] \n";
print " xcattest [-f configure file] [-b case bundle list] [-l]\n";
print " xcattest [-f configure file] [-t case list] [-l]\n";
print " xcattest [-f configure file] [-c cmd list] [-l]\n";
print " xcattest [-bl]";
print "\n";
return;
}
sub listbundlefiles
{
print "Bundle files listed in $bundledir/:\n";
system("ls $bundledir ");
return 0;
}
sub getreport
{
open(INDOC, ">$_[1]") || die("open STDOUT failed");
@@ -976,11 +1002,11 @@ sub getreport
sub reordercases {
my @caserange = ();
my $line;
if ($bundle_list) {
my @bundles = split /,/, $bundle_list;
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("Error: Can't open bundle file: $bundle");
return 1;
}
while ($line = <FILE>) {
@@ -991,8 +1017,8 @@ sub reordercases {
close(FILE);
}
}
if ($case_list) {
@caserange = split /,/, $case_list;
if ($caselist) {
@caserange = split /,/, $caselist;
}
my @tmpcases = ();
@@ -1012,3 +1038,50 @@ sub reordercases {
@cases = @tmpcases;
}
sub checkoptions{
#bundle, cases lists and command lists, one of them must be defined
if (!defined($bundlelist) && !defined($caselist) && !defined($caselist) && !defined($showbundlefiles)){
&usage;
exit 1;
}
#get and check config file and System label
#this System label means only the [System] variable will be loaded
if ($configinfo){
if ($configinfo =~ /(\w+):(\w+)/){
$configfile =$1;
$initallabel = $2;
if ($initallabel ne $loadsysteminfo){
print "Error $initallabel is not supported!\n";
log_this("Error: $initallabel is not supported!");
return 1;
}
}else{
$configfile = $configinfo;
}
}
if (!(-e $configfile)) {
print "Error Can't open config file: $configfile\n";
log_this("Error Can't open config file: $configfile");
return 1;
}
#check bundle files
if ($bundlelist){
my @bundles = split /,/, $bundlelist;
foreach my $bundle (@bundles){
if (!(-e "$bundledir/$bundle")) {
print "Error: Can't open bundle file: $bundledir/$bundle\n";
log_this("Error: Can't open bundle file: $bundledir/$bundle");
return 1;
}
}
}
return 0;
}