Skip to content

Commit 51bc8c2

Browse files
committed
PT-2156 - Fix tests for lib
- Updated test t/lib/TableChecksum.t so it reflects changes, introduced in the fix for PT-2016 - Updated test t/lib/RowChecksum.t so it reflects changes added to in the fix for PT-2138: UTF8 support - Uncommented SQL in sandbox/slave_channels.sql that made t/lib/MasterSlave.t to fail - Added check for undef into t/pt-archiver/archive_using_channels.t - Updated lib/Cxn.pm so it uses $dbh->{Active} after issue with the ping() call, reported at perl5-dbi/DBD-mysql#306
1 parent 69a9933 commit 51bc8c2

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

lib/Cxn.pm

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ sub connect {
123123
my $dp = $self->{DSNParser};
124124

125125
my $dbh = $self->{dbh};
126-
if ( !$dbh || !$dbh->ping() ) {
126+
# We cannot use $dbh->ping() here due to https://github.com/perl5-dbi/DBD-mysql/issues/306
127+
if ( !$dbh || !$dbh->{Active} ) {
127128
# Ask for password once.
128129
if ( $self->{ask_pass} && !$self->{asked_for_pass} && !defined $dsn->{p} ) {
129130
$dsn->{p} = OptionParser::prompt_noecho("Enter MySQL password: ");
@@ -160,7 +161,7 @@ sub set_dbh {
160161
# created the dbh probably didn't set what we set here. For example,
161162
# MasterSlave makes dbhs when finding slaves, but it doesn't set
162163
# anything.
163-
if ( $self->{dbh} && $self->{dbh} == $dbh && $self->{dbh_set} ) {
164+
if ( $self->{dbh} && $self->{dbh} == $dbh && $self->{dbh_set}) {
164165
PTDEBUG && _d($dbh, 'Already set dbh');
165166
return $dbh;
166167
}

sandbox/slave_channels.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ SET @@GLOBAL.GTID_MODE = ON;
88

99
CHANGE MASTER TO master_host='127.0.0.1', master_port=12345, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan1';
1010

11-
-- CHANGE MASTER TO master_host='127.0.0.1', master_port=12346, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan2';
11+
CHANGE MASTER TO master_host='127.0.0.1', master_port=12346, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan2';
1212

1313
START SLAVE for channel 'masterchan1';
14-
-- START SLAVE for channel 'masterchan2';
14+
START SLAVE for channel 'masterchan2';
1515

t/lib/RowChecksum.t

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ is(
128128
),
129129
q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, `original_language_id`,}
130130
.q{ `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`,}
131-
.q{ UNIX_TIMESTAMP(`last_update`) AS `last_update`, SHA1(CONCAT_WS('#', `film_id`, `title`,}
131+
.q{ UNIX_TIMESTAMP(`last_update`) AS `last_update`, SHA1(CONCAT_WS('#', `film_id`, convert(`title` using utf8mb4),}
132132
.q{ CRC32(`description`), `release_year`, `language_id`, `original_language_id`, `rental_duration`,}
133-
.q{ `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, }
133+
.q{ `rental_rate`, `length`, `replacement_cost`, convert(`rating` using utf8mb4), convert(`special_features` using utf8mb4), }
134134
.q{UNIX_TIMESTAMP(`last_update`), CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
135135
.q{ISNULL(`original_language_id`), ISNULL(`length`), ISNULL(`rating`), ISNULL(`special_features`))))},
136136
'SHA1 query for sakila.film',
@@ -180,7 +180,7 @@ is(
180180
tbl => $tbl,
181181
func => 'SHA1',
182182
),
183-
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, `title`))},
183+
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, convert(`title` using utf8mb4)))},
184184
'Separator',
185185
);
186186

@@ -191,7 +191,7 @@ is(
191191
tbl => $tbl,
192192
func => 'SHA1',
193193
),
194-
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, `title`))},
194+
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, convert(`title` using utf8mb4)))},
195195
'Bad separator',
196196
);
197197

@@ -204,7 +204,7 @@ is(
204204
cols => [qw(film_id title)],
205205
sep => "'''",
206206
),
207-
q{`film_id`, `title`, SHA1(CONCAT_WS('#', `film_id`, `title`))},
207+
q{`film_id`, `title`, SHA1(CONCAT_WS('#', `film_id`, convert(`title` using utf8mb4)))},
208208
'Really bad separator',
209209
);
210210

t/lib/TableChecksum.t

+7-7
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ is (
229229
function => 'SHA1',
230230
tbl_struct => $t,
231231
),
232-
q{`film_id`, `title`, `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
232+
q{`film_id`, `title`, CRC32(`description`) AS `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
233233
. q{SHA1(CONCAT_WS('#', }
234-
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
234+
. q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, }
235235
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
236236
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
237237
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
@@ -245,9 +245,9 @@ is (
245245
function => 'FNV_64',
246246
tbl_struct => $t,
247247
),
248-
q{`film_id`, `title`, `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
248+
q{`film_id`, `title`, CRC32(`description`) AS `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
249249
. q{FNV_64(}
250-
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
250+
. q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, }
251251
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
252252
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0)},
253253
'FNV_64 query for sakila.film',
@@ -490,7 +490,7 @@ is (
490490
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
491491
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
492492
. q{SHA1(CONCAT(@crc, SHA1(CONCAT_WS('#', }
493-
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
493+
. q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, }
494494
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
495495
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
496496
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
@@ -514,7 +514,7 @@ is (
514514
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
515515
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
516516
. q{CONV(CAST(FNV_64(CONCAT(@crc, FNV_64(}
517-
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
517+
. q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, }
518518
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
519519
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0}
520520
. q{))) AS UNSIGNED), 10, 16))), 16), 0) AS crc }
@@ -559,7 +559,7 @@ is (
559559
. q{SELECT ?, ?, /*CHUNK_NUM*/ ?, COUNT(*) AS cnt, }
560560
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
561561
. q{SHA1(CONCAT(@crc, SHA1(CONCAT_WS('#', }
562-
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
562+
. q{`film_id`, `title`, CRC32(`description`), `release_year`, `language_id`, }
563563
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
564564
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
565565
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }

t/pt-archiver/archive_using_channels.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ $output = output(
7676
sub { $exit_status = pt_archiver::main(@args) },
7777
stderr => 1,
7878
);
79-
diag("Exit status: $exit_status");
79+
diag("Exit status: $exit_status") if ($exit_status);
8080
diag($output);
8181

8282
isnt(

0 commit comments

Comments
 (0)