mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-22 19:04:30 +00:00
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:
@@ -313,15 +313,15 @@ sub ok {
|
||||
# Dings a heartbeat on the master, and waits until the slave catches up fully.
|
||||
sub wait_for_slaves {
|
||||
my $self = shift;
|
||||
my $now = time();
|
||||
my $master_dbh = $self->get_dbh_for('master');
|
||||
my $slave2_dbh = $self->get_dbh_for('slave2');
|
||||
$master_dbh->do("update percona_test.sentinel set a=$now where id = 1");
|
||||
my ($ping) = $master_dbh->selectrow_array("SELECT MD5(RAND() + NOW())");
|
||||
$master_dbh->do("UPDATE percona_test.sentinel SET ping='$ping' WHERE id=1");
|
||||
PerconaTest::wait_until(
|
||||
sub {
|
||||
my $then = $slave2_dbh->selectall_arrayref(
|
||||
"select a from percona_test.sentinel where id = 1")->[0]->[0];
|
||||
return $now == $then;
|
||||
my ($pong) = $slave2_dbh->selectrow_array(
|
||||
"SELECT ping FROM percona_test.sentinel WHERE id=1");
|
||||
return $ping eq $pong;
|
||||
}, undef, 300
|
||||
);
|
||||
}
|
||||
|
@@ -291,15 +291,13 @@ case $opt in
|
||||
echo "OK"
|
||||
fi
|
||||
../util/checksum-test-dataset
|
||||
now=$(date +%s);
|
||||
/tmp/12345/use -e 'create table percona_test.sentinel(id int primary key, a int unsigned)';
|
||||
/tmp/12345/use -e "insert into percona_test.sentinel(id, a) values(1, $now)";
|
||||
ping=$(/tmp/12345/use -ss -e "SELECT MD5(RAND() + NOW())")
|
||||
/tmp/12345/use -e "create table percona_test.sentinel(id int primary key, ping varchar(64) not null default '')"
|
||||
/tmp/12345/use -e "insert into percona_test.sentinel(id, ping) values(1, '$ping')";
|
||||
echo -n "Waiting for replication to finish..."
|
||||
while true; do
|
||||
found=$(/tmp/12347/use -ss -e 'select a from percona_test.sentinel where id = 1' 2>/dev/null)
|
||||
if [ "$found" = "$now" ]; then
|
||||
break
|
||||
fi
|
||||
pong=$(/tmp/12347/use -ss -e 'select ping from percona_test.sentinel where id=1' 2>/dev/null)
|
||||
[ "$ping" = "$pong" ] && break
|
||||
echo -n '.'
|
||||
sleep 1
|
||||
done
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user