mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
Make pt-stalk/pt-stalk.t stable. Add PerconaTest::not_running().
This commit is contained in:
+14
-1
@@ -222,7 +222,7 @@ sub parse_file {
|
|||||||
# Wait until code returns true.
|
# Wait until code returns true.
|
||||||
sub wait_until {
|
sub wait_until {
|
||||||
my ( $code, $t, $max_t ) = @_;
|
my ( $code, $t, $max_t ) = @_;
|
||||||
$t ||= .25;
|
$t ||= .20;
|
||||||
$max_t ||= 5;
|
$max_t ||= 5;
|
||||||
|
|
||||||
my $slept = 0;
|
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 {
|
sub _read {
|
||||||
my ( $fh ) = @_;
|
my ( $fh ) = @_;
|
||||||
return <$fh>;
|
return <$fh>;
|
||||||
|
|||||||
+6
-12
@@ -155,10 +155,8 @@ is(
|
|||||||
"Collect ran for --run-time"
|
"Collect ran for --run-time"
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = `ps x | grep -v grep | grep 'pt-stalk --iterations 1'`;
|
ok(
|
||||||
is(
|
PerconaTest::not_running("pt-stalk --iterations 1"),
|
||||||
$output,
|
|
||||||
"",
|
|
||||||
"pt-stalk is not running"
|
"pt-stalk is not running"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -202,10 +200,8 @@ ok(
|
|||||||
"No files collected"
|
"No files collected"
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = `ps x | grep -v grep | grep 'pt-stalk --no-collect'`;
|
ok(
|
||||||
is(
|
PerconaTest::not_running("pt-stalk --no-collect"),
|
||||||
$output,
|
|
||||||
"",
|
|
||||||
"pt-stalk is not running"
|
"pt-stalk is not running"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -280,10 +276,8 @@ is(
|
|||||||
"Not stalking, collect gathered data"
|
"Not stalking, collect gathered data"
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = `ps x | grep -v grep | grep 'pt-stalk --no-stalk'`;
|
ok(
|
||||||
is(
|
PerconaTest::not_running("pt-stalk --no-stalk"),
|
||||||
$output,
|
|
||||||
"",
|
|
||||||
"Not stalking, pt-stalk is not running"
|
"Not stalking, pt-stalk is not running"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user