2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

Improve genesistest test script

This commit is contained in:
Mark Gurevich 2021-12-14 10:19:21 -05:00
parent 2ceca4bc4a
commit f02a5c97c1

View File

@ -100,6 +100,10 @@ if ($genesis_nodesetshell_test) {
send_msg(0, "[$$]:rpower $noderange failed...............");
exit 1;
}
else {
send_msg(2, "Installing with \"nodeset $noderange shell\" for shell test");
sleep 180; # wait 3 min for install to finish
}
#run nodeshell test
send_msg(2, "prepare for nodeshell script.");
if ( &testxdsh(3)) {
@ -208,6 +212,7 @@ sub rungenesiscmd {
}
else {
send_msg(2, "Installing with \"$rinstall_cmd\" for runcmd test");
sleep 180; # wait 3 min for install to finish
}
return $value;
}
@ -242,10 +247,14 @@ sub rungenesisimg {
chmod 0755, "/install/my_image/runme.sh";
`tar -zcvf /tmp/my_image.tgz -C /install/my_image .`;
copy("/tmp/my_image.tgz", "/install/my_image") or die "Copy failed: $!";
`rinstall $noderange "runimage=http://$master/install/my_image/my_image.tgz",shell`;
my $rinstall_cmd = "rinstall $noderange runimage=http://$master/install/my_image/my_image.tgz,shell";
`$rinstall_cmd`;
if ($?) {
send_msg(0, "rinstall noderange runimage=* failed\n");
send_msg(0, "Command \"$rinstall_cmd\" failed for runimage test\n");
$value = -1;
} else {
send_msg(2, "Installing with \"$rinstall_cmd\" for runimage test\n");
sleep 180; # wait 3 min for install to finish
}
return $value;
}
@ -257,6 +266,7 @@ sub testxdsh {
my $checkstring;
my $checkfile;
my $nodestatus;
my $xdsh_out;
if ($value == 1) {
#mean runcmd test using test scripts genesistest.pl writes
$checkstring = "testcmd";
@ -268,24 +278,26 @@ sub testxdsh {
$checkstring = "destiny=shell";
$checkfile = "/proc/cmdline";
} elsif ($value == -1) {
send_msg(2,"Error setting up the node for testxdsh");
send_msg(0,"Error setting up the node for testxdsh");
return 1;
}
send_msg(2, "Node $noderange has been installed with genesis shell. Checking $checkfile file on that node contains '$checkstring' \n");
my $xdsh_command="xdsh $noderange -t 2 cat $checkfile 2>&1|grep $checkstring";
send_msg(2, "Node $noderange has been installed with genesis shell for test value $value \n");
send_msg(2, "Checking $checkfile file on that node contains '$checkstring' \n");
my $xdsh_command="xdsh $noderange -t 2 cat $checkfile 2>&1";
if (($value == 1) || ($value == 2) || ($value == 3)) {
`$xdsh_command`;
`$xdsh_command | grep $checkstring`;
if ($?) {
# First attempt to run xdsh failed, display console log to see what happened, then try few more times
my $console_log = `nodels $noderange | xargs -I % tail -v --lines 25 /var/log/consoles/%.log`;
send_msg(2, "Console log: $console_log \n");
my @i = (1..5);
my @i = (1..3);
for (@i) {
sleep 300;
$xdsh_out=`$xdsh_command`;
$nodestatus=`lsdef $noderange -i status -c 2>&1 | awk -F'=' '{print \$2}'`;
send_msg(1,"[$_] Running \"$xdsh_command\" to check results. Node status: $nodestatus");
`$xdsh_command`;
send_msg(1,"[$_] \"$xdsh_command\" returned: $xdsh_out. Node status: $nodestatus");
sleep 180;
`$xdsh_command | grep $checkstring`;
last if ($? == 0);
}
}
@ -375,7 +387,9 @@ sub send_msg {
my $logfile = "";
my $logfiledir = "/tmp/genesistestlog";
my $date = `date +"%Y%m%d"`;
my $time = `date +"%T"`;
chomp($date);
chomp($time);
if (!-e $logfiledir)
{
mkpath( $logfiledir );
@ -386,13 +400,13 @@ sub send_msg {
} elsif ($log_level == 1) {
$content = "Warning:";
} elsif ($log_level == 2) {
$content = "Notice:";
$content = "Info:";
}
if (!open(LOGFILE, ">> $logfiledir/$logfile")) {
return 1;
}
print "$date $$ $content $msg\n";
print "$date $time $$ $content $msg\n";
print LOGFILE "$date $$ $content $msg\n";
close LOGFILE;