mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00

* PT-2140 - Update modules in the main branch Updated modules for: - pt-align - pt-archiver - pt-config-diff - pt-deadlock-logger - pt-diskstats - pt-duplicate-key-checker - pt-fifo-split - pt-find - pt-fingerprint - pt-fk-error-logger - pt-heartbeat - pt-index-usage - pt-ioprofile - pt-kill - pt-mext - pt-mysql-summary - pt-online-schema-change - pt-pmp - pt-query-digest - pt-show-grants - pt-sift - pt-slave-delay - pt-slave-find - pt-slave-restart - pt-summary - pt-table-sync - pt-upgrade - pt-variable-advisor Added execute bit for pt-query-digest * PT-2140 Update modules in the main branch Fixed Daemon.pm plugin usage Updated all tests, related to the Daemon plugin. I intentionally did not fix failing tests, not related to Daemon plugin, to avoid making this PR too big. - bin/pt-archiver - PT-2141 - Fixed usage of Daemon.pm - PT-2141 - Updated t/pt-archiver/standard_options.t - bin/pt-deadlock-logger - PT-2143 - Fixed usage of Daemon.pm - PT-2143 - Updated t/pt-deadlock-logger/standard_options.t - bin/pt-fifo-split - PT-2144 - Fixed usage of Daemon.pm - PT-2144 - Updated t/pt-fifo-split/pt-fifo-split.t - bin/pt-find - PT-2145 - Fixed usage of Daemon.pm - PT-2145 - Updated t/pt-find/pt-find.t - bin/pt-fk-error-logger - PT-2146 - Fixed usage of Daemon.pm - PT-2146 - Updated t/pt-fk-error-logger/basics.t - bin/pt-heartbeat - PT-2147 - Fixed usage of Daemon.pm - PT-2147 - Updated t/pt-heartbeat/standard_options.t, t/pt-heartbeat/basics.t - bin/pt-kill - PT-2148 - Fixed usage of Daemon.pm - PT-2148 - Updated t/pt-kill/standard_options.t - bin/pt-show-grants - PT-2152 - Fixed usage of Daemon.pm - PT-2152 - Updated t/pt-show-grants/standard_options.t - bin/pt-slave-delay - Fixed usage of Daemon.pm - Updated t/pt-slave-delay/standard_options.t - bin/pt-slave-find - PT-2153 - Fixed usage of Daemon.pm - PT-2153 -Updated t/pt-slave-find/pt-slave-find.t - bin/pt-slave-restart - Fixed usage of Daemon.pm - Updated t/pt-slave-restart/pt-slave-restart.t - bin/pt-table-sync - PT-2154 - Fixed usage of Daemon.pm - PT-2154 -Updated t/pt-table-sync/standard_options.t
150 lines
3.8 KiB
Perl
150 lines
3.8 KiB
Perl
#!/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-archiver";
|
|
|
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
|
my $dbh = $sb->get_dbh_for('master');
|
|
my $dbh2 = $sb->get_dbh_for('slave1');
|
|
|
|
if ( !$dbh ) {
|
|
plan skip_all => 'Cannot connect to sandbox master';
|
|
}
|
|
elsif ( !$dbh2 ) {
|
|
plan skip_all => 'Cannot connect to sandbox slave';
|
|
}
|
|
|
|
my $output;
|
|
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
|
my $pid_file = "/tmp/pt-archiver-test.pid.$PID";
|
|
my $sentinel = "/tmp/pt-archiver-test.sentinel.$PID";
|
|
|
|
$sb->create_dbs($dbh, [qw(test)]);
|
|
|
|
ok(
|
|
no_diff(
|
|
sub {
|
|
pt_archiver::main('--source', "F=$cnf,h=127.1,D=sakila,t=film",
|
|
qw(--no-check-charset --purge --dry-run --port 12345),
|
|
"--where", "film_id < 100")
|
|
},
|
|
"t/pt-archiver/samples/issue-248.txt",
|
|
),
|
|
'DSNs inherit from standard connection options (issue 248)'
|
|
);
|
|
|
|
# Test with a sentinel file
|
|
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
|
diag(`touch $sentinel`);
|
|
|
|
$output = output(
|
|
sub { pt_archiver::main("--source", "D=test,t=table_1,F=$cnf",
|
|
qw(--where 1=1 --why-quit --purge),
|
|
"--sentinel", $sentinel)
|
|
},
|
|
stderr => 1,
|
|
);
|
|
|
|
like(
|
|
$output,
|
|
qr/because sentinel file $sentinel exists/,
|
|
'Exits because of sentinel'
|
|
);
|
|
|
|
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
|
|
is(
|
|
$output + 0,
|
|
4,
|
|
'No rows were deleted'
|
|
) or diag($output);
|
|
|
|
diag(`rm -f $sentinel`);
|
|
|
|
# Test --stop, which sets the sentinel
|
|
$output = output(
|
|
sub { pt_archiver::main("--sentinel", $sentinel, "--stop") },
|
|
);
|
|
|
|
like(
|
|
$output,
|
|
qr/Successfully created file $sentinel/,
|
|
'Created the sentinel OK'
|
|
);
|
|
|
|
diag(`rm -f $sentinel`);
|
|
|
|
# #############################################################################
|
|
# Issue 391: Add --pid option to mk-table-sync
|
|
# #############################################################################
|
|
diag(`touch $pid_file`);
|
|
|
|
$output = output(
|
|
sub { pt_archiver::main('--source', "F=$cnf,D=test,t=issue_131_src",
|
|
qw(--where 1=1 --statistics --dest t=issue_131_dst),
|
|
"--pid", $pid_file)
|
|
},
|
|
stderr => 1,
|
|
);
|
|
|
|
like(
|
|
$output,
|
|
qr{PID file $pid_file exists},
|
|
'Dies if PID file already exists (issue 391)'
|
|
);
|
|
|
|
diag(`rm -f $pid_file`);
|
|
|
|
# #############################################################################
|
|
# Issue 460: mk-archiver does not inherit DSN as documented
|
|
# #############################################################################
|
|
|
|
# This test will achive rows from dbh:test.table_1 to dbh2:test.table_2.
|
|
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
|
|
|
# Change passwords so defaults files won't work.
|
|
$sb->do_as_root(
|
|
'master',
|
|
q/CREATE USER 'bob'@'%' IDENTIFIED BY 'foo'/,
|
|
q/GRANT ALL ON *.* TO 'bob'@'%'/,
|
|
);
|
|
$dbh2->do('TRUNCATE TABLE test.table_2');
|
|
$sb->wait_for_slaves;
|
|
|
|
$output = output(
|
|
sub { pt_archiver::main(
|
|
'--source', 'h=127.1,P=12345,D=test,t=table_1,u=bob,p=foo',
|
|
'--dest', 'P=12346,t=table_2',
|
|
qw(--where 1=1))
|
|
},
|
|
stderr => 1,
|
|
);
|
|
|
|
my $r = $dbh2->selectall_arrayref('SELECT * FROM test.table_2');
|
|
is(
|
|
scalar @$r,
|
|
4,
|
|
'--dest inherited from --source'
|
|
);
|
|
|
|
$sb->do_as_root('master', q/DROP USER 'bob'@'%'/);
|
|
|
|
# #############################################################################
|
|
# Done.
|
|
# #############################################################################
|
|
$sb->wipe_clean($dbh);
|
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
|
done_testing;
|