Commit c2602c3e authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Two performance additions. 1) Use the -e option to mysqldump to turn

of "fast insert" mode. That option plus a couple of others makes
duplicating the DB 3-4x faster.

Add a DB table of tables to prune out of the copy before creating the
clean DB. There is a lot of stuff in the DB that is not needed for the
testsuite, and the constant copies churn the DB for little reason.
parent 2af54eb9
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
use DBI; use DBI;
use POSIX; use POSIX;
die("*** $0:\n". #die("*** $0:\n".
" Testsuite Disabled. Come edit me if need be.\n"); # " Testsuite Disabled. Come edit me if need be.\n");
$| = 1; $| = 1;
...@@ -385,7 +385,7 @@ sub step_init { ...@@ -385,7 +385,7 @@ sub step_init {
# Setup test database # Setup test database
prints "Setting up test database.\n"; prints "Setting up test database.\n";
prints " Dumping Current "; prints " Dumping Current ";
tbexec("mysqldump $TBDB","$path/dbdump.txt"); tbexec("mysqldump -e -a $TBDB","$path/dbdump.txt");
# Now add a line to the dumped database that sets flest as an admin # Now add a line to the dumped database that sets flest as an admin
prints " Setting up flest admin account "; prints " Setting up flest admin account ";
tbexec("echo \"update users set admin=1 where uid='flest';\"". tbexec("echo \"update users set admin=1 where uid='flest';\"".
...@@ -396,7 +396,7 @@ sub step_init { ...@@ -396,7 +396,7 @@ sub step_init {
tbexec("echo \"create database $testdb\" | mysql","createdb.log"); tbexec("echo \"create database $testdb\" | mysql","createdb.log");
prints " Filling DB "; prints " Filling DB ";
tbexec("cat $path/dbdump.txt | mysql $testdb","fill.log"); tbexec("cat $path/dbdump.txt | mysql -q -s $testdb","fill.log");
$dbh = DBI->connect("DBI:mysql:database=$testdb;host=localhost") || do { $dbh = DBI->connect("DBI:mysql:database=$testdb;host=localhost") || do {
...@@ -405,6 +405,33 @@ sub step_init { ...@@ -405,6 +405,33 @@ sub step_init {
}; };
$ENV{'PATH'} = "$basepath:$path/install/bin:$path/install/sbin"; $ENV{'PATH'} = "$basepath:$path/install/bin:$path/install/sbin";
#
# Clear our extraneous stuff.
#
$sth = $dbh->prepare("SELECT * from testsuite_preentables");
$sth->execute;
while (($table,$action) = $sth->fetchrow_array) {
$_ = $action;
SWITCH: {
/^drop$/ && do {
prints " Dropping table $table\n";
$dbh->do("drop table $table");
last SWITCH;
};
/^clean$/ && do {
prints " Cleaning table $table\n";
$dbh->do("delete from $table");
last SWITCH;
};
/^prune$/ && do {
prints " Pruning table $table\n";
$dbh->do("delete from $table ".
"where pid!='emulab-ops' and pid!='testbed'");
last SWITCH;
};
}
}
if ($type eq "frontend") { if ($type eq "frontend") {
# Clear out experiments and set up test experiment. # Clear out experiments and set up test experiment.
prints " Clearing out existing experiments "; prints " Clearing out existing experiments ";
...@@ -492,7 +519,7 @@ sub step_init { ...@@ -492,7 +519,7 @@ sub step_init {
$pass++; $pass++;
prints " Snapshotting clean state "; prints " Snapshotting clean state ";
tbexec("mysqldump $testdb","clean.txt"); tbexec("mysqldump -e -a $testdb","clean.txt");
prints "END INIT\n"; prints "END INIT\n";
} }
...@@ -556,7 +583,7 @@ sub step_test { ...@@ -556,7 +583,7 @@ sub step_test {
$fail++; $fail++;
doexit(1); doexit(1);
} }
if (tbexect("cat $path/clean.txt | mysql $testdb",TESTLOG)) { if (tbexect("cat $path/clean.txt | mysql -q -s $testdb",TESTLOG)) {
prints "FAIL - Could not populate test DB.\n"; prints "FAIL - Could not populate test DB.\n";
prints "Failure was FATAL - Exiting.\n"; prints "Failure was FATAL - Exiting.\n";
fail2("$test - Populate test DB"); fail2("$test - Populate test DB");
...@@ -595,7 +622,7 @@ sub step_test { ...@@ -595,7 +622,7 @@ sub step_test {
} elsif ($status =~ /^FAIL/) { } elsif ($status =~ /^FAIL/) {
$fail++; $fail++;
# grab copy of testbed # grab copy of testbed
system("mysqldump $testdb > db.txt"); system("mysqldump -e -a $testdb > db.txt");
if (($? >> 8) != 0) { if (($? >> 8) != 0) {
prints "ERROR: Could not grab copy of database.\n"; prints "ERROR: Could not grab copy of database.\n";
doexit(1); doexit(1);
......
Supports Markdown
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