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
1=== modified file 't/pt-archiver/basics.t'
2--- t/pt-archiver/basics.t 2012-05-30 20:59:47 +0000
3+++ t/pt-archiver/basics.t 2012-07-26 20:38:21 +0000
4@@ -18,11 +18,15 @@
5
6 my $dp = new DSNParser(opts=>$dsn_opts);
7 my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
8-my $dbh = $sb->get_dbh_for('master');
9+my $master_dbh = $sb->get_dbh_for('master');
10+my $slave1_dbh = $sb->get_dbh_for('slave1');
11
12-if ( !$dbh ) {
13+if ( !$master_dbh ) {
14 plan skip_all => 'Cannot connect to sandbox master';
15 }
16+elsif ( !$slave1_dbh ) {
17+ plan skip_all => 'Cannot connect to sandbox slave1';
18+}
19
20 my $output;
21 my $rows;
22@@ -30,14 +34,14 @@
23 my $cmd = "$trunk/bin/pt-archiver";
24
25 # Make sure load works.
26-$sb->create_dbs($dbh, ['test']);
27+$sb->create_dbs($master_dbh, ['test']);
28 $sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
29-$rows = $dbh->selectrow_arrayref('select count(*) from test.table_1')->[0];
30+$rows = $master_dbh->selectrow_arrayref('select count(*) from test.table_1')->[0];
31 if ( ($rows || 0) != 4 ) {
32 plan skip_all => 'Failed to load tables1-4.sql';
33 }
34 else {
35- plan tests => 25;
36+ plan tests => 28;
37 }
38
39 my @args = qw(--dry-run --where 1=1);
40@@ -186,7 +190,56 @@
41 );
42
43 # #############################################################################
44+# Bug 903387: pt-archiver doesn't honor b=1 flag to create SQL_LOG_BIN statement
45+# #############################################################################
46+
47+$sb->load_file('master', "t/pt-archiver/samples/bulk_regular_insert.sql");
48+PerconaTest::wait_for_table($slave1_dbh, "bri.t", "id=10");
49+
50+my $original_rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
51+is_deeply(
52+ $original_rows,
53+ [
54+ [1, 'aa', '11:11:11'],
55+ [2, 'bb', '11:11:12'],
56+ [3, 'cc', '11:11:13'],
57+ [4, 'dd', '11:11:14'],
58+ [5, 'ee', '11:11:15'],
59+ [6, 'ff', '11:11:16'],
60+ [7, 'gg', '11:11:17'],
61+ [8, 'hh', '11:11:18'],
62+ [9, 'ii', '11:11:19'],
63+ [10,'jj', '11:11:10'],
64+ ],
65+ "Bug 903387: slave has rows"
66+);
67+
68+$output = output(
69+ sub { pt_archiver::main(
70+ '--source', "D=bri,t=t,F=$cnf,b=1",
71+ '--dest', "D=bri,t=t_arch",
72+ qw(--where 1=1 --replace --commit-each --bulk-insert --bulk-delete),
73+ qw(--limit 10)) },
74+);
75+
76+$rows = $master_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
77+is_deeply(
78+ $rows,
79+ [
80+ [10,'jj', '11:11:10'],
81+ ],
82+ "Bug 903387: rows deleted on master"
83+) or diag(Dumper($rows));
84+
85+$rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id");
86+is_deeply(
87+ $rows,
88+ $original_rows,
89+ "Bug 903387: slave still has rows"
90+) or diag(Dumper($rows));
91+
92+# #############################################################################
93 # Done.
94 # #############################################################################
95-$sb->wipe_clean($dbh);
96+$sb->wipe_clean($master_dbh);
97 exit;

Subscribers

People subscribed via source and target branches