Remove pt-table-checksum tests which are no longer applicable.

This commit is contained in:
Daniel Nichter
2011-09-29 16:04:34 -06:00
parent 78b4f36d71
commit 72d71a84da
11 changed files with 0 additions and 974 deletions

View File

@@ -1,106 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
my $slave_dbh = $sb->get_dbh_for('slave1');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 6;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf -d test -t checksum_test 127.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
# Check --since with --arg-table. The value in the --arg-table table
# ought to override the --since passed on the command-line.
$output = `$cmd --arg-table test.argtest --since 20 --explain 2>&1`;
unlike($output, qr/`a`>='20'/, 'Argtest overridden');
like($output, qr/`a`>='1'/, 'Argtest set to something else');
# Make sure that --arg-table table has only legally allowed columns in it
$output = `$cmd --arg-table test.argtest2 2>&1`;
like($output, qr/Column foobar .from test.argtest2/, 'Argtest with bad column');
# #############################################################################
# Issue 467: overridable arguments with --arg-table
# #############################################################################
# This block of actions is historical, before mk-table-checksum.t
# was modularized. In some forgotten way, it sets up the conditions
# for the actual test below.
$sb->load_file('master', 't/pt-table-checksum/samples/issue_122.sql');
$sb->load_file('master', 't/pt-table-checksum/samples/issue_94.sql');
`$cmd --arg-table test.argtable --save-since -d test -t issue_122 --chunk-size 2`;
$master_dbh->do("INSERT INTO test.issue_122 VALUES (null,'a'),(null,'b')");
`$cmd --arg-table test.argtable --save-since -d test -t issue_122 --chunk-size 2`;
$master_dbh->do('ALTER TABLE test.argtable ADD COLUMN (modulo INT, offset INT, `chunk-size` INT)');
$master_dbh->do("TRUNCATE TABLE test.argtable");
# Two different args for two different tables. Because issue_122 uses
# --chunk-size, it will use the BIT_XOR algo. And issue_94 uses no opts
# so it will use the CHECKSUM algo.
$master_dbh->do("INSERT INTO test.argtable (db, tbl, since, modulo, offset, `chunk-size`) VALUES ('test', 'issue_122', NULL, 2, 1, 2)");
$master_dbh->do("INSERT INTO test.argtable (db, tbl, since, modulo, offset, `chunk-size`) VALUES ('test', 'issue_94', NULL, NULL, NULL, NULL)");
$master_dbh->do("INSERT INTO test.issue_122 VALUES (3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(9,'i'),(10,'j')");
$output = `$cmd -d test -t issue_122,issue_94 --arg-table test.argtable | diff $trunk/t/pt-table-checksum/samples/issue_467.txt -`;
is(
$output,
'',
'chunk-size, modulo and offset in argtable (issue 467)'
);
# #############################################################################
# Issue 922: mk-table-checksum --arg-table causes false positive results
# #############################################################################
SKIP: {
skip 'issue 922', 2 unless $slave_dbh;
$sb->wipe_clean($master_dbh);
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', "t/pt-table-checksum/samples/issue_922.sql");
$sb->load_file('master', "t/pt-table-checksum/samples/arg-table.sql");
$master_dbh->do('insert into test.args values ("test", "t")');
is_deeply(
$master_dbh->selectall_arrayref('select * from test.t order by i'),
[[1,'aa'],[2,'ab'],[3,'ac'],[4,'ad'],[5,'zz'],[6,'zb']],
'Master has all rows'
);
is_deeply(
$slave_dbh->selectall_arrayref('select * from test.t order by i'),
[[1,'aa'],[2,'ab'],[3,'ac'],[4,'ad']],
'Slave missing 2 rows'
);
}
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,162 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $vp = new VersionParser();
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 14;
}
my ($output, $output2);
my $cnf ='/tmp/12345/my.sandbox.cnf';
my @args = ('-F', $cnf, qw(-d test -t checksum_test 127.0.0.1));
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
# Test basic functionality with defaults
$output = output(sub { pt_table_checksum::main(@args) } );
like($output, qr/^DATABASE/m, 'The header row is there');
like($output, qr/checksum_test/, 'The results row is there');
my ( $cnt, $crc ) = $output =~ m/checksum_test *\d+ \S+ \S+ *(\d+|NULL) *(\w+)/;
like($cnt, qr/1|NULL/, 'One row in the table, or no count');
if ( $output =~ m/cannot be used; using MD5/ ) {
# same as md5(md5(1))
is($crc, '28c8edde3d61a0411511d3b1866f0636', 'MD5 is okay');
}
elsif ( $crc =~ m/^\d+$/ ) {
is($crc, 3036305396, 'CHECKSUM is okay');
}
else {
# same as sha1(sha1(1))
is($crc, '9c1c01dc3ac1445a500251fc34a15d3e75a849df', 'SHA1 is okay');
}
# Test that it works with locking
$output = output(
sub { pt_table_checksum::main(@args, qw(--lock --slave-lag),
qw(--function sha1 --checksum --algorithm ACCUM)) }
);
like($output, qr/9c1c01dc3ac1445a500251fc34a15d3e75a849df/, 'Locks' );
SKIP: {
skip 'MySQL version < 4.1', 5
unless $vp->version_ge($master_dbh, '4.1.0');
$output = output(
sub { pt_table_checksum::main(@args,
qw(--function CRC32 --checksum --algorithm ACCUM)) }
);
like($output, qr/00000001E9F5DC8E/, 'CRC32 ACCUM' );
$output = output(
sub { pt_table_checksum::main(@args,
qw(--function sha1 --checksum --algorithm ACCUM)) }
);
like($output, qr/9c1c01dc3ac1445a500251fc34a15d3e75a849df/, 'SHA1 ACCUM' );
# same as sha1(1)
$output = output(
sub { pt_table_checksum::main(@args,
qw(--function sha1 --checksum --algorithm BIT_XOR)) }
);
like($output, qr/356a192b7913b04c54574d18c28d46e6395428ab/, 'SHA1 BIT_XOR' );
# test that I get the same result with --no-optxor
$output2 = output(
sub { pt_table_checksum::main(@args,
qw(--function sha1 --no-optimize-xor --checksum --algorithm BIT_XOR)) }
);
is($output, $output2, 'Same result with --no-optxor');
# same as sha1(1)
$output = output(
sub { pt_table_checksum::main(@args,
qw(--checksum --function MD5 --algorithm BIT_XOR)) }
);
like($output, qr/c4ca4238a0b923820dcc509a6f75849b/, 'MD5 BIT_XOR' );
};
$output = output(
sub { pt_table_checksum::main(@args,
qw(--checksum --function MD5 --algorithm ACCUM)) }
);
like($output, qr/28c8edde3d61a0411511d3b1866f0636/, 'MD5 ACCUM' );
# ############################################################################
# --sleep
# ############################################################################
# Issue 1256: mk-tabe-checksum: if no rows are found in a chunk, don't perform the sleep
my $t0 = time;
output(
sub { pt_table_checksum::main("F=$cnf",
qw(--sleep 5 -t mysql.user --chunk-size 100)) },
);
ok(
time - $t0 < 1,
"--sleep doesn't sleep unless table is chunked"
);
# ############################################################################
# Bug 821673: pt-table-checksum doesn't included --where in min max queries
# ############################################################################
$sb->load_file('master', "t/pt-table-checksum/samples/where01.sql");
ok(
no_diff(
sub { pt_table_checksum::main(@args,
qw(--no-zero-chunk --chunk-size 5), '--where', "date = '2011-03-03'");
},
"t/pt-table-checksum/samples/where01.out",
trf => "awk '{print \$1 \" \" \$2 \" \" \$3 \" \" \$6}'",
),
"--where affects int range stats (bug 821673)"
);
# Test it again with a varchar primary key. The resulting 5 rows are:
# | Apple | 2011-03-03 |
# | lemon | 2011-03-03 |
# | lime | 2011-03-03 |
# | pineapple | 2011-03-03 |
# | raspberry | 2011-03-03 |
$sb->load_file('master', "t/pt-table-checksum/samples/where02.sql");
ok(
no_diff(
sub { pt_table_checksum::main(@args,
qw(--no-zero-chunk --chunk-size 5), '--where', "date = '2011-03-03'");
},
"t/pt-table-checksum/samples/where02.out",
trf => "awk '{print \$1 \" \" \$2 \" \" \$3 \" \" \$6}'",
),
"--where affects char range stats (bug 821673)"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,59 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 2;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
$output = `$cmd --checksum --ignore-databases sakila -d test -t checksum_test`;
is(
$output,
"3036305396 127.0.0.1.test.checksum_test.0
",
'--checksum terse output'
);
# #############################################################################
# Issue 103: mk-table-checksum doesn't honor --checksum in --schema mode
# #############################################################################
$output = `$cmd --checksum --schema --ignore-databases sakila -d test -t checksum_test`;
unlike(
$output,
qr/DATABASE\s+TABLE/,
'--checksum in --schema mode prints terse output'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,104 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $vp = new VersionParser();
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 5;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my @args = ('-F', $cnf, 'h=127.1', qw(-d issue_519 --explain --chunk-size 3));
$sb->load_file('master', "t/pt-table-checksum/samples/issue_519.sql");
my $default_output = "issue_519 t SELECT /*issue_519.t:1/5*/ 0 AS chunk_num, 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` = 0)
issue_519 t `i` = 0
issue_519 t `i` > 0 AND `i` < '4'
issue_519 t `i` >= '4' AND `i` < '7'
issue_519 t `i` >= '7' AND `i` < '10'
issue_519 t `i` >= '10'
";
$output = output(
sub { pt_table_checksum::main(@args) },
);
is(
$output,
$default_output,
"Chooses chunk column by default"
);
$output = output(
sub { pt_table_checksum::main(@args, qw(--chunk-column batman)) },
);
is(
$output,
$default_output,
"Chooses chunk column if --chunk-column doesn't exist"
);
$output = output(
sub { pt_table_checksum::main(@args, qw(--chunk-column t)) },
);
is(
$output,
$default_output,
"Chooses chunk column if --chunk-column isn't chunkable"
);
$output = output(
sub { pt_table_checksum::main(@args, qw(--chunk-column i --chunk-index y)) },
);
is(
$output,
$default_output,
"Chooses chunk column if it isn't chunkable with --chunk-index",
);
$output = output(
sub { pt_table_checksum::main(@args, qw(--chunk-column y)) },
);
is(
$output,
"issue_519 t SELECT /*issue_519.t:1/5*/ 0 AS chunk_num, 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` = 0)
issue_519 t `y` = 0
issue_519 t `y` > 0 AND `y` < '2003'
issue_519 t `y` >= '2003' AND `y` < '2006'
issue_519 t `y` >= '2006' AND `y` < '2009'
issue_519 t `y` >= '2009'
",
"Use --chunk-column"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
exit;

View File

@@ -1,67 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
my $slave_dbh = $sb->get_dbh_for('slave1');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$slave_dbh ) {
plan skip_all => 'Cannot connect to sandbox slave';
}
else {
plan tests => 2;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/issue_47.sql');
# #############################################################################
# Issue 8: Add --force-index parameter to mk-table-checksum and mk-table-sync
# #############################################################################
# This is difficult to test. If it works, it should just work silently.
# That is: there's really no way for us to see if MySQL is indeed using
# the index that we told it to.
$output = `MKDEBUG=1 $cmd P=12346 -d test -t issue_47 --algorithm ACCUM 2>&1 | grep 'SQL for chunk 0:'`;
like(
$output,
qr/SQL for chunk 0:.*FROM `test`\.`issue_47` (?:FORCE|USE) INDEX \(`idx`\) WHERE/,
'Injects correct USE INDEX by default'
);
$output = `MKDEBUG=1 $cmd P=12346 -d test -t issue_47 --algorithm ACCUM --no-use-index 2>&1 | grep 'SQL for chunk 0:'`;
like(
$output,
qr/SQL for chunk 0:.*FROM `test`\.`issue_47` WHERE/,
'Does not inject USE INDEX with --no-use-index'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
$sb->wipe_clean($slave_dbh);
exit;

View File

@@ -1,52 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 3;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
# Check --offset with --modulo
$output = `$cmd --databases mysql --chunk-size 5 --modulo 7 --offset 'weekday(now())' --tables help_relation --chunk-size-limit 0 2>&1`;
like($output, qr/^mysql\s+help_relation\s+\d+/m, '--modulo --offset runs');
my @chunks = $output =~ m/help_relation\s+(\d+)/g;
my $chunks = scalar @chunks;
ok($chunks, 'There are several chunks with --modulo');
my %differences;
my $first = shift @chunks;
while ( my $chunk = shift @chunks ) {
$differences{$chunk - $first} ++;
$first = $chunk;
}
is($differences{7}, $chunks - 1, 'All chunks are 7 apart');
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,60 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use List::Util qw(sum);
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 3;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
# Ensure --probability works
$output = `$cmd --probability 0 -d test --chunk-size 4 | grep -v DATABASE`;
chomp $output;
my @chunks = $output =~ m/(\d+)\s+127\.0\.0\.1/g;
is(sum(@chunks), 0, 'Nothing with --probability 0!');
# Make sure that it actually checksumed tables and that sum(@chunks)
# isn't zero because no tables were checksumed.
is(
scalar @chunks,
6,
'Checksummed the tables'
);
like(
$output,
qr/test\s+argtest\s+0\s+127.0.0.1\s+MyISAM\s+3\s+875b102e/,
'It actually did something'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,172 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
my $slave_dbh = $sb->get_dbh_for('slave1');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$slave_dbh ) {
plan skip_all => 'Cannot connect to sandbox slave';
}
else {
plan tests => 30;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
# Check --schema
$output = `$cmd --tables checksum_test --checksum --schema 2>&1`;
my $checksum = $sandbox_version ge '5.1' ? '3688961686' : '2752458186';
like(
$output,
qr/$checksum\s+127.1.test2.checksum_test/,
'--checksum --schema'
);
# Should output the same thing, it only lacks the AUTO_INCREMENT specifier
# which is removed by the code before the schema is checksummed so the two
# tables end up having the same checksum.
like(
$output,
qr/$checksum\s+127.1.test.checksum_test/,
'--checksum --schema, AUTO_INCREMENT removed'
);
$output = `$cmd --schema -d test -t checksum_test 2>&1`;
like(
$output,
qr/
DATABASE\s+TABLE\s+CHUNK\s+HOST\s+ENGINE\s+COUNT\s+CHECKSUM\s+TIME\s+WAIT\s+STAT\s+LAG\n
test\s+checksum_test\s+0\s+127.1\s+MyISAM\s+NULL\s+$checksum\s+0\s+0\s+NULL\s+NULL\n
/x,
"Checksum --schema"
);
# #############################################################################
# Issue 5: Add ability to checksum table schema instead of data
# #############################################################################
# The following --schema tests are sensitive to what schemas exist on the
# sandbox server. The sample file is for a blank server, i.e. just the mysql
# db and maybe or not the sakila db.
$sb->wipe_clean($master_dbh);
my $awk_slice = "awk '{print \$1,\$2,\$7}'";
# This test is too flaky because it depends on MySQL version and mysql
# tables. The 3 tests above accomplish the same thing more deterministically:
# testing that we can checksum schema.
# my $ret_val = system("$cmd P=12346 --ignore-databases sakila --schema | $awk_slice | diff $trunk/t/pt-table-checksum/samples/sample_schema_opt -");
# cmp_ok($ret_val, '==', 0, '--schema basic output');
$output = `$cmd --schema --quiet`;
is(
$output,
'',
'--schema respects --quiet'
);
$output = `$cmd --schema --ignore-databases mysql,sakila`;
is(
$output,
'',
'--schema respects --ignore-databases'
);
$output = `$cmd --schema --ignore-tables users`;
unlike(
$output,
qr/users/,
'--schema respects --ignore-tables'
);
# Remember to add $#opt_combos+1 number of tests to line 30.
my @opt_combos = ( # --schema and
'--algorithm=BIT_XOR',
'--algorithm=ACCUM',
'--chunk-size=1M',
'--count',
'--crc',
'--empty-replicate-table',
'--float-precision=3',
'--function=FNV_64',
'--lock',
'--optimize-xor',
'--probability=1',
'--replicate-check=1000',
'--replicate=checksum_tbl',
'--resume samples/resume01_partial.txt',
'--since \'"2008-01-01" - interval 1 day\'',
'--sleep=1000',
'--wait=1000',
'--where="id > 1000"',
);
foreach my $opt_combo ( @opt_combos ) {
$output = `$cmd P=12346 --ignore-databases sakila --schema $opt_combo 2>&1`;
my ($other_opt) = $opt_combo =~ m/^([\w-]+\b)/;
like(
$output,
qr/--schema is not allowed with $other_opt/,
"--schema is not allowed with $other_opt"
);
}
# Have to do this one manually be --no-verify is --verify in the
# error output which confuses the regex magic for $other_opt.
$output = `$cmd P=12346 --ignore-databases sakila --schema --no-verify 2>&1`;
like(
$output,
qr/--schema is not allowed with --verify/,
"--schema is not allowed with --[no]verify"
);
# Check that --schema does NOT lock by default
$output = `MKDEBUG=1 $cmd P=12346 --schema 2>&1`;
unlike($output, qr/LOCK TABLES /, '--schema does not lock tables by default');
$output = `MKDEBUG=1 $cmd P=12346 --schema --lock 2>&1`;
unlike($output, qr/LOCK TABLES /, '--schema does not lock tables even with --lock');
# #############################################################################
# Test issue 5 + 35: --schema a missing table
# #############################################################################
$sb->create_dbs($master_dbh, [qw(test)]);
diag(`/tmp/12345/use -e 'SET SQL_LOG_BIN=0; CREATE TABLE test.only_on_master(a int);'`);
$output = `$cmd P=12346 -t test.only_on_master --schema 2>&1`;
$checksum = $sandbox_version ge '5.1' ? '2402764438' : '23678842';
like($output, qr/MyISAM\s+NULL\s+$checksum/, 'Table on master checksummed with --schema');
like($output, qr/MyISAM\s+NULL\s+NULL/, 'Missing table on slave checksummed with --schema');
like($output, qr/test.only_on_master does not exist on slave 127\.1:12346/, 'Debug reports missing slave table with --schema');
diag(`/tmp/12345/use -e 'DROP TABLE IF EXISTS test.only_on_master'`);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
$sb->wipe_clean($slave_dbh);
exit;

View File

@@ -1,79 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 10;
}
my ($output, $output2);
my $cnf='/tmp/12345/my.sandbox.cnf';
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf -d test -t checksum_test 127.0.0.1";
$sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
# Check --since
$output = `MKDEBUG=1 $cmd --since '"2008-01-01" - interval 1 day' --explain 2>&1 | grep 2007`;
like($output, qr/2007-12-31/, '--since is calculated as an expression');
# Check --since with --arg-table. The value in the --arg-table table
# ought to override the --since passed on the command-line.
$output = `$cmd --arg-table test.argtest --since 20 --explain`;
unlike($output, qr/`a`>=20/, 'Argtest overridden');
like($output, qr/`a`>='1'/, 'Argtest set to something else');
$output = `MKDEBUG=1 $cmd --since 'current_date + interval 1 day' -t test.blackhole 2>&1`;
like($output, qr/Finished chunk/, '--since does not crash on blackhole tables');
$output = `MKDEBUG=1 $cmd --since 'current_date + interval 1 day' 2>&1`;
like($output, qr/Skipping.*--since/, '--since skips tables');
$output = `$cmd --since 100 --explain`;
like($output, qr/`a`>='100'/, '--since adds WHERE clauses');
$output = `$cmd --since current_date 2>&1 | grep HASH`;
unlike($output, qr/HASH\(0x/, '--since does not f*** up table names');
# Check --since with --save-since
$output = `$cmd --arg-table test.argtest --save-since --chunk-size 50 -t test.chunk`;
$output2 = `/tmp/12345/use --skip-column-names -e "select since from test.argtest where tbl='chunk'"`;
is($output2 + 0, 1000, '--save-since saved the maxrow');
$output = `$cmd --arg-table test.argtest --save-since --chunk-size 50 -t test.argtest`;
$output2 = `/tmp/12345/use --skip-column-names -e "select since from test.argtest where tbl='argtest'"`;
like($output2, qr/^\d{4}-\d\d-\d\d/, '--save-since saved the current timestamp');
# #############################################################################
# Issue 121: mk-table-checksum and --since isn't working right on InnoDB tables
# #############################################################################
# Reusing issue_21.sql
$sb->load_file('master', 't/pt-table-checksum/samples/issue_21.sql');
$output = `$trunk/bin/pt-table-checksum --since 'current_date - interval 7 day' h=127.1,P=12345,u=msandbox,p=msandbox -t test.issue_21`;
like($output, qr/test\s+issue_21\s+0\s+127\.1\s+InnoDB/, 'InnoDB table is checksummed with temporal --since');
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
exit;

View File

@@ -1,57 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $vp = new VersionParser();
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 2;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my @args = ('-F', $cnf, 'h=127.1', qw(-t osc.t));
diag(`/tmp/12345/use < $trunk/t/pt-table-checksum/samples/oversize-chunks.sql`);
$dbh->do('alter table osc.t drop index `i`');
ok(
no_diff(
sub { pt_table_checksum::main(@args, qw(--chunk-size 10)) },
"t/pt-table-checksum/samples/unchunkable-table.txt",
),
"Skip unchunkable table"
);
ok(
no_diff(
sub { pt_table_checksum::main(@args, qw(--chunk-size 1000)) },
"t/pt-table-checksum/samples/unchunkable-table-small.txt",
),
"Chunk unchunable table if smaller than chunk size"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
exit;

View File

@@ -1,56 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-table-checksum";
my $vp = new VersionParser();
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 2;
}
my $output;
my $cnf='/tmp/12345/my.sandbox.cnf';
my @args = ('-F', $cnf, 'h=127.1', qw(-t sakila.actor --explain --chunk-size 100));
$output = output(
sub { pt_table_checksum::main(@args) },
);
like(
$output,
qr/`actor_id` = 0/,
"Zero chunk"
);
$output = output(
sub { pt_table_checksum::main(@args, qw(--no-zero-chunk)) },
);
unlike(
$output,
qr/`actor_id` = 0/,
"No zero chunk"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
exit;