Merged test-for-957442-pqd-custom-filter-group-by

This commit is contained in:
Brian Fraser
2012-11-16 11:42:03 -03:00
3 changed files with 124 additions and 0 deletions

57
t/pt-query-digest/bugs.t Normal file
View File

@@ -0,0 +1,57 @@
#!/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;
use Sandbox;
use PerconaTest;
# See 101_slowlog_analyses.t for why we shift.
shift @INC; # our unshift (above)
shift @INC; # PerconaTest's unshift
shift @INC; # Sandbox
require "$trunk/bin/pt-query-digest";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
my $output = '';
my $exit_status;
my $cnf = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my $samples = "$trunk/t/pt-query-digest/samples";
# #############################################################################
# pt-query-digest with custom --group-by throws error
# https://bugs.launchpad.net/percona-toolkit/+bug/957442
# #############################################################################
$output = output(sub {
$exit_status = pt_query_digest::main('--group-by=page',
'--filter', "$samples/bug_957442_filter.pl",
"$samples/bug_957442_sample.log")
});
ok(
!$exit_status,
"Bug 957442: No error with a custom --filter & --group-by=page"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;

View File

@@ -0,0 +1,9 @@
use strict;
use warnings FATAL => 'all';
use Data::Dumper;
my $page = 0;
if ( $event->{arg} ) {
($page) = $event->{arg} =~ m#/\*page_(\d+)\*/#g;
}
$event->{page} = ($page || 0);
1

View File

@@ -0,0 +1,58 @@
# Time: 120315 18:01:58.479076
# User@Host: EpiFou2[EpiFou2] @ 10.42.1.136 []
# Client: 10.42.1.136:52714
# Thread_id: 1989712101
# Query_time: 0.001084 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
# administrator command: Connect;
# Time: 120315 18:01:58.480646
# User@Host: EpiFou2[EpiFou2] @ 10.60.24.110 []
# Client: 10.60.24.110:59474
# Thread_id: 1989712100
# Query_time: 0.002040 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
SELECT id, meta, faidelog_id
FROM posts_ref
/*page_3*/
ORDER BY id DESC LIMIT 11;
# Time: 120315 18:01:58.481714
# User@Host: EpiFou2[EpiFou2] @ 10.60.24.110 []
# Client: 10.60.24.110:59474
# Thread_id: 1989712100
# Query_time: 0.000000 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
# administrator command: Quit;
# Time: 120315 18:01:58.482088
# User@Host: EpiFou2[EpiFou2] @ 10.42.1.136 []
# Client: 10.42.1.136:52714
# Thread_id: 1989712101
# Query_time: 0.002632 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
SELECT SQL_CALC_FOUND_ROWS id, faidelog_id
FROM posts_ref
WHERE NOT (meta & 0x00000008) AND faidelog_id = 16067957 /*page_8*/
ORDER BY meta DESC, id DESC LIMIT 105, 15;
# Time: 120315 18:01:58.482571
# User@Host: EpiFou2[EpiFou2] @ 10.42.1.136 []
# Client: 10.42.1.136:52714
# Thread_id: 1989712101
# Query_time: 0.000000 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
# administrator command: Quit;
# Time: 120315 18:01:58.497459
# User@Host: EpiFou2[EpiFou2] @ 10.60.24.96 []
# Client: 10.60.24.96:35130
# Thread_id: 1989712113
# Query_time: 0.000483 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
# administrator command: Connect;
# Time: 120315 18:01:58.501509
# User@Host: EpiFou2[EpiFou2] @ 10.60.24.96 []
# Client: 10.60.24.96:35130
# Thread_id: 1989712113
# Query_time: 0.003460 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use faidr3;
SELECT id, meta, faidelog_id
FROM posts_ref
/*page_2*/
ORDER BY id DESC LIMIT 11;