Use dynamic switch directly from "server_need_restart" for better control of when to do it.

Remove #!force-restart and #!fresh-datadir
parent 87283f40
...@@ -2066,33 +2066,26 @@ sub run_testcase_check_skip_test($) ...@@ -2066,33 +2066,26 @@ sub run_testcase_check_skip_test($)
return 0; return 0;
} }
sub dynamic_binlog_format_switch { sub dynamic_binlog_format_switch {
my ($tinfo)= @_; my ($tinfo, $mysqld)= @_;
# Dynamically switch binlog format started MySQL servers
foreach my $mysqld ( mysqlds() )
{
# Skip servers that are restarted between each test
next if $mysqld->option('#!force-restart');
my $sql= "include/set_binlog_format_".$tinfo->{binlog_format_switch}.".sql"; my $sql= "include/set_binlog_format_".$tinfo->{binlog_format_switch}.".sql";
my $args; my $args;
mtr_init_args(\$args); mtr_init_args(\$args);
mtr_add_arg($args, "--defaults-file=%s", $path_config_file); mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld')); mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
mtr_verbose("Dynamically switching binlog format to:", my $res= My::SafeProcess->run
$tinfo->{binlog_format_switch}); (
my $res= My::SafeProcess->run name => "switch binlog format ".$mysqld->name(),
( path => $exe_mysql,
name => "switch binlog format ".$mysqld->name(), args => \$args,
path => $exe_mysql, input => $sql,
args => \$args,
input => $sql,
); );
if ($res != 0) if ($res != 0)
{ {
mtr_error("Failed to switch binlog format"); mtr_error("Failed to switch binlog format");
}
} }
} }
...@@ -2287,11 +2280,6 @@ sub run_testcase ($) { ...@@ -2287,11 +2280,6 @@ sub run_testcase ($) {
do_before_run_mysqltest($tinfo); do_before_run_mysqltest($tinfo);
if (defined $tinfo->{binlog_format_switch} )
{
dynamic_binlog_format_switch($tinfo)
}
if ( $opt_check_testcases ) if ( $opt_check_testcases )
{ {
run_check_testcase_all($tinfo, "before") run_check_testcase_all($tinfo, "before")
...@@ -2779,11 +2767,6 @@ sub server_need_restart { ...@@ -2779,11 +2767,6 @@ sub server_need_restart {
return 0; return 0;
} }
if ( $server->option('#!force-restart') ) {
mtr_verbose("Restart: forced in configuration");
return 1;
}
if ( $tinfo->{'force_restart'} ) { if ( $tinfo->{'force_restart'} ) {
mtr_verbose("Restart: forced in .opt file"); mtr_verbose("Restart: forced in .opt file");
return 1; return 1;
...@@ -2820,31 +2803,38 @@ sub server_need_restart { ...@@ -2820,31 +2803,38 @@ sub server_need_restart {
} }
} }
# Check that running process was started with same options my $is_mysqld= grep ($server eq $_, mysqlds());
# as the current test requires if ($is_mysqld)
my $extra_opt= get_extra_opt($server, $tinfo); {
my $started_opts= $server->{'started_opts'};
if (defined $started_opts and $extra_opt and
! mtr_same_opts($started_opts, $extra_opt) )
{
# Check if diff is binlog format only
# and the next test has $binlog_format_switch set
my @diff_opts= mtr_diff_opts($started_opts, $extra_opt);
if (@diff_opts == 2 and
$diff_opts[0] =~/^--binlog-format=/ and
$diff_opts[1] =~/^--binlog-format=/ and
defined $tinfo->{binlog_format_switch})
{
mtr_verbose("Using dynamic switch of binlog format from ",
$diff_opts[0],"to", $diff_opts[1]);
}
else
{
mtr_verbose("Restart: running with different options '" . # Check that running process was started with same options
join(" ", @{$extra_opt}) . "' != '" . # as the current test requires
join(" ", @{$server->{'started_opts'}}) . "'" ); my $extra_opt= get_extra_opt($server, $tinfo);
return 1; my $started_opts= $server->{'started_opts'};
if (defined $started_opts and $extra_opt and
! mtr_same_opts($started_opts, $extra_opt) )
{
# TODO Use a list to find all options that can be set dynamically
# Check if diff is binlog format only
# and the next test has $binlog_format_switch set
my @diff_opts= mtr_diff_opts($started_opts, $extra_opt);
if (@diff_opts == 2 and
$diff_opts[0] =~/^--binlog-format=/ and
$diff_opts[1] =~/^--binlog-format=/ and
defined $tinfo->{binlog_format_switch})
{
mtr_verbose("Using dynamic switch of binlog format from ",
$diff_opts[0],"to", $diff_opts[1]);
dynamic_binlog_format_switch($tinfo, $server);
}
else
{
mtr_verbose("Restart: running with different options '" .
join(" ", @{$extra_opt}) . "' != '" .
join(" ", @{$server->{'started_opts'}}) . "'" );
return 1;
}
} }
} }
...@@ -2985,12 +2975,6 @@ sub start_servers($) { ...@@ -2985,12 +2975,6 @@ sub start_servers($) {
# Don't delete anything if starting dirty # Don't delete anything if starting dirty
if (!$opt_start_dirty) if (!$opt_start_dirty)
{ {
# Remove old datadir before starting process
if ($mysqld->option('#!fresh-datadir') and -d $datadir) {
mtr_debug("Removing old datadir: '$datadir'");
rmdir($datadir);
}
my @options= ('log-bin', 'relay-log'); my @options= ('log-bin', 'relay-log');
foreach my $option_name ( @options ) { foreach my $option_name ( @options ) {
......
...@@ -16,12 +16,6 @@ log-bin= master-bin ...@@ -16,12 +16,6 @@ log-bin= master-bin
# starting the mysqld # starting the mysqld
#!use-slave-opt #!use-slave-opt
# Force restart between each test case
#!force-restart
# Always install a fresh datadir before starting process
#!fresh-datadir
log-bin= slave-bin log-bin= slave-bin
relay-log= slave-relay-bin relay-log= slave-relay-bin
......
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