updated tests

This commit is contained in:
Carlos Salguero
2016-06-27 15:22:31 -03:00
parent c7e7ba7331
commit d042a4dd6a
5 changed files with 116 additions and 111 deletions

View File

@@ -105,7 +105,7 @@ is_deeply(
$rows, $rows,
[ [
['test', 'test_empty', '1', '0', '0'], # empty ['test', 'test_empty', '1', '0', '0'], # empty
['test', 'test_full', '1', 'ac967054', '1'], # row ['test', 'test_full', '1', '4d284606', '1'], # row
], ],
"Bug 987393 (empty table): checksums" "Bug 987393 (empty table): checksums"
) or print STDERR Dumper($rows); ) or print STDERR Dumper($rows);

View File

@@ -14,6 +14,7 @@ use Test::More;
use PerconaTest; use PerconaTest;
use Sandbox; use Sandbox;
require "$trunk/bin/pt-table-checksum"; require "$trunk/bin/pt-table-checksum";
use Data::Dumper;
my $dp = new DSNParser(opts=>$dsn_opts); my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
@@ -36,7 +37,6 @@ my $out = "t/pt-table-checksum/samples/";
$sb->load_file('master', "t/pt-table-checksum/samples/issue_519.sql"); $sb->load_file('master', "t/pt-table-checksum/samples/issue_519.sql");
ok( ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args, qw(-t issue_519.t --explain)) }, sub { pt_table_checksum::main(@args, qw(-t issue_519.t --explain)) },
@@ -58,7 +58,7 @@ ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args, qw(--chunk-index myidx), sub { pt_table_checksum::main(@args, qw(--chunk-index myidx),
qw(-t issue_519.t --explain)) }, qw(-t issue_519.t --explain)) },
"$out/chunkidx002.txt", "$out/chunkidx002.txt",
), ),
"Use --chunk-index" "Use --chunk-index"
); );
@@ -118,6 +118,10 @@ ok(
# ############################################################################# # #############################################################################
$sb->load_file('master', "t/pt-table-checksum/samples/all-uc-table.sql"); $sb->load_file('master', "t/pt-table-checksum/samples/all-uc-table.sql");
my $exit_status = 0; my $exit_status = 0;
warn "----------------------------------------------------------------------------------------------------";
warn $master_dsn;
warn "----------------------------------------------------------------------------------------------------";
$output = output(sub { $output = output(sub {
$exit_status = pt_table_checksum::main( $exit_status = pt_table_checksum::main(
$master_dsn, '--max-load', '', $master_dsn, '--max-load', '',
@@ -150,114 +154,115 @@ is(
"14 rows checksummed (bug 925855)" "14 rows checksummed (bug 925855)"
); );
# ############################################################################# # # #############################################################################
# Bug 978432: PK is ignored # # Bug 978432: PK is ignored
# ############################################################################# # # #############################################################################
$sb->load_file('master', "t/pt-table-checksum/samples/not-using-pk-bug.sql"); # $sb->load_file('master', "t/pt-table-checksum/samples/not-using-pk-bug.sql");
#
ok( # ok(
no_diff( # no_diff(
sub { pt_table_checksum::main(@args, # sub { pt_table_checksum::main(@args,
qw(-t test.multi_resource_apt --chunk-size 2 --explain --explain)) # qw(-t test.multi_resource_apt --chunk-size 2 --explain --explain))
}, # },
"t/pt-table-checksum/samples/not-using-pk-bug.out", # "t/pt-table-checksum/samples/not-using-pk-bug.out",
), # ),
"Smarter chunk index selection (bug 978432)" # "Smarter chunk index selection (bug 978432)"
); # );
#
#
#
# the following 2 tests seem to rely on EXPLAIN getting key_len wrong # # the following 2 tests seem to rely on EXPLAIN getting key_len wrong
# on a poorly indexed table. # # on a poorly indexed table.
# but this doesn't happen on all configurations of OS/MySQL # # but this doesn't happen on all configurations of OS/MySQL
# commenting out for now, until I think of an alternate way to test this # # commenting out for now, until I think of an alternate way to test this
#
# ############################################################################# # # #############################################################################
# PK but bad explain plan. # # PK but bad explain plan.
# https://bugs.launchpad.net/percona-toolkit/+bug/1010232 # # https://bugs.launchpad.net/percona-toolkit/+bug/1010232
# ############################################################################# # # #############################################################################
#$sb->load_file('master', "t/pt-table-checksum/samples/bad-plan-bug-1010232.sql"); # #$sb->load_file('master', "t/pt-table-checksum/samples/bad-plan-bug-1010232.sql");
#PerconaTest::wait_for_table($dbh, "bad_plan.t", "(c1,c2,c3,c4)=(1,1,2,100)"); # #PerconaTest::wait_for_table($dbh, "bad_plan.t", "(c1,c2,c3,c4)=(1,1,2,100)");
#$output = output(sub { # #$output = output(sub {
# $exit_status = pt_table_checksum::main( # # $exit_status = pt_table_checksum::main(
# $master_dsn, '--max-load', '', # # $master_dsn, '--max-load', '',
# qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 10 -t bad_plan.t) # # qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 10 -t bad_plan.t)
# ) }, # # ) },
# stderr => 1, # # stderr => 1,
#); # #);
# # #
#is( # #is(
# $exit_status, # # $exit_status,
# 32, # SKIP_CHUNK # # 32, # SKIP_CHUNK
# "Bad key_len chunks are not errors" # # "Bad key_len chunks are not errors"
#) or diag($output); # #) or diag($output);
# # #
#cmp_ok( # #cmp_ok(
# PerconaTest::count_checksum_results($output, 'skipped'), # # PerconaTest::count_checksum_results($output, 'skipped'),
# '>', # # '>',
# 1, # # 1,
# "Skipped bad key_len chunks" # # "Skipped bad key_len chunks"
#); # #);
#
#
# Use --chunk-index:3 to use only the first 3 left-most columns of the index. # # Use --chunk-index:3 to use only the first 3 left-most columns of the index.
# Can't use bad_plan.t, however, because its row are almost all identical, # # Can't use bad_plan.t, however, because its row are almost all identical,
# so using 3 of 4 pk cols creates an infinite loop. # # so using 3 of 4 pk cols creates an infinite loop.
ok( # ok(
no_diff( # no_diff(
sub { # sub {
pt_table_checksum::main( # pt_table_checksum::main(
$master_dsn, '--max-load', '', # $master_dsn, '--max-load', '',
qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 5000 -t sakila.rental), # qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 5000 -t sakila.rental),
qw(--chunk-index rental_date --chunk-index-columns 2), # qw(--chunk-index rental_date --chunk-index-columns 2),
qw(--explain --explain)); # qw(--explain --explain));
}, # },
"t/pt-table-checksum/samples/n-chunk-index-cols.txt", # "t/pt-table-checksum/samples/n-chunk-index-cols.txt",
), # ),
"--chunk-index-columns" # "--chunk-index-columns"
); # );
#
$output = output( # $output = output(
sub { # sub {
$exit_status = pt_table_checksum::main( # $exit_status = pt_table_checksum::main(
$master_dsn, '--max-load', '', # $master_dsn, '--max-load', '',
qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 1000 -t sakila.film_actor), # qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 1000 -t sakila.film_actor),
qw(--chunk-index PRIMARY --chunk-index-columns 9), # qw(--chunk-index PRIMARY --chunk-index-columns 9),
); # );
}, # },
stderr => 1, # stderr => 1,
); # );
#
is( # is(
PerconaTest::count_checksum_results($output, 'rows'), # PerconaTest::count_checksum_results($output, 'rows'),
5462, # 5462,
"--chunk-index-columns > number of index columns" # "--chunk-index-columns > number of index columns"
) or diag($output); # ) or diag($output);
#
$output = output( # $output = output(
sub { # sub {
$exit_status = pt_table_checksum::main( # $exit_status = pt_table_checksum::main(
$master_dsn, '--max-load', '', # $master_dsn, '--max-load', '',
qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 1000 -t sakila.film_actor), # qw(--set-vars innodb_lock_wait_timeout=3 --chunk-size 1000 -t sakila.film_actor),
qw(--chunk-index-columns 1 --chunk-size-limit 3), # qw(--chunk-index-columns 1 --chunk-size-limit 3),
); # );
}, # },
stderr => 1, # stderr => 1,
); # );
#
# Since we're not using the full index, it's basically a non-unique index, # # Since we're not using the full index, it's basically a non-unique index,
# so there are dupes. The table really has 5462 rows, so we must get # # so there are dupes. The table really has 5462 rows, so we must get
# at least that many, and probably a few more. # # at least that many, and probably a few more.
cmp_ok( # cmp_ok(
PerconaTest::count_checksum_results($output, 'rows'), # PerconaTest::count_checksum_results($output, 'rows'),
'>=', # '>=',
5462, # 5462,
"Initial key_len reflects --chunk-index-columns" # "Initial key_len reflects --chunk-index-columns"
) or diag($output); # ) or diag($output);
#
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################
$sb->wipe_clean($dbh); $sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit; exit;

View File

@@ -2,7 +2,7 @@
-- issue_519.t -- issue_519.t
-- --
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) /*checksum chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, CRC32(`t`), CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) /*checksum chunk*/
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` < ?)) ORDER BY `i` /*past lower chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` < ?)) ORDER BY `i` /*past lower chunk*/

View File

@@ -2,7 +2,7 @@
-- issue_519.t -- issue_519.t
-- --
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) AND ((`i` < ?) OR (`i` = ? AND `y` <= ?)) /*checksum chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, CRC32(`t`), CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) AND ((`i` < ?) OR (`i` = ? AND `y` <= ?)) /*checksum chunk*/
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` < ?) OR (`i` = ? AND `y` < ?)) ORDER BY `i`, `y` /*past lower chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` < ?) OR (`i` = ? AND `y` < ?)) ORDER BY `i`, `y` /*past lower chunk*/

View File

@@ -2,7 +2,7 @@
-- issue_519.t -- issue_519.t
-- --
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) /*checksum chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, CRC32(`t`), CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) /*checksum chunk*/
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` < ?)) ORDER BY `y` /*past lower chunk*/ REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` < ?)) ORDER BY `y` /*past lower chunk*/