mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-14 01:00:23 +08:00
Make wipe_clean() wait until 12347 is clean. Fix ChangeHandler.t, CompareResults.t, and Quoter.t so they leave the dbs clean.
This commit is contained in:
@@ -36,7 +36,8 @@ use Data::Dumper;
|
||||
$Data::Dumper::Indent = 1;
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
$Data::Dumper::Quotekeys = 0;
|
||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||
use constant PTDEVDEBUG => $ENV{PTDEVDEBUG} || 0;
|
||||
|
||||
my $trunk = $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
|
||||
@@ -183,6 +184,28 @@ sub wipe_clean {
|
||||
next if $db =~ m/$test_dbs/;
|
||||
$dbh->do("DROP DATABASE IF EXISTS `$db`");
|
||||
}
|
||||
|
||||
my $slave2_dbh = $self->get_dbh_for('slave2');
|
||||
my $ok = PerconaTest::wait_until(
|
||||
sub {
|
||||
my $dbs = $slave2_dbh->selectall_arrayref("SHOW DATABASES");
|
||||
if ( grep { $_->[0] !~ m/$test_dbs/ } @$dbs ) {
|
||||
PTDEVDEBUG && _d('Waiting for databases to drop', Dumper($dbs));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
);
|
||||
$slave2_dbh->disconnect;
|
||||
if ( !$ok ) {
|
||||
# If this happen, chances are ok() is going to throw
|
||||
# ERROR: Databases are left on slave1: foo
|
||||
# Or maybe not if by chance the DROP statement replicates
|
||||
# between now and then.
|
||||
diag("WARNING: Timeout in Sandbox::wipe_clean() waiting for "
|
||||
. "databases to drop");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use PerconaTest;
|
||||
|
||||
my $dp = new DSNParser(opts => $dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
my $slave1_dbh = $sb->get_dbh_for('slave1');
|
||||
|
||||
throws_ok(
|
||||
@@ -201,9 +201,9 @@ is_deeply(\@rows,
|
||||
# Test fetch_back().
|
||||
# #############################################################################
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 1 unless $dbh;
|
||||
skip 'Cannot connect to sandbox master', 1 unless $master_dbh;
|
||||
|
||||
$dbh->do('CREATE DATABASE IF NOT EXISTS test');
|
||||
$master_dbh->do('CREATE DATABASE IF NOT EXISTS test');
|
||||
|
||||
$ch = new ChangeHandler(
|
||||
Quoter => $q,
|
||||
@@ -218,7 +218,7 @@ SKIP: {
|
||||
|
||||
@rows = ();
|
||||
$ch->{queue} = 0;
|
||||
$ch->fetch_back($dbh);
|
||||
$ch->fetch_back($master_dbh);
|
||||
`/tmp/12345/use < $trunk/t/lib/samples/before-TableSyncChunk.sql`;
|
||||
# This should cause it to fetch the row from test.test1 where a=1
|
||||
$ch->change('UPDATE', { a => 1, __foo => 'bar' }, [qw(a)] );
|
||||
@@ -309,13 +309,13 @@ is(
|
||||
delete $row->{other_col};
|
||||
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 3 unless $dbh;
|
||||
skip 'Cannot connect to sandbox master', 3 unless $master_dbh;
|
||||
|
||||
$dbh->do('DROP TABLE IF EXISTS test.issue_371');
|
||||
$dbh->do('CREATE TABLE test.issue_371 (id INT, foo varchar(16), bar char)');
|
||||
$dbh->do('INSERT INTO test.issue_371 VALUES (1,"foo","a"),(2,"bar","b")');
|
||||
$master_dbh->do('DROP TABLE IF EXISTS test.issue_371');
|
||||
$master_dbh->do('CREATE TABLE test.issue_371 (id INT, foo varchar(16), bar char)');
|
||||
$master_dbh->do('INSERT INTO test.issue_371 VALUES (1,"foo","a"),(2,"bar","b")');
|
||||
|
||||
$ch->fetch_back($dbh);
|
||||
$ch->fetch_back($master_dbh);
|
||||
|
||||
is(
|
||||
$ch->make_INSERT($row, [qw(id foo)]),
|
||||
@@ -409,7 +409,7 @@ is(
|
||||
# #############################################################################
|
||||
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 1 unless $dbh;
|
||||
skip 'Cannot connect to sandbox master', 1 unless $master_dbh;
|
||||
$sb->load_file('master', "t/lib/samples/issue_641.sql");
|
||||
|
||||
@rows = ();
|
||||
@@ -429,7 +429,7 @@ SKIP: {
|
||||
queue => 0,
|
||||
tbl_struct => $tbl_struct,
|
||||
);
|
||||
$ch->fetch_back($dbh);
|
||||
$ch->fetch_back($master_dbh);
|
||||
|
||||
$ch->change('UPDATE', {id=>1}, [qw(id)] );
|
||||
$ch->change('INSERT', {id=>1}, [qw(id)] );
|
||||
@@ -471,7 +471,7 @@ is_deeply(
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($slave1_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
||||
@@ -777,5 +777,6 @@ like(
|
||||
diag(`rm -rf $tmpdir`);
|
||||
diag(`rm -rf /tmp/*outfile.txt`);
|
||||
$sb->wipe_clean($dbh1);
|
||||
$sb->wipe_clean($dbh2);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
||||
@@ -211,7 +211,7 @@ SKIP: {
|
||||
$selsth->finish();
|
||||
|
||||
$dbh->do("DROP DATABASE serialize_test");
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$dbh->disconnect();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user