mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-10 01:12:18 +08:00
Change mk_tool::main() to pt_tool::main() in all tests.
This commit is contained in:
@@ -47,49 +47,49 @@ my @args = qw(--dry-run --where 1=1);
|
||||
# ###########################################################################
|
||||
|
||||
# Test --for-update
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--for-update --purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--for-update --purge)) });
|
||||
like($output, qr/SELECT .*? FOR UPDATE/, '--for-update');
|
||||
|
||||
# Test --share-lock
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--share-lock --purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--share-lock --purge)) });
|
||||
like($output, qr/SELECT .*? LOCK IN SHARE MODE/, '--share-lock');
|
||||
|
||||
# Test --quick-delete
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--quick-delete --purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--quick-delete --purge)) });
|
||||
like($output, qr/DELETE QUICK/, '--quick-delete');
|
||||
|
||||
# Test --low-priority-delete
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--low-priority-delete --purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--low-priority-delete --purge)) });
|
||||
like($output, qr/DELETE LOW_PRIORITY/, '--low-priority-delete');
|
||||
|
||||
# Test --low-priority-insert
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--low-priority-insert)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--low-priority-insert)) });
|
||||
like($output, qr/INSERT LOW_PRIORITY/, '--low-priority-insert');
|
||||
|
||||
# Test --delayed-insert
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--delayed-insert)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--delayed-insert)) });
|
||||
like($output, qr/INSERT DELAYED/, '--delay-insert');
|
||||
|
||||
# Test --replace
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--replace)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--dest t=table_2), '--source', "D=test,t=table_1,F=$cnf", qw(--replace)) });
|
||||
like($output, qr/REPLACE/, '--replace');
|
||||
|
||||
# Test --high-priority-select
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--high-priority-select --dest t=table_2 --source), "D=test,t=table_1,F=$cnf", qw(--replace)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--high-priority-select --dest t=table_2 --source), "D=test,t=table_1,F=$cnf", qw(--replace)) });
|
||||
like($output, qr/SELECT HIGH_PRIORITY/, '--high-priority-select');
|
||||
|
||||
# Test --columns
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", '--columns', 'a,b', qw(--purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", '--columns', 'a,b', qw(--purge)) });
|
||||
like($output, qr{SELECT /\*!40001 SQL_NO_CACHE \*/ `a`,`b` FROM}, 'Only got specified columns');
|
||||
|
||||
# Test --primary-key-only
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--primary-key-only --purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--primary-key-only --purge)) });
|
||||
like($output, qr{SELECT /\*!40001 SQL_NO_CACHE \*/ `a` FROM}, '--primary-key-only works');
|
||||
|
||||
# Test that tables must have same columns
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--dest t=table_4 --source), "D=test,t=table_1,F=$cnf", qw(--purge)) }, stderr=>1);
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--dest t=table_4 --source), "D=test,t=table_1,F=$cnf", qw(--purge)) }, stderr=>1);
|
||||
like($output, qr/The following columns exist in --source /, 'Column check throws error');
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--no-check-columns --dest t=table_4 --source), "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--no-check-columns --dest t=table_4 --source), "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
like($output, qr/SELECT/, 'I can disable the check OK');
|
||||
|
||||
# ###########################################################################
|
||||
@@ -100,7 +100,7 @@ shift @args; # remove --dry-run
|
||||
|
||||
# Test --why-quit and --statistics output
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--purge --why-quit --statistics)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--purge --why-quit --statistics)) });
|
||||
like($output, qr/Started at \d/, 'Start timestamp');
|
||||
like($output, qr/Source:/, 'source');
|
||||
like($output, qr/SELECT 4\nINSERT 0\nDELETE 4\n/, 'row counts');
|
||||
@@ -108,13 +108,13 @@ like($output, qr/Exiting because there are no more rows/, 'Exit reason');
|
||||
|
||||
# Test basic functionality with OPTIMIZE
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--optimize ds --source), "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--optimize ds --source), "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
is($output, '', 'OPTIMIZE did not fail');
|
||||
|
||||
# Test an empty table
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = `/tmp/12345/use -N -e "delete from test.table_1"`;
|
||||
$output = output(sub {mk_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
$output = output(sub {pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$cnf", qw(--purge)) });
|
||||
is($output, "", 'Empty table OK');
|
||||
|
||||
# Test the output
|
||||
@@ -131,15 +131,15 @@ EOF
|
||||
|
||||
# Statistics
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--statistics --source), "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--statistics --source), "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) });
|
||||
like($output, qr/commit *10/, 'Stats print OK');
|
||||
|
||||
# Test --no-delete.
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--no-delete --purge --source), "D=test,t=table_1,F=$cnf", qw(--dry-run)) });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--no-delete --purge --source), "D=test,t=table_1,F=$cnf", qw(--dry-run)) });
|
||||
like($output, qr/> /, '--no-delete implies strict ascending');
|
||||
unlike($output, qr/>=/, '--no-delete implies strict ascending');
|
||||
$output = output(sub {mk_archiver::main(@args, qw(--no-delete --purge --source), "D=test,t=table_1,F=$cnf") });
|
||||
$output = output(sub {pt_archiver::main(@args, qw(--no-delete --purge --source), "D=test,t=table_1,F=$cnf") });
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
is($output + 0, 4, 'All 4 rows are still there');
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ is($output + 0, 105, 'Generic plugin worked');
|
||||
|
||||
# Test --bulk-delete jails the WHERE safely in parens.
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--dry-run --no-ascend --limit 50 --bulk-delete --purge --where 1=1), "--source", "D=test,t=table_5,F=$cnf", qw(--statistics)) },
|
||||
sub { pt_archiver::main(qw(--dry-run --no-ascend --limit 50 --bulk-delete --purge --where 1=1), "--source", "D=test,t=table_5,F=$cnf", qw(--statistics)) },
|
||||
);
|
||||
like($output, qr/\(1=1\)/, 'WHERE clause is jailed');
|
||||
unlike($output, qr/[^(]1=1/, 'WHERE clause is jailed');
|
||||
@@ -56,7 +56,7 @@ unlike($output, qr/[^(]1=1/, 'WHERE clause is jailed');
|
||||
# Test --bulk-delete works ok with a destination table
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table5.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--no-ascend --limit 50 --bulk-delete --where 1=1), "--source", "D=test,t=table_5,F=$cnf", qw(--statistics --dest t=table_5_dest)) },
|
||||
sub { pt_archiver::main(qw(--no-ascend --limit 50 --bulk-delete --where 1=1), "--source", "D=test,t=table_5,F=$cnf", qw(--statistics --dest t=table_5_dest)) },
|
||||
);
|
||||
like($output, qr/SELECT 105/, 'Fetched 105 rows');
|
||||
like($output, qr/DELETE 105/, 'Deleted 105 rows');
|
||||
|
||||
@@ -39,7 +39,7 @@ $sb->load_file('master', 't/pt-archiver/samples/table5.sql');
|
||||
$dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--no-ascend --limit 50 --bulk-insert),
|
||||
sub { pt_archiver::main(qw(--no-ascend --limit 50 --bulk-insert),
|
||||
qw(--bulk-delete --where 1=1 --statistics),
|
||||
'--source', "D=test,t=table_5,F=$cnf",
|
||||
'--dest', "t=table_5_dest") },
|
||||
@@ -64,7 +64,7 @@ like($output, qr/copy\s+$chks/, 'copy checksum');
|
||||
# ############################################################################
|
||||
$sb->load_file('master', 't/pt-archiver/samples/bulk_regular_insert.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
'--where', "id < 8", qw(--limit 100000 --txn-size 1000),
|
||||
qw(--why-quit --statistics --bulk-insert),
|
||||
'--source', "D=bri,t=t,F=$cnf",
|
||||
|
||||
@@ -39,7 +39,7 @@ $sb->load_file('master', "t/pt-archiver/samples/bulk_regular_insert.sql");
|
||||
$dbh->do('use bri');
|
||||
|
||||
output(
|
||||
sub { mk_archiver::main("--source", "F=$cnf,D=bri,t=t", qw(--dest t=t_arch --where 1=1 --bulk-insert --limit 3)) },
|
||||
sub { pt_archiver::main("--source", "F=$cnf,D=bri,t=t", qw(--dest t=t_arch --where 1=1 --bulk-insert --limit 3)) },
|
||||
);
|
||||
|
||||
my $t_rows = $dbh->selectall_arrayref('select * from t order by id');
|
||||
|
||||
@@ -37,7 +37,7 @@ $sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
|
||||
# Archive to another table.
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
);
|
||||
is($output, '', 'No output for archiving to another table');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -48,7 +48,7 @@ is($output + 0, 4, 'Found rows in new table OK when archiving to another table')
|
||||
# Archive only some columns to another table.
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main("-c", "b,c", qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
sub { pt_archiver::main("-c", "b,c", qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
);
|
||||
is($output, '', 'No output for archiving only some cols to another table');
|
||||
$rows = $dbh->selectall_arrayref("select * from test.table_1");
|
||||
@@ -70,7 +70,7 @@ is_deeply(
|
||||
# Archive to another table with autocommit
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --txn-size 0), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1 --txn-size 0), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
);
|
||||
is($output, '', 'Commit every 0 rows worked OK');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -81,7 +81,7 @@ is($output + 0, 4, 'Found rows in new table OK when archiving to another table w
|
||||
# Archive to another table with commit every 2 rows
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --txn-size 2), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1 --txn-size 2), "--source", "D=test,t=table_1,F=$cnf", qw(--dest t=table_2)) },
|
||||
);
|
||||
is($output, '', 'Commit every 2 rows worked OK');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -92,7 +92,7 @@ is($output + 0, 4, 'Found rows in new table OK when archiving to another table w
|
||||
# Test that table with many rows can be archived to table with few
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --dest t=table_4 --no-check-columns), "--source", "D=test,t=table_1,F=$cnf") },
|
||||
sub { pt_archiver::main(qw(--where 1=1 --dest t=table_4 --no-check-columns), "--source", "D=test,t=table_1,F=$cnf") },
|
||||
);
|
||||
$output = `/tmp/12345/use -N -e "select sum(a) from test.table_4"`;
|
||||
is($output + 0, 10, 'Rows got archived');
|
||||
|
||||
@@ -37,7 +37,7 @@ $sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
# Archive to a file.
|
||||
`rm -f archive.test.table_1`;
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
|
||||
);
|
||||
is($output, '', 'No output for archiving to a file');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -58,7 +58,7 @@ EOF
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
`rm -f archive.test.table_1`;
|
||||
$output = output(
|
||||
sub { mk_archiver::main("-c", "b,c", qw(--where 1=1 --header), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
|
||||
sub { pt_archiver::main("-c", "b,c", qw(--where 1=1 --header), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
|
||||
);
|
||||
$output = `cat archive.test.table_1`;
|
||||
is($output, <<EOF
|
||||
|
||||
@@ -37,7 +37,7 @@ $sb->load_file('master', 't/pt-archiver/samples/issue_1152.sql');
|
||||
# #############################################################################
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
qw(--header --progress 1000 --statistics --limit 1000),
|
||||
qw(--commit-each --why-quit),
|
||||
'--source', 'h=127.1,P=12345,D=issue_1152,t=t,u=msandbox,p=msandbox',
|
||||
|
||||
@@ -39,7 +39,7 @@ $sb->load_file('master', 't/pt-archiver/samples/issue_131.sql');
|
||||
$sb->load_file('master', 't/pt-archiver/samples/issue_1166.sql');
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
sub { pt_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
"F=$cnf,D=test,t=issue_131_src", qw(--dest t=issue_131_dst)) }
|
||||
);
|
||||
like(
|
||||
@@ -51,7 +51,7 @@ like(
|
||||
# With non-unique index LIMIT 1 should appear.
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
sub { pt_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
"F=$cnf,D=test,t=issue_1166", "--purge") }
|
||||
);
|
||||
like(
|
||||
@@ -68,7 +68,7 @@ like(
|
||||
$sb->load_file('master', 't/pt-archiver/samples/issue_131.sql');
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
sub { pt_archiver::main(qw(--where 1=1 --dry-run --source),
|
||||
"F=$cnf,D=test,t=issue_131_src", qw(--bulk-delete --purge),
|
||||
qw(--no-bulk-delete-limit --limit 3)) }
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ is_deeply(
|
||||
);
|
||||
|
||||
throws_ok(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
|
||||
'--dest', 't=a',
|
||||
qw(--where 1=1 --purge))
|
||||
@@ -56,7 +56,7 @@ throws_ok(
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
|
||||
'--dest', 't=a',
|
||||
qw(--no-check-charset --where 1=1 --purge))
|
||||
@@ -73,7 +73,7 @@ ok(
|
||||
$sb->load_file('master', 't/pt-archiver/samples/issue_1225.sql');
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
|
||||
'--dest', 't=a',
|
||||
qw(--where 1=1 --purge -A utf8)) # -A utf8 makes it work
|
||||
|
||||
@@ -49,7 +49,7 @@ is_deeply(
|
||||
diag(`rm -rf $file >/dev/null`);
|
||||
|
||||
$output = output(
|
||||
sub { mk_archiver::main(
|
||||
sub { pt_archiver::main(
|
||||
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
|
||||
'--file', $file,
|
||||
qw(--where 1=1 -A UTF8)) # -A utf8 makes it work
|
||||
|
||||
@@ -38,7 +38,7 @@ $sb->create_dbs($dbh, ['test']);
|
||||
# #############################################################################
|
||||
$sb->load_file('master', 't/pt-archiver/samples/issue_131.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "F=$cnf,D=test,t=issue_131_src", qw(--statistics --dest t=issue_131_dst)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "F=$cnf,D=test,t=issue_131_src", qw(--statistics --dest t=issue_131_dst)) },
|
||||
);
|
||||
$rows = $dbh->selectall_arrayref('SELECT * FROM test.issue_131_dst');
|
||||
is_deeply(
|
||||
|
||||
@@ -37,7 +37,7 @@ $sb->create_dbs($dbh, ['test']);
|
||||
# #############################################################################
|
||||
$sb->load_file('master', 't/pt-archiver/samples/issue_131.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --dry-run --no-delete), "--source", "F=$cnf,D=test,t=issue_131_src", qw(--dest t=issue_131_dst)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1 --dry-run --no-delete), "--source", "F=$cnf,D=test,t=issue_131_src", qw(--dest t=issue_131_dst)) },
|
||||
);
|
||||
unlike(
|
||||
$output,
|
||||
|
||||
@@ -38,7 +38,7 @@ $sb->create_dbs($dbh, ['test']);
|
||||
# #############################################################################
|
||||
$dbh->do('CREATE TABLE test.t (i int)');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "F=$cnf,D=test,t=t", qw(--purge --primary-key-only)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "F=$cnf,D=test,t=t", qw(--purge --primary-key-only)) },
|
||||
);
|
||||
unlike(
|
||||
$output,
|
||||
|
||||
@@ -36,7 +36,7 @@ $sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
|
||||
# Test basic functionality with defaults
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--purge)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--purge)) },
|
||||
);
|
||||
is($output, '', 'Basic test run did not die');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -45,7 +45,7 @@ is($output + 0, 0, 'Purged ok');
|
||||
# Test basic functionality with --commit-each
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--commit-each --limit 1 --purge)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--commit-each --limit 1 --purge)) },
|
||||
);
|
||||
is($output, '', 'Commit-each did not die');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -54,7 +54,7 @@ is($output + 0, 0, 'Purged ok with --commit-each');
|
||||
# Archive only part of the table
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--where a<4 --purge)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", qw(--where a<4 --purge)) },
|
||||
);
|
||||
is($output, '', 'No output for archiving only part of a table');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
|
||||
@@ -36,7 +36,7 @@ $sb->create_dbs($dbh, ['test']);
|
||||
# Safe auto-increment behavior.
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table12.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--purge --where 1=1), "--source", "D=test,t=table_12,F=$cnf") },
|
||||
sub { pt_archiver::main(qw(--purge --where 1=1), "--source", "D=test,t=table_12,F=$cnf") },
|
||||
);
|
||||
is($output, '', 'Purge worked OK');
|
||||
$output = `/tmp/12345/use -N -e "select min(a),count(*) from test.table_12"`;
|
||||
@@ -45,7 +45,7 @@ like($output, qr/^3\t1$/, 'Did not touch the max auto_increment');
|
||||
# Safe auto-increment behavior, disabled.
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table12.sql');
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--no-safe-auto-increment --purge --where 1=1), "--source", "D=test,t=table_12,F=$cnf") },
|
||||
sub { pt_archiver::main(qw(--no-safe-auto-increment --purge --where 1=1), "--source", "D=test,t=table_12,F=$cnf") },
|
||||
);
|
||||
is($output, '', 'Disabled safeautoinc worked OK');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_12"`;
|
||||
|
||||
@@ -50,7 +50,7 @@ SKIP: {
|
||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||
diag(`touch sentinel`);
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--where 1=1 --why-quit --sentinel sentinel), "--source", "D=test,t=table_1,F=$cnf", qw(--purge)) },
|
||||
sub { pt_archiver::main(qw(--where 1=1 --why-quit --sentinel sentinel), "--source", "D=test,t=table_1,F=$cnf", qw(--purge)) },
|
||||
);
|
||||
like($output, qr/because sentinel/, 'Exits because of sentinel');
|
||||
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
||||
@@ -59,7 +59,7 @@ is($output + 0, 4, 'No rows were deleted');
|
||||
|
||||
# Test --stop, which sets the sentinel
|
||||
$output = output(
|
||||
sub { mk_archiver::main(qw(--sentinel sentinel --stop)) },
|
||||
sub { pt_archiver::main(qw(--sentinel sentinel --stop)) },
|
||||
);
|
||||
like($output, qr/Successfully created file sentinel/, 'Created the sentinel OK');
|
||||
diag(`rm -f sentinel >/dev/null`);
|
||||
|
||||
Reference in New Issue
Block a user