Commit 80da6058 authored by Christopher Alfeld's avatar Christopher Alfeld
Browse files

Updated for full mode. Everything's in including tmcd_redirect. It

hasn't been tested much though.

Currently all frontend tests will run fine as full tests.
parent d27aa493
......@@ -35,20 +35,26 @@ The test directory holds the following files:
build.log Log of 'gmake'
install.log Log of 'gmake boss-install'
postinstall.log Log of 'gmake post-install'
createdb.log Log of creating test DB.
fill.log Log of filling test DB.
clear.log Log of clearing experiments from test DB.
createdb.log # Log of creating test DB.
fill.log # Log of filling test DB.
clear.log * Log of clearing experiments from test DB.
unavailable.log ** Log of marking nodes as unavailable.
clean.txt Dump of clean test DB.
dbdump.txt Dump of real database.
defs Defs file used for configure.
* - Appears only in frontend (default) mode.
** - Appears only in full mode.
# - Empty except under error conditions.
Note: createdb.log, fill.log, and cleanup.log are empty when no errors
occur.
Note: cleanup.log, unavailable.log, and free.log appear only in full
mode. clear.log appears only in frontend mode.
Advanced: To run all tests with a special DB setup you can do 'tbtest
init' and then replace 'clean.txt' with a dump of the DB of your
choice. 'clean.txt' is loaded into the test DB before every test run.
choice. 'clean.txt' is loaded into the test DB before every test
run. Be very careful to maintain the reserved table when doing this
in full mode.
Adding Tests
------------
......@@ -131,11 +137,18 @@ Mode:
init <db> [<pid> <eid> <num>]
test <testdir>
single <testdir> <tests>
finish
finish [<db> <pid> <eid>]
tbtest [-leavedb] [-path <path>] <db> <testdir>
Notes:
The arguments in [] for the modes are necessary with -full and should
not be present otherwise.
IMPORTANT: If running with -full you must have -full on all modes.
Doing a -full init and then a finish without -full will cause
problems.
Generally tbtest is invoked in 'run' mode that does everything. For
an more interactive approach a you can invoke 'tbtest init ...' and
then any number of 'tbtest test' and 'tbtest single' commands to run
......
......@@ -22,7 +22,7 @@
# init <db> [<pid> <eid> <num>] - Initiatlize.
# test <testdir> - Run tests
# single <testdir> <tests> - Run only <tests>
# finish [<pid> <eid>] - Finish run.
# finish [<db> <pid> <eid>] - Finish run.
# <num> is "X <type> ...", for example "10 pc 16 shark"
use DBI;
......@@ -73,7 +73,7 @@ sub show_help {
print STDERR " init <db> [<pid> <eid> <num>]\n";
print STDERR " test <testdir>\n";
print STDERR " single <testdir> <tests>\n";
print STDERR " finish <pid> <eid>\n";
print STDERR " finish [<db> <pid> <eid>]\n";
print STDERR "<num>: Must be even lengthed list of <number> <type>.\n";
print STDERR " Ex: \"4 pc 16 shark\"\n";
print STDERR "Examples:\n";
......@@ -130,8 +130,8 @@ if ($mode eq "run") {
if ($type eq "frontend") {
if ($#ARGV != -1) {show_help;}
} else {
if ($#ARGV != 1) {show_help;}
($pid,$eid) = @ARGV;
if ($#ARGV != 2) {show_help;}
($TBDB,$pid,$eid) = @ARGV;
}
} else {
print STDERR "Unknown mode: $mode\n";
......@@ -209,12 +209,8 @@ sub tbexect {
sub doexit {
printf LOG "Total Tests: %-5d Pass: %-5d Fail: %-5d Unknown: %-5d\n", $pass+$fail+$unknown, $pass, $fail, $unknown;
printf "Total Tests: %-5d Pass: %-5d Fail: %-5d Unknown: %-5d\n", $pass+$fail+$unknown, $pass, $fail, $unknown;
# Try to do the necessary cleanup
if ($leavedb == 0) {
system("echo \"drop database if exists $testdb\" | mysql");
}
if (($type eq "full") && (($mode eq "run") || ($mode eq "init"))) {
system("/usr/testbed/bin/nfree $pid $eid > /dev/null");
if ($_[0] != 0) {
prints "Run in finish mode to clean up any residual state.\n";
}
close(LOG);
exit($_[0]);
......@@ -229,7 +225,7 @@ sub step_init {
prints "Database: $TBDB\n";
prints "Type: $type\n";
prints "\n";
prints "Beginning test run. " . ctime(time) . "\n";
prints "Beginning test run. " . ctime(time);
# Initialize DB
$dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") ||
......@@ -282,6 +278,28 @@ sub step_init {
}
prints " Reserving ";
tbexec("/usr/testbed/bin/nalloc $pid $eid $raw","$path/reserve.log");
prints " Setting up tmcc redirect ";
$dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") ||
die "Could not connect to DB.\n";
foreach $type (keys(%have)) {
foreach $node (@{$have{$type}}) {
$dbh->do("DELETE from tmcd_redirect" .
" where node_id=\"$node\"") || do {
$fail++;
prints "FAIL - $node\n";
doexit(1);
};
$dbh->do("INSERT into tmcd_redirect (node_id,dbname) values" .
" (\"$node\",\"$testdb\")") || do {
$fail++;
prints "FAIL - $node\n";
doexit(1);
};
}
}
prints "PASS\n";
$dbh->disconnect;
}
# Set up object tree
......@@ -382,7 +400,7 @@ sub step_init {
} else {
# Free nodes we allocated for the experiment and allocate all
# others.
prints " Creating testbed/unavailable in test DB.\n";
prints " Creating testbed/unavailable in test DB ";
open(AVAIL,"avail |");
$raw = "";
while (<AVAIL>) {
......@@ -391,7 +409,6 @@ sub step_init {
($node) = /^\|([-a-zA-Z0-9]+)/;
$raw .= " $node";
}
print "DEBUG: $raw\n";
close(AVAIL);
$dbh->do("DELETE from experiments where pid=\"testbed\" and eid=\"unavailable\"");
......@@ -425,7 +442,6 @@ sub step_init {
prints " Snapshotting clean state ";
tbexec("mysqldump $testdb","clean.txt");
prints "END INIT\n";
close(LOG);
}
sub step_test {
......@@ -529,25 +545,69 @@ sub step_test {
chdir $path;
}
prints "END TEST\n";
close(LOG);
}
sub step_cleanup {
open(LOG,">> $logfile");
prints "START cleanup\n";
prints "START CLEANUP\n";
prints "Cleaning up\n";
# Try to do the necessary cleanup
if ($leavedb == 0) {
prints " Dropping test DB ";
system("echo \"drop database if exists $testdb\" | mysql");
if (($? >> 8) != 0) {
prints "FAIL\n";
$fail++;
} else {
prints "PASS\n";
$pass++;
}
}
if (($type eq "full")) {
prints " Clearing redirects ";
$ok = 1;
$dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") || do {
$ok = 0;
};
if (! $ok) {
prints "FAIL - Could not connect to db\n";
$fail++;
} else {
$sth=$dbh->prepare("SELECT node_id from reserved" .
" where pid=\"$pid\" and eid=\"$eid\"");
$sth->execute;
$ok = 1;
while (($node) = $sth->fetchrow_array) {
$dbh->do("DELETE from tmcd_redirect" .
" where node_id=\"$node\"") || do {
prints "FAIL - $node\n";
$fail++;
$ok = 0;
last;
}
}
if ($ok) {
prints "PASS\n";
}
$dbh->disconnect;
}
if ($type eq "full") {
prints " Freeing reserved nodes ";
tbexec("/usr/testbed/bin/nfree $pid $eid","cleanup.log");
prints " Freeing nodes ";
system("/usr/testbed/bin/nfree $pid $eid > /dev/null");
if (($? >> 8) != 0) {
prints "FAIL\n";
$fail++;
} else {
prints "PASS\n";
$pass++;
}
}
prints "End test run. " . ctime(time) . "\n";
prints "End test run. " . ctime(time);
prints "END CLEANUP\n";
close(LOG);
}
if ($mode eq "run") {
step_init;
step_test;
......@@ -563,5 +623,6 @@ if ($mode eq "run") {
}
open(LOG,">> $logfile");
doexit(0);
# Do exit does all cleanup.
doexit(0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment