mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#19535 mysql-test-run cannot handle crashing test cases
- Make mysql-test-run.pl restart a crashed/stopped process if it was expected it should crash. - Added testcase for "crash_commit_before", which tests behaviour when server crashes just before commit. * The testcase first write a small var/tmp/master0.expect file indicating expected crash * Then sets "DEBUG" variable to for example "d,crash_commit_before" and then executes a commit. * The server will crash and be brought back up by mysql-test-run.pl * Test case will then wait for the process to come back online before continuing. client/mysqltest.c: Add "die" command used to abort a failing test case Remove unused "exit" command mysql-test/lib/mtr_process.pl: When a process crash during execution of mysqltest, check if it was expected and restart the process in that case. mysql-test/mysql-test-run.pl: Remmeber options used when ndbd's and mysqld's was started, to be used by restart code mysql-test/r/crash_commit_before.result: New BitKeeper file ``mysql-test/r/crash_commit_before.result'' mysql-test/include/wait_until_connected_again.inc: New BitKeeper file ``mysql-test/include/wait_until_connected_again.inc'' mysql-test/t/crash_commit_before.test: New BitKeeper file ``mysql-test/t/crash_commit_before.test''
This commit is contained in:
@ -272,10 +272,10 @@ sub spawn_parent_impl {
|
||||
last;
|
||||
}
|
||||
|
||||
# If one of the processes died, we want to
|
||||
# mark this, and kill the mysqltest process.
|
||||
# One of the child processes died, unless this was expected
|
||||
# mysqltest should be killed and test aborted
|
||||
|
||||
mark_process_dead($ret_pid);
|
||||
check_expected_crash_and_restart($ret_pid);
|
||||
}
|
||||
|
||||
if ( $ret_pid != $pid )
|
||||
@ -809,6 +809,81 @@ sub mark_process_dead($)
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# Loop through our list of processes and look for and entry
|
||||
# with the provided pid, if found check for the file indicating
|
||||
# expected crash and restart it.
|
||||
#
|
||||
sub check_expected_crash_and_restart($)
|
||||
{
|
||||
my $ret_pid= shift;
|
||||
|
||||
foreach my $mysqld (@{$::master}, @{$::slave})
|
||||
{
|
||||
if ( $mysqld->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
|
||||
$mysqld->{'pid'}= 0;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
|
||||
"$mysqld->{'idx'}" . ".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
mysqld_start($mysqld, $mysqld->{'start_opts'},
|
||||
$mysqld->{'start_slave_master_info'});
|
||||
unlink($expect_file);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $cluster (@{$::clusters})
|
||||
{
|
||||
if ( $cluster->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
|
||||
$cluster->{'pid'}= 0;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
|
||||
".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
ndbmgmd_start($cluster);
|
||||
unlink($expect_file);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
foreach my $ndbd (@{$cluster->{'ndbds'}})
|
||||
{
|
||||
if ( $ndbd->{'pid'} eq $ret_pid )
|
||||
{
|
||||
mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
|
||||
$ndbd->{'pid'}= 0;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
|
||||
"$ndbd->{'idx'}" . ".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
ndbd_start($cluster, $ndbd->{'idx'},
|
||||
$ndbd->{'start_extra_args'});
|
||||
unlink($expect_file);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
|
||||
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# The operating system will keep information about dead children,
|
||||
|
Reference in New Issue
Block a user