mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-25 02:01:13 +08:00
Check for leftover databases. Fix MasterSlave.t so it doesn't leave leftover dbs and it resets 12347.
This commit is contained in:
@@ -52,6 +52,8 @@ my %port_for = (
|
||||
master6 => 2903,
|
||||
);
|
||||
|
||||
my $test_dbs = qr/^(?:mysql|information_schema|sakila|performance_schema|percona_test)$/;
|
||||
|
||||
sub new {
|
||||
my ( $class, %args ) = @_;
|
||||
foreach my $arg ( qw(basedir DSNParser) ) {
|
||||
@@ -178,7 +180,7 @@ sub wipe_clean {
|
||||
}
|
||||
}
|
||||
foreach my $db ( @{$dbh->selectcol_arrayref('SHOW DATABASES')} ) {
|
||||
next if $db =~ m/(mysql|information_schema|sakila|performance_schema|percona_test)$/;
|
||||
next if $db =~ m/$test_dbs/;
|
||||
$dbh->do("DROP DATABASE IF EXISTS `$db`");
|
||||
}
|
||||
return;
|
||||
@@ -270,6 +272,19 @@ sub leftover_servers {
|
||||
return;
|
||||
}
|
||||
|
||||
sub leftover_databases {
|
||||
my ($self, $host) = @_;
|
||||
PTDEBUG && _d('Checking for leftover databases');
|
||||
my $dbh = $self->get_dbh_for($host);
|
||||
my $dbs = $dbh->selectall_arrayref("SHOW DATABASES");
|
||||
$dbh->disconnect();
|
||||
my @leftover_dbs = map { $_->[0] } grep { $_->[0] !~ m/$test_dbs/ } @$dbs;
|
||||
if ( @leftover_dbs ) {
|
||||
return "Databases are left on $host: " . join(', ', @leftover_dbs);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# This returns an empty string if all servers and data are OK. If it returns
|
||||
# anything but empty string, there is a problem, and the string indicates what
|
||||
# the problem is.
|
||||
@@ -280,9 +295,10 @@ sub ok {
|
||||
push @errors, $self->slave_is_ok('slave1', 'master');
|
||||
push @errors, $self->slave_is_ok('slave2', 'slave1', 1);
|
||||
push @errors, $self->leftover_servers();
|
||||
push @errors, $self->verify_test_data('master');
|
||||
push @errors, $self->verify_test_data('slave1');
|
||||
push @errors, $self->verify_test_data('slave2');
|
||||
foreach my $host ( qw(master slave1 slave2) ) {
|
||||
push @errors, $self->leftover_databases($host);
|
||||
push @errors, $self->verify_test_data($host);
|
||||
}
|
||||
|
||||
@errors = grep { warn "ERROR: ", $_, "\n" if $_; $_; } @errors;
|
||||
return !@errors;
|
||||
|
||||
@@ -207,8 +207,7 @@ SKIP: {
|
||||
);
|
||||
|
||||
$ro_dbh->disconnect();
|
||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
@@ -635,12 +634,16 @@ SKIP: {
|
||||
"Slave replication filter"
|
||||
);
|
||||
|
||||
diag(`/tmp/12346/stop >/dev/null 2>&1`);
|
||||
diag(`/tmp/12345/stop >/dev/null 2>&1`);
|
||||
diag(`/tmp/12346/stop >/dev/null`);
|
||||
diag(`/tmp/12345/stop >/dev/null`);
|
||||
diag(`mv /tmp/12346/orig.cnf /tmp/12346/my.sandbox.cnf`);
|
||||
diag(`mv /tmp/12345/orig.cnf /tmp/12345/my.sandbox.cnf`);
|
||||
diag(`/tmp/12345/start >/dev/null 2>&1`);
|
||||
diag(`/tmp/12346/start >/dev/null 2>&1`);
|
||||
diag(`/tmp/12345/start >/dev/null`);
|
||||
diag(`/tmp/12346/start >/dev/null`);
|
||||
diag(`/tmp/12347/use -e "STOP SLAVE; START SLAVE;" >/dev/null`);
|
||||
|
||||
$master_dbh = $sb->get_dbh_for('master');
|
||||
$slave_dbh = $sb->get_dbh_for('slave1');
|
||||
};
|
||||
|
||||
is(
|
||||
@@ -702,6 +705,7 @@ is(
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh);
|
||||
diag(`$trunk/sandbox/stop-sandbox 2903 2902 2901 2900 >/dev/null 2>&1`);
|
||||
diag(`/tmp/12346/use -e "set global read_only=1"`);
|
||||
diag(`/tmp/12347/use -e "set global read_only=1"`);
|
||||
|
||||
@@ -68,7 +68,7 @@ is(
|
||||
$exit_status,
|
||||
0,
|
||||
"Bug 995274 (undef array): zero exit status"
|
||||
);
|
||||
) or diag($output);
|
||||
|
||||
cmp_ok(
|
||||
PerconaTest::count_checksum_results($output, 'rows'),
|
||||
|
||||
Reference in New Issue
Block a user