4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
9
# RowDiff-custom.t tests some of the basic RowDiff functionalities
10
# as RowDiff.t but uses a different Perl lib if the MK_PERL_LIB
11
# environment var is set. This allows us to test these functionalities
12
# against custom versions of DBI, DBD::mysql, etc. If MK_PERL_LIB
13
# is not set, then all these tests are skipped.
17
return bless [], shift;
21
my ( $self, $lr, $rr ) = @_;
26
my ( $self, $lr ) = @_;
27
push @$self, [ 'not in right', $lr];
31
my ( $self, $rr ) = @_;
32
push @$self, [ 'not in left', $rr];
44
# #############################################################################
49
if ( defined $ENV{MK_PERL_LIB} ) {
50
die "The MK_PERL_LIB environment variable is not a valid directory: "
51
. $ENV{MK_PERL_LIB} unless -d $ENV{MK_PERL_LIB};
52
print "# Using Perl lib $ENV{MK_PERL_LIB}\n";
53
use lib ($ENV{MK_PERL_LIB} ? "$ENV{MK_PERL_LIB}" : ());
58
use warnings FATAL => 'all';
61
use English qw(-no_match_vars);
63
use DBD::mysql; # so we can print $DBD::mysql::VERSION
66
plan skip_all => "MK_PERL_LIB env var is not set", 4
67
unless defined $ENV{MK_PERL_LIB};
69
print "# DBI v$DBI::VERSION\n"
70
. "# DBD::mysql v$DBD::mysql::VERSION\n";
79
my $d = new RowDiff(dbh => 1);
80
my $s = new MockSync();
82
my $du = new MySQLDump();
83
my $tp = new TableParser(Quoter => $q);
84
my $dp = new DSNParser(opts=>$dsn_opts);
86
# Connect to sandbox now to make sure it's running.
87
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
88
my $master_dbh = $sb->get_dbh_for('master');
89
my $slave_dbh = $sb->get_dbh_for('slave1');
91
plan skip_all => "Cannot connect to sandbox master";
93
elsif ( !$slave_dbh ) {
94
plan skip_all => "Cannot connect to sandbox slave";
101
$sb->create_dbs($master_dbh, [qw(test)]);
102
$sb->load_file('master', 't/lib/samples/issue_11.sql');
104
my $tbl = $tp->parse(
105
$du->get_create_table($master_dbh, $q, 'test', 'issue_11'));
107
my $left_sth = $master_dbh->prepare('SELECT * FROM test.issue_11');
108
my $right_sth = $slave_dbh->prepare('SELECT * FROM test.issue_11');
109
$left_sth->execute();
110
$right_sth->execute();
121
'no rows (real DBI sth)',
124
$slave_dbh->do('INSERT INTO test.issue_11 VALUES (1,2,3)');
125
$left_sth = $master_dbh->prepare('SELECT * FROM test.issue_11');
126
$right_sth = $slave_dbh->prepare('SELECT * FROM test.issue_11');
127
$left_sth->execute();
128
$right_sth->execute();
139
['not in left', { a => 1, b => 2, c => 3 },],
142
'right only (real DBI sth)',
145
$slave_dbh->do('TRUNCATE TABLE test.issue_11');
146
$master_dbh->do('SET SQL_LOG_BIN=0;');
147
$master_dbh->do('INSERT INTO test.issue_11 VALUES (1,2,3)');
148
$left_sth = $master_dbh->prepare('SELECT * FROM test.issue_11');
149
$right_sth = $slave_dbh->prepare('SELECT * FROM test.issue_11');
150
$left_sth->execute();
151
$right_sth->execute();
162
[ 'not in right', { a => 1, b => 2, c => 3 },],
165
'left only (real DBI sth)',
168
$slave_dbh->do('INSERT INTO test.issue_11 VALUES (1,2,3)');
169
$left_sth = $master_dbh->prepare('SELECT * FROM test.issue_11');
170
$right_sth = $slave_dbh->prepare('SELECT * FROM test.issue_11');
171
$left_sth->execute();
172
$right_sth->execute();
186
'one identical row (real DBI sth)',
189
$sb->wipe_clean($master_dbh);
190
$sb->wipe_clean($slave_dbh);