Use md5 "pings" in percona_test.sentinel for sub-second tests that call wipe_clean() twice. Update t/lib/samples/SchemaIterator/all-dbs-tbls-5.0.txt for percona_test.sentinel. Restart slaves in pt-table-checksum/replication_filters.t. Modernize and make pt-table-sync/replicate_do_db.t stable.

This commit is contained in:
Daniel Nichter
2012-06-06 13:31:24 -07:00
parent e15c712398
commit a178bb32f8
5 changed files with 34 additions and 51 deletions

View File

@@ -243,6 +243,13 @@ CREATE TABLE `checksums` (
PRIMARY KEY (`db_tbl`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
percona_test.sentinel
CREATE TABLE `sentinel` (
`id` int(11) NOT NULL,
`a` int(10) unsigned default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
sakila.actor
CREATE TABLE `actor` (
`actor_id` smallint(5) unsigned NOT NULL auto_increment,

View File

@@ -263,6 +263,8 @@ $master_dbh->disconnect();
diag(`/tmp/12345/stop >/dev/null`);
diag(`mv /tmp/12345/orig.cnf /tmp/12345/my.sandbox.cnf`);
diag(`/tmp/12345/start >/dev/null`);
# Restart the slaves so they reconnect immediately.
restart_slave_threads();
$master_dbh = $sb->get_dbh_for('master');
# Get the master's binlog pos so we can check its binlogs for USE statements

View File

@@ -21,16 +21,8 @@ my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
# Reset master and slave relay logs so the second slave
# starts faster (i.e. so it doesn't have to replay the
# masters logs which is stuff from previous tests that we
# don't care about).
diag(`$trunk/sandbox/test-env reset >/dev/null`);
# It's not really master1, we just use its port 12348.
# diag(`/tmp/12348/stop >/dev/null 2>&1`);
# diag(`rm -rf /tmp/12348/ >/dev/null 2>&1`);
diag(`$trunk/sandbox/start-sandbox slave 12348 12345 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox slave 12348 12345`);
my $dbh3 = $sb->get_dbh_for('master1');
if ( !$master_dbh ) {
@@ -40,7 +32,7 @@ elsif ( !$dbh3 ) {
plan skip_all => 'Cannot connect to second sandbox slave';
}
else {
plan tests => 5;
plan tests => 4;
}
$sb->wipe_clean($master_dbh);
@@ -59,26 +51,8 @@ $master_dbh->do('CREATE DATABASE test');
$master_dbh->do('CREATE TABLE test.foo (i INT, UNIQUE INDEX (i))');
$master_dbh->do('INSERT INTO test.foo VALUES (1),(2),(9)');
diag(`/tmp/12345/use < $trunk/t/pt-table-sync/samples/issue_533.sql`);
# My box acts weird so I double check that this is ok.
my $r;
my $i = 0;
PerconaTest::wait_until(
sub {
eval {
$r = $dbh3->selectrow_arrayref('SHOW TABLES FROM test');
};
return 1 if ($r->[0] || '') eq 'foo';
return 0;
},
0.5,
30,
);
is_deeply(
$r,
['foo'],
'Slave has other db.tbl'
) or die "Timeout waiting for slave";
PerconaTest::wait_for_table($dbh3, "test.foo", "i=9");
PerconaTest::wait_for_table($dbh3, "onlythisdb.t", "i=3");
# Stop the slave, add replicate-do-db to its config, and restart it.
$dbh3->disconnect();
@@ -87,24 +61,26 @@ diag(`echo "replicate-do-db = onlythisdb" >> /tmp/12348/my.sandbox.cnf`);
diag(`/tmp/12348/start >/dev/null`);
$dbh3 = $sb->get_dbh_for('master1');
die "Second sandbox master lost test.foo"
unless -f '/tmp/12348/data/test/foo.frm';
# Make master and slave differ. Because we USE test, this DELETE on
# the master won't replicate to the slave now that replicate-do-db
# is set.
$master_dbh->do('USE test');
$master_dbh->do('DELETE FROM onlythisdb.t WHERE i = 2');
$dbh3->do('INSERT INTO test.foo VALUES (5)');
$master_dbh->do("USE test");
$master_dbh->do("DELETE FROM onlythisdb.t WHERE i = 2");
$dbh3->do("INSERT INTO test.foo VALUES (5)");
$r = $dbh3->selectall_arrayref('SELECT * FROM onlythisdb.t ORDER BY i');
my $r = $dbh3->selectall_arrayref('SELECT * FROM onlythisdb.t ORDER BY i');
is_deeply(
$r,
[[1],[2],[3]],
'do-replicate-db is out of sync before sync'
);
`$trunk/bin/pt-table-sync h=127.1,P=12348,u=msandbox,p=msandbox --sync-to-master --execute --no-check-triggers --ignore-databases sakila,mysql 2>&1`;
output(
sub { pt_table_sync::main("h=127.1,P=12348,u=msandbox,p=msandbox",
qw(--sync-to-master --execute --no-check-triggers),
"--ignore-databases", "sakila,mysql") },
stderr => 1,
);
$r = $dbh3->selectall_arrayref('SELECT * FROM onlythisdb.t ORDER BY i');
is_deeply(
@@ -121,7 +97,7 @@ is_deeply(
);
$dbh3->disconnect();
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
diag(`$trunk/sandbox/stop-sandbox 12348`);
# #############################################################################
# Done.