mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 21:05:00 +00:00
Make pt-table-sync/binlog_format.t stable.
This commit is contained in:
@@ -10,6 +10,7 @@ use strict;
|
|||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
use Sandbox;
|
use Sandbox;
|
||||||
@@ -29,37 +30,29 @@ elsif ( !$slave_dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox slave';
|
plan skip_all => 'Cannot connect to sandbox slave';
|
||||||
}
|
}
|
||||||
elsif ( !$vp->version_ge($master_dbh, '5.1.5') ) {
|
elsif ( !$vp->version_ge($master_dbh, '5.1.5') ) {
|
||||||
plan skip_all => 'Sandbox master version not >= 5.1';
|
plan skip_all => 'Requires MySQL 5.1 or newer';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 7;
|
plan tests => 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sb->wipe_clean($master_dbh);
|
|
||||||
$sb->wipe_clean($slave_dbh);
|
|
||||||
$sb->create_dbs($master_dbh, ['test']);
|
|
||||||
|
|
||||||
my @args = qw(-F /tmp/12346/my.sandbox.cnf --sync-to-master P=12346 -t test.t);
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Issue 95: Make mk-table-sync force statement-based binlog format on 5.1
|
# Issue 95: Make mk-table-sync force statement-based binlog format on 5.1
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
$master_dbh->do('use test');
|
$sb->create_dbs($master_dbh, ['test']);
|
||||||
$slave_dbh->do('use test');
|
$master_dbh->do('create table test.t (i int, unique index (i))');
|
||||||
|
$master_dbh->do('insert into test.t values (1),(2)');
|
||||||
$master_dbh->do('create table t (i int, unique index (i))');
|
$sb->wait_for_slaves();
|
||||||
$master_dbh->do('insert into t values (1),(2)');
|
$slave_dbh->do('insert into test.t values (3)'); # only on the slaves
|
||||||
|
|
||||||
$slave_dbh->do('insert into t values (3)');
|
|
||||||
PerconaTest::wait_for_table($slave_dbh, 'test.t', 'i=1');
|
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$master_dbh->selectall_arrayref('select * from test.t order by i'),
|
$master_dbh->selectall_arrayref('select * from test.t order by i'),
|
||||||
[[1],[2]],
|
[[1],[2]],
|
||||||
'Data on master before sync'
|
'Data on master before sync'
|
||||||
);
|
);
|
||||||
use Data::Dumper;
|
|
||||||
|
# Slaves have an extra row, something to sync.
|
||||||
my $rows = $slave_dbh->selectall_arrayref('select * from test.t order by i');
|
my $rows = $slave_dbh->selectall_arrayref('select * from test.t order by i');
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$rows,
|
$rows,
|
||||||
@@ -67,7 +60,7 @@ is_deeply(
|
|||||||
'Data on slave before sync'
|
'Data on slave before sync'
|
||||||
) or print Dumper($rows);
|
) or print Dumper($rows);
|
||||||
|
|
||||||
$master_dbh->do('SET GLOBAL binlog_format="ROW"');
|
$master_dbh->do("SET GLOBAL binlog_format='ROW'");
|
||||||
$master_dbh->disconnect();
|
$master_dbh->disconnect();
|
||||||
$master_dbh = $sb->get_dbh_for('master');
|
$master_dbh = $sb->get_dbh_for('master');
|
||||||
|
|
||||||
@@ -79,7 +72,8 @@ is_deeply(
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
output(
|
output(
|
||||||
sub { pt_table_sync::main(@args, qw(--print --execute)) },
|
sub { pt_table_sync::main("h=127.1,P=12346,u=msandbox,p=msandbox",
|
||||||
|
qw(--sync-to-master -t test.t --print --execute)) },
|
||||||
trf => \&remove_traces,
|
trf => \&remove_traces,
|
||||||
),
|
),
|
||||||
"DELETE FROM `test`.`t` WHERE `i`='3' LIMIT 1;
|
"DELETE FROM `test`.`t` WHERE `i`='3' LIMIT 1;
|
||||||
@@ -87,14 +81,20 @@ is(
|
|||||||
"Executed DELETE"
|
"Executed DELETE"
|
||||||
);
|
);
|
||||||
|
|
||||||
sleep 1;
|
wait_until(
|
||||||
|
sub {
|
||||||
|
my $rows = $slave_dbh->selectall_arrayref('select * from test.t');
|
||||||
|
return $rows && @$rows == 2;
|
||||||
|
}
|
||||||
|
) or die "DELETE did not replicate to slave";
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$slave_dbh->selectall_arrayref('select * from test.t'),
|
$slave_dbh->selectall_arrayref('select * from test.t'),
|
||||||
[[1],[2]],
|
[[1],[2]],
|
||||||
'DELETE replicated to slave'
|
'DELETE replicated to slave'
|
||||||
);
|
);
|
||||||
|
|
||||||
$master_dbh->do('SET GLOBAL binlog_format="STATEMENT"');
|
$master_dbh->do("SET GLOBAL binlog_format='STATEMENT'");
|
||||||
$master_dbh->disconnect();
|
$master_dbh->disconnect();
|
||||||
$master_dbh = $sb->get_dbh_for('master');
|
$master_dbh = $sb->get_dbh_for('master');
|
||||||
|
|
||||||
@@ -108,6 +108,5 @@ is_deeply(
|
|||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
$sb->wipe_clean($slave_dbh);
|
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
exit;
|
exit;
|
||||||
|
Reference in New Issue
Block a user