Merge lp:~percona-toolkit-dev/percona-toolkit/test-pt-archiver-sql-log-bug-903387-2.0 into lp:percona-toolkit/2.0

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 251
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/test-pt-archiver-sql-log-bug-903387-2.0
Merge into: lp:percona-toolkit/2.0
Diff against target: 97 lines (+59/-6)
1 file modified
t/pt-archiver/basics.t (+59/-6)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/test-pt-archiver-sql-log-bug-903387-2.0
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+116959@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 't/pt-archiver/basics.t'
--- t/pt-archiver/basics.t 2012-05-30 20:59:47 +0000
+++ t/pt-archiver/basics.t 2012-07-26 20:38:21 +0000
@@ -18,11 +18,15 @@
1818
19my $dp = new DSNParser(opts=>$dsn_opts);19my $dp = new DSNParser(opts=>$dsn_opts);
20my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);20my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
21my $dbh = $sb->get_dbh_for('master');21my $master_dbh = $sb->get_dbh_for('master');
22my $slave1_dbh = $sb->get_dbh_for('slave1');
2223
23if ( !$dbh ) {24if ( !$master_dbh ) {
24 plan skip_all => 'Cannot connect to sandbox master';25 plan skip_all => 'Cannot connect to sandbox master';
25}26}
27elsif ( !$slave1_dbh ) {
28 plan skip_all => 'Cannot connect to sandbox slave1';
29}
2630
27my $output;31my $output;
28my $rows;32my $rows;
@@ -30,14 +34,14 @@
30my $cmd = "$trunk/bin/pt-archiver";34my $cmd = "$trunk/bin/pt-archiver";
3135
32# Make sure load works.36# Make sure load works.
33$sb->create_dbs($dbh, ['test']);37$sb->create_dbs($master_dbh, ['test']);
34$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');38$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
35$rows = $dbh->selectrow_arrayref('select count(*) from test.table_1')->[0];39$rows = $master_dbh->selectrow_arrayref('select count(*) from test.table_1')->[0];
36if ( ($rows || 0) != 4 ) {40if ( ($rows || 0) != 4 ) {
37 plan skip_all => 'Failed to load tables1-4.sql';41 plan skip_all => 'Failed to load tables1-4.sql';
38}42}
39else {43else {
40 plan tests => 25;44 plan tests => 28;
41}45}
4246
43my @args = qw(--dry-run --where 1=1);47my @args = qw(--dry-run --where 1=1);
@@ -186,7 +190,56 @@
186);190);
187191
188# #############################################################################192# #############################################################################
193# Bug 903387: pt-archiver doesn't honor b=1 flag to create SQL_LOG_BIN statement
194# #############################################################################
195
196$sb->load_file('master', "t/pt-archiver/samples/bulk_regular_insert.sql");
197PerconaTest::wait_for_table($slave1_dbh, "bri.t", "id=10");
198
199my $original_rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
200is_deeply(
201 $original_rows,
202 [
203 [1, 'aa', '11:11:11'],
204 [2, 'bb', '11:11:12'],
205 [3, 'cc', '11:11:13'],
206 [4, 'dd', '11:11:14'],
207 [5, 'ee', '11:11:15'],
208 [6, 'ff', '11:11:16'],
209 [7, 'gg', '11:11:17'],
210 [8, 'hh', '11:11:18'],
211 [9, 'ii', '11:11:19'],
212 [10,'jj', '11:11:10'],
213 ],
214 "Bug 903387: slave has rows"
215);
216
217$output = output(
218 sub { pt_archiver::main(
219 '--source', "D=bri,t=t,F=$cnf,b=1",
220 '--dest', "D=bri,t=t_arch",
221 qw(--where 1=1 --replace --commit-each --bulk-insert --bulk-delete),
222 qw(--limit 10)) },
223);
224
225$rows = $master_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
226is_deeply(
227 $rows,
228 [
229 [10,'jj', '11:11:10'],
230 ],
231 "Bug 903387: rows deleted on master"
232) or diag(Dumper($rows));
233
234$rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
235is_deeply(
236 $rows,
237 $original_rows,
238 "Bug 903387: slave still has rows"
239) or diag(Dumper($rows));
240
241# #############################################################################
189# Done.242# Done.
190# #############################################################################243# #############################################################################
191$sb->wipe_clean($dbh);244$sb->wipe_clean($master_dbh);
192exit;245exit;

Subscribers

People subscribed via source and target branches