mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
read_timeout.t: Skip the first test if STDIN isn't a tty or blocking
This commit is contained in:
@@ -20,27 +20,32 @@ use Time::HiRes qw(sleep time);
|
|||||||
# #########################################################################
|
# #########################################################################
|
||||||
diag(`rm -rf /tmp/mqd.pid`);
|
diag(`rm -rf /tmp/mqd.pid`);
|
||||||
|
|
||||||
my ($start, $end, $waited);
|
my ($start, $end, $waited, $timeout);
|
||||||
my $timeout = wait_for(
|
SKIP: {
|
||||||
|
use IO::File;
|
||||||
|
skip("Either not connected to a tty or STDIN isn't blocking, won't test"
|
||||||
|
. " --read-timeout with STDIN", 1) if !-t STDIN || !STDIN->blocking();
|
||||||
|
$timeout = wait_for(
|
||||||
sub {
|
sub {
|
||||||
$start = time;
|
$start = time;
|
||||||
`$trunk/bin/pt-query-digest --read-timeout 2 --pid /tmp/mqd.pid 2>/dev/null`;
|
`$trunk/bin/pt-query-digest --read-timeout 2 --pid /tmp/mqd.pid 2>/dev/null`;
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
5,
|
5,
|
||||||
);
|
);
|
||||||
$end = time;
|
$end = time;
|
||||||
$waited = $end - $start;
|
$waited = $end - $start;
|
||||||
if ( $timeout ) {
|
if ( $timeout ) {
|
||||||
# mqd ran longer than --read-timeout
|
# mqd ran longer than --read-timeout
|
||||||
my $pid = `cat /tmp/mqd.pid`;
|
my $pid = `cat /tmp/mqd.pid`;
|
||||||
`kill $pid`;
|
kill SIGTERM => $pid if $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
$waited >= 2 && int($waited) < 4,
|
$waited >= 2 && int($waited) < 4,
|
||||||
sprintf("--read-timeout 2 waited %.1f seconds reading STDIN", $waited)
|
sprintf("--read-timeout 2 waited %.1f seconds reading STDIN", $waited)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
diag(`rm -rf /tmp/mqd.pid`);
|
diag(`rm -rf /tmp/mqd.pid`);
|
||||||
diag(`rm -rf /tmp/mqd.fifo; mkfifo /tmp/mqd.fifo`);
|
diag(`rm -rf /tmp/mqd.fifo; mkfifo /tmp/mqd.fifo`);
|
||||||
|
|||||||
Reference in New Issue
Block a user