Merge pull request #43 from percona/pt-kill-option-filter-does-not-work-lp1488685

pt-kill option --filter does not work (LP bug 1488685)
This commit is contained in:
Daniel Nichter
2015-10-28 09:34:25 -07:00
3 changed files with 46 additions and 0 deletions

View File

@@ -7055,6 +7055,8 @@ sub main {
$filtered_proclist = $proclist;
}
$proclist = $filtered_proclist;
my @queries;
if ( $proclist ) {
# ##################################################################

42
t/pt-kill/filter_plugin.t Normal file
View File

@@ -0,0 +1,42 @@
#!/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 tests => 1;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-kill";
my $sample = "$trunk/t/lib/samples/pl";
my $filter = "$trunk/t/pt-kill/samples";
my @args = qw(--test-matching);
my $output;
# #############################################################################
# Basic filter
# #############################################################################
$output = output(
sub { pt_kill::main(@args, "$sample/recset010.txt",
'--filter', "$filter/filter002.txt",
qw(--match-all),
qw(--victims all --print)); }
);
ok(
$output =~ /foo/m && $output !~ /bar/s,
"basic --filter function works"
);
# #############################################################################
# Done.
# #############################################################################
exit;

View File

@@ -0,0 +1,2 @@
defined($event->{Info}) && $event->{Info} =~ /select.*foo/