From 976f645678094680b15ec811de4a4325deddb38b Mon Sep 17 00:00:00 2001 From: frank-cizmich Date: Thu, 24 Sep 2015 19:28:35 -0300 Subject: [PATCH 1/2] pt-kill fixed filter option lp1488685 --- bin/pt-kill | 2 ++ t/pt-kill/filter_plugin.t | 48 +++++++++++++++++++++++++++++++++ t/pt-kill/samples/filter002.txt | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 t/pt-kill/filter_plugin.t create mode 100644 t/pt-kill/samples/filter002.txt diff --git a/bin/pt-kill b/bin/pt-kill index 89ca8227..0cace6ce 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -7055,6 +7055,8 @@ sub main { $filtered_proclist = $proclist; } + $proclist = $filtered_proclist; + my @queries; if ( $proclist ) { # ################################################################## diff --git a/t/pt-kill/filter_plugin.t b/t/pt-kill/filter_plugin.t new file mode 100644 index 00000000..bbcae338 --- /dev/null +++ b/t/pt-kill/filter_plugin.t @@ -0,0 +1,48 @@ +#!/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)); } +); + +print "sample [$sample/recset010.txt]\n"; +print "filter [$filter/filter002.txt]\n"; +print "[$output]\n"; + +ok( + $output =~ /foo/m && $output !~ /bar/s, + "basic --filter function works" +); + +# ############################################################################# +# Done. +# ############################################################################# +exit; diff --git a/t/pt-kill/samples/filter002.txt b/t/pt-kill/samples/filter002.txt new file mode 100644 index 00000000..103e415f --- /dev/null +++ b/t/pt-kill/samples/filter002.txt @@ -0,0 +1,2 @@ +defined($event->{Info}) && $event->{Info} =~ /select.*foo/ + From 09b1a373bd1b91830cfcae3b3797942ad1fbbda6 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Wed, 28 Oct 2015 09:33:35 -0700 Subject: [PATCH 2/2] Clean up the new test. --- t/pt-kill/filter_plugin.t | 6 ------ 1 file changed, 6 deletions(-) diff --git a/t/pt-kill/filter_plugin.t b/t/pt-kill/filter_plugin.t index bbcae338..01a146e6 100644 --- a/t/pt-kill/filter_plugin.t +++ b/t/pt-kill/filter_plugin.t @@ -24,8 +24,6 @@ my $output; # Basic filter # ############################################################################# - - $output = output( sub { pt_kill::main(@args, "$sample/recset010.txt", '--filter', "$filter/filter002.txt", @@ -33,10 +31,6 @@ $output = output( qw(--victims all --print)); } ); -print "sample [$sample/recset010.txt]\n"; -print "filter [$filter/filter002.txt]\n"; -print "[$output]\n"; - ok( $output =~ /foo/m && $output !~ /bar/s, "basic --filter function works"