~percona-toolkit-dev/percona-toolkit/pt-table-checksum-compatibility-with-pxc-1399789

« back to all changes in this revision

Viewing changes to t/pt-table-checksum/pxc.t

  • Committer: Frank Cizmich
  • Date: 2014-11-18 21:41:23 UTC
  • mfrom: (608.1.31 release-2.2.12)
  • Revision ID: frank.cizmich@percona.com-20141118214123-hyj5wno2onb5wo6o
merged release-2.2.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
   "Dies if no other nodes are found"
82
82
);
83
83
 
 
84
 
 
85
($output, $exit_status) = full_output(
 
86
   sub { pt_table_checksum::main(@args, '--recursion-method', 'none') },
 
87
   stderr => 1,
 
88
);
 
89
 
 
90
ok (
 
91
      $output =~ qr/WARNING/i && !$exit_status,
 
92
      "Warns but doesn't die if --recursion-method=none - issue #1373937"
 
93
);
 
94
 
84
95
for my $args (
85
96
      ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
86
97
      ["using recursion-method=cluster", '--recursion-method', 'cluster']
144
155
   "Node3 not changed"
145
156
);
146
157
 
147
 
for my $args (
148
 
      ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
149
 
      ["using recursion-method=cluster", '--recursion-method', 'cluster']
150
 
   )
151
 
{
152
 
   my $test = shift @$args;
153
 
 
154
 
   $output = output(
155
 
      sub { pt_table_checksum::main(@args,
156
 
         @$args)
157
 
      },
158
 
      stderr => 1,
159
 
   );
160
 
 
161
 
   is(
162
 
      PerconaTest::count_checksum_results($output, 'errors'),
163
 
      0,
164
 
      "1 diff: no errors ($test)"
165
 
   );
166
 
 
167
 
   is(
168
 
      PerconaTest::count_checksum_results($output, 'skipped'),
169
 
      0,
170
 
      "1 diff: no skips ($test)"
171
 
   );
172
 
 
173
 
   is(
174
 
      PerconaTest::count_checksum_results($output, 'diffs'),
175
 
      1,
176
 
      "1 diff: 1 diff ($test)"
177
 
   ) or diag($output);
178
 
 
179
 
   # 11-17T13:02:54      0      1       26       1       0   0.021 test.t
180
 
   like(
181
 
      $output,
182
 
      qr/^\S+\s+  # ts
183
 
         0\s+     # errors
184
 
         1\s+     # diffs
185
 
         26\s+    # rows
186
 
         \d+\s+   # chunks
187
 
         0\s+     # skipped
188
 
         \S+\s+   # time
189
 
         test.t$  # table
190
 
      /xm,
191
 
      "1 diff: it's in test.t ($test)"
192
 
   );
 
158
sub test_recursion_methods {
 
159
   my $same_ids = shift;
 
160
 
 
161
   my ($orig_id_1, $orig_id_2, $orig_id_3);
 
162
 
 
163
   if ($same_ids) {
 
164
      # save original values
 
165
      my $sql = 'SELECT @@server_id';
 
166
      ($orig_id_1) = $node1->selectrow_array($sql);
 
167
      ($orig_id_2) = $node2->selectrow_array($sql);
 
168
      ($orig_id_3) = $node3->selectrow_array($sql);
 
169
      # set server_id  value to 1 on all nodes
 
170
      $sql = 'SET GLOBAL server_id = 1';
 
171
      $node1->do($sql);
 
172
      $node2->do($sql);
 
173
      $node3->do($sql);
 
174
   }
 
175
 
 
176
   for my $args (
 
177
         ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
 
178
         ["using recursion-method=cluster", '--recursion-method', 'cluster']
 
179
      )
 
180
   {
 
181
      my $test = shift @$args;
 
182
      $test = $same_ids ? $test.' - Nodes with different ids' : $test.' - Nodes with same ids';
 
183
 
 
184
      $output = output(
 
185
         sub { pt_table_checksum::main(@args,
 
186
            @$args)
 
187
         },
 
188
         stderr => 1,
 
189
      );
 
190
 
 
191
      is(
 
192
         PerconaTest::count_checksum_results($output, 'errors'),
 
193
         0,
 
194
         "1 diff: no errors ($test)"
 
195
      );
 
196
 
 
197
      is(
 
198
         PerconaTest::count_checksum_results($output, 'skipped'),
 
199
         0,
 
200
         "1 diff: no skips ($test)"
 
201
      );
 
202
 
 
203
      is(
 
204
         PerconaTest::count_checksum_results($output, 'diffs'),
 
205
         1,
 
206
         "1 diff: 1 diff ($test)"
 
207
      ) or diag($output);
 
208
 
 
209
      # 11-17T13:02:54      0      1       26       1       0   0.021 test.t
 
210
      like(
 
211
         $output,
 
212
         qr/^\S+\s+  # ts
 
213
            0\s+     # errors
 
214
            1\s+     # diffs
 
215
            26\s+    # rows
 
216
            \d+\s+   # chunks
 
217
            0\s+     # skipped
 
218
            \S+\s+   # time
 
219
            test.t$  # table
 
220
         /xm,
 
221
         "1 diff: it's in test.t ($test)"
 
222
      );
 
223
   }
 
224
 
 
225
   if ($same_ids) {
 
226
      # reset server_id's to original values
 
227
      $node1->do("SET GLOBAL server_id = $orig_id_1");
 
228
      $node2->do("SET GLOBAL server_id = $orig_id_2");
 
229
      $node3->do("SET GLOBAL server_id = $orig_id_3");
 
230
   }
 
231
 
193
232
}
194
233
 
 
234
# test recursion methods
 
235
test_recursion_methods(0);
 
236
 
 
237
# test recursion methods when all nodes have the same id
 
238
test_recursion_methods(1);
 
239
 
 
240
 
195
241
# #############################################################################
196
242
# cluster, node1 -> slave, run on node1
197
243
# #############################################################################
232
278
   # Wait for the slave to apply the binlogs from node1 (its master).
233
279
   # Then change it so it's not consistent.
234
280
   PerconaTest::wait_for_table($slave_dbh, 'test.t');
235
 
   $sb->wait_for_slaves('cslave1');
 
281
   $sb->wait_for_slaves(master => 'node1', slave => 'cslave1');
236
282
   $slave_dbh->do("update test.t set c='zebra' where c='z'");
237
283
 
238
284
   $output = output(