2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-03-26 11:53:33 +00:00

Merge pull request #6301 from tingtli/task18

add more debug information in the case
This commit is contained in:
Weihua Hu
2019-05-20 21:15:53 +08:00
committed by GitHub

View File

@@ -68,18 +68,18 @@ if (!defined($noderange)) {
}
my $os = &get_os;
if ($check_genesis_file) {
send_msg(2, "[$$]:Check genesis file...............");
send_msg(2, "[$$]:Check if genesis packages are installed on mn...............");
&check_genesis_file(&get_arch);
if ($?) {
send_msg(0, "genesis file not available");
send_msg(0, "genesis packages are not installed");
} else {
send_msg(2, "genesis file available");
send_msg(2, "genesis packages are installed");
}
}
my $master=`lsdef -t site -i master -c 2>&1 | awk -F'=' '{print \$2}'`;
if (!$master) { $master=hostname(); }
chomp($master);
print "master is $master\n";
print "xcat management node is $master\n";
$nodestanza="/tmp/$noderange.stanza";
if (!(-e $nodestanza)) {
`lsdef $noderange -z > $nodestanza`;
@@ -89,15 +89,15 @@ if (!(-e $nodestanza)) {
####nodesetshell test for genesis
####################################
if ($genesis_nodesetshell_test) {
send_msg(2, "[$$]:Running nodesetshell test...............");
send_msg(2, "[$$]:Running nodeset NODE shell test...............");
`nodeset $noderange shell`;
if ($?) {
send_msg(0, "[$$]:nodeset shell failed...............");
send_msg(0, "[$$]:nodeset $noderange shell failed...............");
exit 1;
}
`rpower $noderange boot`;
if ($?) {
send_msg(0, "[$$]:rpower node failed...............");
send_msg(0, "[$$]:rpower $noderange failed...............");
exit 1;
}
#run nodeshell test
@@ -112,7 +112,7 @@ if ($genesis_nodesetshell_test) {
####runcmd test for genesis
####################################
if ($genesis_runcmd_test) {
send_msg(2, "[$$]:Running runcmd test...............");
send_msg(2, "[$$]:Running nodeset NODE runcmd test...............");
if (&testxdsh(&rungenesiscmd(&get_arch))) {
send_msg(0, "[$$]:Could not verify test results using xdsh...............");
exit 1;
@@ -123,7 +123,7 @@ if ($genesis_runcmd_test) {
####runimg test for genesis
##################################
if ($genesis_runimg_test) {
send_msg(2, "[$$]:Run runimg test...............");
send_msg(2, "[$$]:Run nodeset NODE runimage test...............");
if (&testxdsh(&rungenesisimg)) {
send_msg(0, "[$$]:Could not verify test results using xdsh ...............");
exit 1;
@@ -135,12 +135,12 @@ if ($genesis_runimg_test) {
####clear test environment
###################################
if ($clear_env) {
send_msg(2, "[$$]:clear genesis test enviroment...............");
send_msg(2, "[$$]:Clear genesis test enviroment...............");
if (&clearenv(&get_arch)) {
send_msg(0, "[$$]:clear environment failed...............");
send_msg(0, "[$$]:Clear environment failed...............");
exit 1;
}
send_msg(2, "[$$]:clear genesis test enviroment success...............");
send_msg(2, "[$$]:Clear genesis test enviroment success...............");
}
##################################
#check_genesis_file
@@ -160,7 +160,7 @@ sub check_genesis_file {
$genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`;
}
unless ($genesis_base and $genesis_scripts) {
send_msg(0, "xCAT-genesis for $arch did not be installed.");
send_msg(0, "xCAT-genesis for $arch is not installed.");
return 1;
}
return 0;
@@ -190,7 +190,7 @@ sub rungenesiscmd {
$value = 3;
#means runcmd test using test scripts user writes
send_msg(2, "runcmd scripts for test ready.");
send_msg(2, "runcmd scripts for test are ready.");
}
$genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin";
copy("$runcmd_script", "$genesis_bin_dir");
@@ -219,19 +219,18 @@ sub rungenesisimg {
$value = 2;
#means runimg test using test scripts genesistest.pl writes
send_msg(2, "no runimg scripts for test prepared.");
send_msg(2, "no runimg scripts for test are prepared.");
open(TESTIMG, ">$runimg_script")
or die "Can't open testscripts for writing: $!";
or die "Can't open test scripts for writing: $!";
print TESTIMG join("\n", "#!/bin/bash"), "\n";
print TESTIMG join("\n", "#This is test for genesis scripts"), "\n";
print TESTIMG join("\n", "echo \"testimg\" >> $result"), "\n";
close(TESTIMG);
print "value is $value \n";
} else {
$value = 3;
#means runimg test using test scripts user writes
send_msg(2, "runimg scripts for test ready.");
send_msg(2, "runimg scripts for test are ready.");
}
copy("$runimg_script", "/install/my_image/runme.sh") or die "Copy failed: $!";
chmod 0755, "/install/my_image/runme.sh";
@@ -239,7 +238,7 @@ sub rungenesisimg {
copy("/tmp/my_image.tgz", "/install/my_image") or die "Copy failed: $!";
`rinstall $noderange "runimage=http://$master/install/my_image/my_image.tgz",shell`;
if ($?) {
send_msg(0, "rinstall noderange failed for runimg");
send_msg(0, "rinstall noderange runimage=* failed\n");
}
return $value;
}
@@ -248,7 +247,7 @@ sub rungenesisimg {
#########################################
sub testxdsh {
my $value = shift;
print "value is $value \n";
print "The input parameter is $value \n";
my $checkstring;
my $checkfile;
if ($value == 1) {
@@ -267,7 +266,7 @@ sub testxdsh {
if ($?) {
foreach (1 .. 10) {
sleep 300;
send_msg(1,"try to run xdsh to check the results again");
send_msg(1,"try to run xdsh $noderange to check the results again");
`xdsh $noderange -t 2 cat $checkfile 2>&1| grep $checkstring `;
last if ($? == 0);
}
@@ -293,7 +292,7 @@ sub clearenv {
unlink("$runmetar");
unlink("$runimg_script");
rmdir("$runmedir");
send_msg(2, "clear runimage test environment");
send_msg(2, "clear nodeset NODE runimage test environment");
}
if (-e "$runcmd_script") {
my $genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin";
@@ -308,7 +307,7 @@ sub clearenv {
}
`rinstall $noderange boot`;
if ($?) {
send_msg(0, "rinstall node failed");
send_msg(0, "rinstall $noderange boot failed");
exit 1;
}
if (-e "$nodestanza") {
@@ -374,6 +373,8 @@ sub send_msg {
if (!open(LOGFILE, ">> $logfiledir/$logfile")) {
return 1;
}
print "$date $$ $content $msg\n";
print LOGFILE "$date $$ $content $msg\n";
close LOGFILE;