mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
PT-2159 - Fix tests for pt-duplicate-key-checker (#595)
Added transformation to test results, so they work with deprecations, introduced in 8.0
This commit is contained in:
@@ -32,11 +32,30 @@ my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
my $transform_int = undef;
|
||||
# In version 8.0 integer display width is deprecated and not shown in the outputs.
|
||||
# So we need to transform our samples.
|
||||
if ($sandbox_version ge '8.0') {
|
||||
$transform_int = sub {
|
||||
my $txt = slurp_file(shift);
|
||||
$txt =~ s/int\(\d{1,2}\)/int/g;
|
||||
print $txt;
|
||||
};
|
||||
}
|
||||
|
||||
$output = `$cmd -d mysql -t columns_priv -v`;
|
||||
like($output,
|
||||
qr/PRIMARY \(`Host`,`Db`,`User`,`Table_name`,`Column_name`\)/,
|
||||
'Finds mysql.columns_priv PK'
|
||||
);
|
||||
# In version 8.0 order of columns in the index changed
|
||||
if ($sandbox_version ge '8.0') {
|
||||
like($output,
|
||||
qr/PRIMARY \(`Host`,`User`,`Db`,`Table_name`,`Column_name`\)/,
|
||||
'Finds mysql.columns_priv PK'
|
||||
);
|
||||
} else {
|
||||
like($output,
|
||||
qr/PRIMARY \(`Host`,`Db`,`User`,`Table_name`,`Column_name`\)/,
|
||||
'Finds mysql.columns_priv PK'
|
||||
);
|
||||
}
|
||||
|
||||
is(`$cmd -d test --nosummary`, '', 'No dupes on clean sandbox');
|
||||
|
||||
@@ -45,21 +64,27 @@ $sb->load_file('master', 't/lib/samples/dupe_key.sql', 'test');
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test)) },
|
||||
"$sample/basic_output.txt"),
|
||||
'Default output'
|
||||
"$sample/basic_output.txt",
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
'Default output',
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test --nosql)) },
|
||||
"$sample/nosql_output.txt"),
|
||||
"$sample/nosql_output.txt",
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
'--nosql'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test --nosummary)) },
|
||||
"$sample/nosummary_output.txt"),
|
||||
"$sample/nosummary_output.txt",
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
'--nosummary'
|
||||
);
|
||||
|
||||
@@ -69,7 +94,8 @@ ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test -t UPPER_TEST)) },
|
||||
($sandbox_version ge '5.1' ? "$sample/uppercase_names-51.txt"
|
||||
: "$sample/uppercase_names.txt")
|
||||
: "$sample/uppercase_names.txt"),
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
'Issue 306 crash on uppercase column names'
|
||||
);
|
||||
@@ -97,9 +123,10 @@ $sb->load_file('master', 't/lib/samples/dupekeys/dupe-cluster-bug-894140.sql', '
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test)) },
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d test)) },
|
||||
"$sample/bug-894140.txt",
|
||||
sed => [ "-e 's/ */ /g'" ],
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
"Bug 894140"
|
||||
);
|
||||
|
@@ -30,6 +30,17 @@ my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
my $transform_int = undef;
|
||||
# In version 8.0 integer display width is deprecated and not shown in the outputs.
|
||||
# So we need to transform our samples.
|
||||
if ($sandbox_version ge '8.0') {
|
||||
$transform_int = sub {
|
||||
my $txt = slurp_file(shift);
|
||||
$txt =~ s/int\(\d{1,2}\)/int/g;
|
||||
print $txt;
|
||||
};
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Issue 295: Enhance rules for clustered keys in mk-duplicate-key-checker
|
||||
# #############################################################################
|
||||
@@ -38,7 +49,8 @@ ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d issue_295)) },
|
||||
($sandbox_version ge '5.1' ? "$sample/issue_295-51.txt"
|
||||
: "$sample/issue_295.txt")
|
||||
: "$sample/issue_295.txt"),
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
"Shorten, not remove, clustered dupes"
|
||||
) or diag($test_diff);
|
||||
|
@@ -33,6 +33,17 @@ my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['issue_1192']);
|
||||
|
||||
my $transform_int = undef;
|
||||
# In version 8.0 integer display width is deprecated and not shown in the outputs.
|
||||
# So we need to transform our samples.
|
||||
if ($sandbox_version ge '8.0') {
|
||||
$transform_int = sub {
|
||||
my $txt = slurp_file(shift);
|
||||
$txt =~ s/int\(\d{1,2}\)/int/g;
|
||||
print $txt;
|
||||
};
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Issue 1192: DROP/ADD leaves structure unchanged
|
||||
# #############################################################################
|
||||
@@ -43,6 +54,7 @@ ok(
|
||||
"$cmd -d issue_1192 --no-summary",
|
||||
"t/pt-duplicate-key-checker/samples/issue_1192.txt",
|
||||
sed => ["'s/ (/ (/g'"],
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
"Keys are sorted lc so left-prefix magic works (issue 1192)"
|
||||
);
|
||||
|
@@ -33,6 +33,17 @@ my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
my $transform_int = undef;
|
||||
# In version 8.0 integer display width is deprecated and not shown in the outputs.
|
||||
# So we need to transform our samples.
|
||||
if ($sandbox_version ge '8.0') {
|
||||
$transform_int = sub {
|
||||
my $txt = slurp_file(shift);
|
||||
$txt =~ s/int\(\d{1,2}\)/int/g;
|
||||
print $txt;
|
||||
};
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Issue 331: mk-duplicate-key-checker crashes getting size of foreign keys
|
||||
# #############################################################################
|
||||
@@ -41,7 +52,8 @@ $sb->load_file('master', 't/pt-duplicate-key-checker/samples/issue_331.sql', 'te
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_duplicate_key_checker::main(@args, qw(-d issue_331)) },
|
||||
't/pt-duplicate-key-checker/samples/issue_331.txt'
|
||||
't/pt-duplicate-key-checker/samples/issue_331.txt',
|
||||
transform_sample => $transform_int
|
||||
),
|
||||
'Issue 331 crash on fks'
|
||||
) or diag($test_diff);
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# UNIQUE KEY `domain` (`domain`),
|
||||
# UNIQUE KEY `unique_key_domain` (`domain`)
|
||||
# Column types:
|
||||
# `domain` varchar(175) character set utf8 collate utf8_bin not null
|
||||
# `domain` varchar(175) character set utf8mb3 collate utf8mb3_bin not null
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`domains` DROP INDEX `domain`;
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# UNIQUE KEY `domain` (`domain`),
|
||||
# UNIQUE KEY `unique_key_domain` (`domain`)
|
||||
# Column types:
|
||||
# `domain` varchar(175) character set utf8 collate utf8_bin not null
|
||||
# `domain` varchar(175) character set utf8mb3 collate utf8mb3_bin not null
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`domains` DROP INDEX `domain`;
|
||||
|
||||
|
Reference in New Issue
Block a user