Fix some lib/ tests.

This commit is contained in:
Daniel Nichter
2011-11-02 10:20:07 -06:00
parent 2e72da5717
commit c45676abf1
4 changed files with 26 additions and 36 deletions

View File

@@ -73,7 +73,6 @@ SKIP: {
p => 'msandbox', p => 'msandbox',
t => undef, t => undef,
u => 'msandbox', u => 'msandbox',
n => 'h=127.0.0.1,P=12346',
server_id => 12346, server_id => 12346,
master_id => 12345, master_id => 12345,
source => 'hosts', source => 'hosts',
@@ -179,7 +178,6 @@ is_deeply(
D => undef, D => undef,
A => undef, A => undef,
t => undef, t => undef,
n => 'h=127.0.0.1,P=2900',
}, },
'Got master DSN', 'Got master DSN',
); );
@@ -563,7 +561,6 @@ is_deeply(
p => 'msandbox', p => 'msandbox',
t => undef, t => undef,
u => 'msandbox', u => 'msandbox',
n => 'h=127.1,P=12346',
}, },
'get_slaves() from DSN table' 'get_slaves() from DSN table'
); );

View File

@@ -2321,7 +2321,7 @@ my $schema_itr = new SchemaIterator(
Schema => $schema, Schema => $schema,
); );
# Init schema. # Init schema.
1 while ($schema_itr->next_schema_object()); 1 while ($schema_itr->next());
# Notice how c3 and b aren't qualified. # Notice how c3 and b aren't qualified.
is_deeply( is_deeply(

View File

@@ -47,7 +47,7 @@ my $si = new SchemaIterator (
); );
# Init the schema (SchemaIterator calls Schema::add_schema_object()). # Init the schema (SchemaIterator calls Schema::add_schema_object()).
1 while(defined $si->next_schema_object()); 1 while(defined $si->next());
#ok( #ok(
# $sq->is_duplicate_column('c1') # $sq->is_duplicate_column('c1')

View File

@@ -757,15 +757,11 @@ is_deeply(
# ############################################################################# # #############################################################################
# Issue 464: Make mk-table-sync do two-way sync # Issue 464: Make mk-table-sync do two-way sync
# ############################################################################# # #############################################################################
SKIP: { diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
skip "Not tested with MySQL $sandbox_version", 7 my $dbh3 = $sb->get_dbh_for('master1');
unless $sandbox_version gt '4.0';
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
my $dbh2 = $sb->get_dbh_for('slave2');
SKIP: { SKIP: {
skip 'Cannot connect to sandbox master', 7 unless $dbh; 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 { sub set_bidi_callbacks {
$sync_chunk->set_callback('same_row', sub { $sync_chunk->set_callback('same_row', sub {
@@ -782,27 +778,27 @@ SKIP: {
my $cmp = ($left_ts || '') cmp ($right_ts || ''); my $cmp = ($left_ts || '') cmp ($right_ts || '');
if ( $cmp == -1 ) { if ( $cmp == -1 ) {
MKDEBUG && TableSyncer::_d("right dbh $dbh2 is newer; update left dbh $src_dbh"); MKDEBUG && TableSyncer::_d("right dbh $dbh3 is newer; update left dbh $src_dbh");
$ch->set_src('right', $dbh2); $ch->set_src('right', $dbh3);
$auth_row = $args{rr}; $auth_row = $args{rr};
$change_dbh = $src_dbh; $change_dbh = $src_dbh;
} }
elsif ( $cmp == 1 ) { 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); $ch->set_src('left', $src_dbh);
$auth_row = $args{lr}; $auth_row = $args{lr};
$change_dbh = $dbh2; $change_dbh = $dbh3;
} }
return ('UPDATE', $auth_row, $change_dbh); return ('UPDATE', $auth_row, $change_dbh);
}); });
$sync_chunk->set_callback('not_in_right', sub { $sync_chunk->set_callback('not_in_right', sub {
my ( %args ) = @_; my ( %args ) = @_;
$args{syncer}->{ChangeHandler}->set_src('left', $src_dbh); $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 { $sync_chunk->set_callback('not_in_left', sub {
my ( %args ) = @_; my ( %args ) = @_;
$args{syncer}->{ChangeHandler}->set_src('right', $dbh2); $args{syncer}->{ChangeHandler}->set_src('right', $dbh3);
return 'INSERT', $args{rr}, $src_dbh; 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/table.sql');
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.sql'); $sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.sql');
# Load remote data. # Load remote data.
$sb->load_file('slave2', 't/pt-table-sync/samples/bidirectional/table.sql'); $sb->load_file('master1', '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/remote-1.sql');
make_plugins(); make_plugins();
set_bidi_callbacks(); set_bidi_callbacks();
$tbl_struct = $tp->parse($tp->get_create_table($src_dbh, 'bidi', 't')); $tbl_struct = $tp->parse($tp->get_create_table($src_dbh, 'bidi', 't'));
@@ -846,7 +842,7 @@ SKIP: {
$src->{tbl} = 't'; $src->{tbl} = 't';
$dst->{db} = 'bidi'; $dst->{db} = 'bidi';
$dst->{tbl} = 't'; $dst->{tbl} = 't';
$dst->{dbh} = $dbh2; # Must set $dbh2 here and $dst->{dbh} = $dbh3; # Must set $dbh3 here and
my %args = ( my %args = (
src => $src, src => $src,
@@ -855,7 +851,7 @@ SKIP: {
cols => [qw(ts)], # Compare only ts col when chunks differ. cols => [qw(ts)], # Compare only ts col when chunks differ.
plugins => $plugins, plugins => $plugins,
function => 'SHA1', function => 'SHA1',
ChangeHandler => new_ch($dbh2, 0), # here to override $dst_dbh. ChangeHandler => new_ch($dbh3, 0), # here to override $dst_dbh.
RowDiff => $rd, RowDiff => $rd,
chunk_size => 2, chunk_size => 2,
); );
@@ -870,7 +866,7 @@ SKIP: {
'Bidirectional sync "master" (chunk size 2)' '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( is_deeply(
$res, $res,
$bidi_data, $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/table.sql');
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.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('master1', '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/remote-1.sql');
make_plugins(); make_plugins();
set_bidi_callbacks(); set_bidi_callbacks();
$args{ChangeHandler} = new_ch($dbh2, 0); $args{ChangeHandler} = new_ch($dbh3, 0);
@rows = (); @rows = ();
$syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 10); $syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 10);
@@ -898,7 +894,7 @@ SKIP: {
'Bidirectional sync "master" (chunk size 10)' '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( is_deeply(
$res, $res,
$bidi_data, $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/table.sql');
$sb->load_file('master', 't/pt-table-sync/samples/bidirectional/master-data.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('master1', '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/remote-1.sql');
make_plugins(); make_plugins();
set_bidi_callbacks(); set_bidi_callbacks();
$args{ChangeHandler} = new_ch($dbh2, 0); $args{ChangeHandler} = new_ch($dbh3, 0);
@rows = (); @rows = ();
$syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 100000); $syncer->sync_table(%args, plugins => [$sync_chunk], chunk_size => 100000);
@@ -926,7 +922,7 @@ SKIP: {
'Bidirectional sync "master" (whole table chunk)' '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( is_deeply(
$res, $res,
$bidi_data, $bidi_data,
@@ -936,18 +932,15 @@ SKIP: {
# ######################################################################## # ########################################################################
# See TableSyncer.pm for why this is so. # See TableSyncer.pm for why this is so.
# ######################################################################## # ########################################################################
$args{ChangeHandler} = new_ch($dbh2, 1); $args{ChangeHandler} = new_ch($dbh3, 1);
throws_ok( throws_ok(
sub { $syncer->sync_table(%args, bidirectional => 1, plugins => [$sync_chunk]) }, sub { $syncer->sync_table(%args, bidirectional => 1, plugins => [$sync_chunk]) },
qr/Queueing does not work with bidirectional syncing/, qr/Queueing does not work with bidirectional syncing/,
'Queueing does not work with bidirectional syncing' 'Queueing does not work with bidirectional syncing'
); );
$sb->wipe_clean($dbh2); diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null &`);
diag(`$trunk/sandbox/stop-sandbox 12347 >/dev/null &`);
} }
}
# ############################################################################# # #############################################################################
# Test with transactions. # Test with transactions.