mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
Fix some lib/ tests.
This commit is contained in:
@@ -73,7 +73,6 @@ SKIP: {
|
||||
p => 'msandbox',
|
||||
t => undef,
|
||||
u => 'msandbox',
|
||||
n => 'h=127.0.0.1,P=12346',
|
||||
server_id => 12346,
|
||||
master_id => 12345,
|
||||
source => 'hosts',
|
||||
@@ -179,7 +178,6 @@ is_deeply(
|
||||
D => undef,
|
||||
A => undef,
|
||||
t => undef,
|
||||
n => 'h=127.0.0.1,P=2900',
|
||||
},
|
||||
'Got master DSN',
|
||||
);
|
||||
@@ -563,7 +561,6 @@ is_deeply(
|
||||
p => 'msandbox',
|
||||
t => undef,
|
||||
u => 'msandbox',
|
||||
n => 'h=127.1,P=12346',
|
||||
},
|
||||
'get_slaves() from DSN table'
|
||||
);
|
||||
|
@@ -2321,7 +2321,7 @@ my $schema_itr = new SchemaIterator(
|
||||
Schema => $schema,
|
||||
);
|
||||
# Init schema.
|
||||
1 while ($schema_itr->next_schema_object());
|
||||
1 while ($schema_itr->next());
|
||||
|
||||
# Notice how c3 and b aren't qualified.
|
||||
is_deeply(
|
||||
|
@@ -47,7 +47,7 @@ my $si = new SchemaIterator (
|
||||
);
|
||||
|
||||
# Init the schema (SchemaIterator calls Schema::add_schema_object()).
|
||||
1 while(defined $si->next_schema_object());
|
||||
1 while(defined $si->next());
|
||||
|
||||
#ok(
|
||||
# $sq->is_duplicate_column('c1')
|
||||
|
@@ -757,15 +757,11 @@ is_deeply(
|
||||
# #############################################################################
|
||||
# Issue 464: Make mk-table-sync do two-way sync
|
||||
# #############################################################################
|
||||
SKIP: {
|
||||
skip "Not tested with MySQL $sandbox_version", 7
|
||||
unless $sandbox_version gt '4.0';
|
||||
|
||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
||||
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||
my $dbh3 = $sb->get_dbh_for('master1');
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 7 unless $dbh;
|
||||
skip 'Cannot connect to second sandbox master', 7 unless $dbh2;
|
||||
skip 'Cannot connect to second sandbox master', 7 unless $dbh3;
|
||||
|
||||
sub set_bidi_callbacks {
|
||||
$sync_chunk->set_callback('same_row', sub {
|
||||
@@ -782,27 +778,27 @@ SKIP: {
|
||||
|
||||
my $cmp = ($left_ts || '') cmp ($right_ts || '');
|
||||
if ( $cmp == -1 ) {
|
||||
MKDEBUG && TableSyncer::_d("right dbh $dbh2 is newer; update left dbh $src_dbh");
|
||||
$ch->set_src('right', $dbh2);
|
||||
MKDEBUG && TableSyncer::_d("right dbh $dbh3 is newer; update left dbh $src_dbh");
|
||||
$ch->set_src('right', $dbh3);
|
||||
$auth_row = $args{rr};
|
||||
$change_dbh = $src_dbh;
|
||||
}
|
||||
elsif ( $cmp == 1 ) {
|
||||
MKDEBUG && TableSyncer::_d("left dbh $src_dbh is newer; update right dbh $dbh2");
|
||||
MKDEBUG && TableSyncer::_d("left dbh $src_dbh is newer; update right dbh $dbh3");
|
||||
$ch->set_src('left', $src_dbh);
|
||||
$auth_row = $args{lr};
|
||||
$change_dbh = $dbh2;
|
||||
$change_dbh = $dbh3;
|
||||
}
|
||||
return ('UPDATE', $auth_row, $change_dbh);
|
||||
});
|
||||
$sync_chunk->set_callback('not_in_right', sub {
|
||||
my ( %args ) = @_;
|
||||
$args{syncer}->{ChangeHandler}->set_src('left', $src_dbh);
|
||||
return 'INSERT', $args{lr}, $dbh2;
|
||||
return 'INSERT', $args{lr}, $dbh3;
|
||||
});
|
||||
$sync_chunk->set_callback('not_in_left', sub {
|
||||
my ( %args ) = @_;
|
||||
$args{syncer}->{ChangeHandler}->set_src('right', $dbh2);
|
||||
$args{syncer}->{ChangeHandler}->set_src('right', $dbh3);
|
||||
return 'INSERT', $args{rr}, $src_dbh;
|
||||
});
|
||||
};
|
||||
@@ -836,8 +832,8 @@ SKIP: {
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.sql');
|
||||
# Load remote data.
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
make_plugins();
|
||||
set_bidi_callbacks();
|
||||
$tbl_struct = $tp->parse($tp->get_create_table($src_dbh, 'bidi', 't'));
|
||||
@@ -846,7 +842,7 @@ SKIP: {
|
||||
$src->{tbl} = 't';
|
||||
$dst->{db} = 'bidi';
|
||||
$dst->{tbl} = 't';
|
||||
$dst->{dbh} = $dbh2; # Must set $dbh2 here and
|
||||
$dst->{dbh} = $dbh3; # Must set $dbh3 here and
|
||||
|
||||
my %args = (
|
||||
src => $src,
|
||||
@@ -855,7 +851,7 @@ SKIP: {
|
||||
cols => [qw(ts)], # Compare only ts col when chunks differ.
|
||||
plugins => $plugins,
|
||||
function => 'SHA1',
|
||||
ChangeHandler => new_ch($dbh2, 0), # here to override $dst_dbh.
|
||||
ChangeHandler => new_ch($dbh3, 0), # here to override $dst_dbh.
|
||||
RowDiff => $rd,
|
||||
chunk_size => 2,
|
||||
);
|
||||
@@ -870,7 +866,7 @@ SKIP: {
|
||||
'Bidirectional sync "master" (chunk size 2)'
|
||||
);
|
||||
|
||||
$res = $dbh2->selectall_arrayref('select * from bidi.t order by id');
|
||||
$res = $dbh3->selectall_arrayref('select * from bidi.t order by id');
|
||||
is_deeply(
|
||||
$res,
|
||||
$bidi_data,
|
||||
@@ -882,11 +878,11 @@ SKIP: {
|
||||
# ########################################################################
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.sql');
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
make_plugins();
|
||||
set_bidi_callbacks();
|
||||
$args{ChangeHandler} = new_ch($dbh2, 0);
|
||||
$args{ChangeHandler} = new_ch($dbh3, 0);
|
||||
@rows = ();
|
||||
|
||||
$syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 10);
|
||||
@@ -898,7 +894,7 @@ SKIP: {
|
||||
'Bidirectional sync "master" (chunk size 10)'
|
||||
);
|
||||
|
||||
$res = $dbh2->selectall_arrayref('select * from bidi.t order by id');
|
||||
$res = $dbh3->selectall_arrayref('select * from bidi.t order by id');
|
||||
is_deeply(
|
||||
$res,
|
||||
$bidi_data,
|
||||
@@ -910,11 +906,11 @@ SKIP: {
|
||||
# ########################################################################
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.sql');
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/table.sql');
|
||||
$sb->load_file('master1', 't/pt-table-sync/samples/bidirectional/remote-1.sql');
|
||||
make_plugins();
|
||||
set_bidi_callbacks();
|
||||
$args{ChangeHandler} = new_ch($dbh2, 0);
|
||||
$args{ChangeHandler} = new_ch($dbh3, 0);
|
||||
@rows = ();
|
||||
|
||||
$syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 100000);
|
||||
@@ -926,7 +922,7 @@ SKIP: {
|
||||
'Bidirectional sync "master" (whole table chunk)'
|
||||
);
|
||||
|
||||
$res = $dbh2->selectall_arrayref('select * from bidi.t order by id');
|
||||
$res = $dbh3->selectall_arrayref('select * from bidi.t order by id');
|
||||
is_deeply(
|
||||
$res,
|
||||
$bidi_data,
|
||||
@@ -936,18 +932,15 @@ SKIP: {
|
||||
# ########################################################################
|
||||
# See TableSyncer.pm for why this is so.
|
||||
# ########################################################################
|
||||
$args{ChangeHandler} = new_ch($dbh2, 1);
|
||||
$args{ChangeHandler} = new_ch($dbh3, 1);
|
||||
throws_ok(
|
||||
sub { $syncer->sync_table(%args, bidirectional => 1, plugins => [$sync_chunk]) },
|
||||
qr/Queueing does not work with bidirectional syncing/,
|
||||
'Queueing does not work with bidirectional syncing'
|
||||
);
|
||||
|
||||
$sb->wipe_clean($dbh2);
|
||||
diag(`$trunk/sandbox/stop-sandbox 12347 >/dev/null &`);
|
||||
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null &`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# #############################################################################
|
||||
# Test with transactions.
|
||||
|
Reference in New Issue
Block a user