mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-22 03:44:55 +00:00
Test that pt-kill reconnects using new util/kill-mysql-process. Fix optional DSN by adding magical options rule.
This commit is contained in:
@@ -4,6 +4,7 @@ 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";
|
||||
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
||||
};
|
||||
|
||||
use strict;
|
||||
@@ -25,7 +26,7 @@ if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 4;
|
||||
plan tests => 6;
|
||||
}
|
||||
|
||||
my $output;
|
||||
@@ -79,6 +80,32 @@ like(
|
||||
'--verbose'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Reconnect if cxn lost.
|
||||
# #############################################################################
|
||||
$master_dbh->do("CREATE DATABASE IF NOT EXISTS pt_kill_test");
|
||||
|
||||
system(qq($trunk/util/kill-mysql-process db=pt_kill_test wait=2 &));
|
||||
|
||||
$output = output(
|
||||
sub { pt_kill::main('-F', $cnf, qw(-D pt_kill_test),
|
||||
qw(--run-time 4 --interval 1 --print --verbose)) },
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/Reconnected/,
|
||||
"kill-mysql-process says it reconnected"
|
||||
);
|
||||
|
||||
my $n_checks =()= $output =~ m/Checking processlist/g;
|
||||
is(
|
||||
$n_checks,
|
||||
4,
|
||||
"pt-kill still checked the processlist 4 times"
|
||||
) or diag($output);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
@@ -41,7 +41,7 @@ my $cnf='/tmp/12345/my.sandbox.cnf';
|
||||
|
||||
# Shell out to a sleep(10) query and try to capture the query.
|
||||
# Backticks don't work here.
|
||||
system("/tmp/12345/use -h127.1 -P12345 -umsandbox -pmsandbox -e 'select sleep(4)' >/dev/null&");
|
||||
system("/tmp/12345/use -h127.1 -P12345 -umsandbox -pmsandbox -e 'select sleep(4)' >/dev/null 2>&1 &");
|
||||
sleep 0.5;
|
||||
my $rows = $dbh->selectall_hashref('show processlist', 'id');
|
||||
my $pid;
|
||||
|
Reference in New Issue
Block a user