Make pt-stalk/pt-stalk.t stable. Add PerconaTest::not_running().

This commit is contained in:
Daniel Nichter
2012-06-03 13:29:45 -07:00
parent 30a2bdb78c
commit 98b384d845
2 changed files with 20 additions and 13 deletions

View File

@@ -222,7 +222,7 @@ sub parse_file {
# Wait until code returns true.
sub wait_until {
my ( $code, $t, $max_t ) = @_;
$t ||= .25;
$t ||= .20;
$max_t ||= 5;
my $slept = 0;
@@ -306,6 +306,19 @@ sub wait_for_sh {
);
};
sub not_running {
my ($cmd) = @_;
PTDEVDEBUG && _d('Wait until not running:', $cmd);
return wait_until(
sub {
my $output = `ps x | grep -v grep | grep "$cmd"`;
PTDEVDEBUG && _d($output);
return 1 unless $output;
return 0;
}
);
}
sub _read {
my ( $fh ) = @_;
return <$fh>;