mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 05:58:16 +00:00
Add forked Maatkit tools in bin/ and their tests in t/.
This commit is contained in:
89
t/pt-query-digest/since_until.t
Normal file
89
t/pt-query-digest/since_until.t
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/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 => 9;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
use DSNParser;
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
my $run_with = "$trunk/bin/pt-query-digest --report-format=query_report --limit 10 $trunk/t/lib/samples/slowlogs/";
|
||||
|
||||
# #############################################################################
|
||||
# Issue 154: Add --since and --until options to mk-query-digest
|
||||
# #############################################################################
|
||||
|
||||
# --since
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --since 2009-07-28', "t/pt-query-digest/samples/slow033-since-yyyy-mm-dd.txt"),
|
||||
'--since 2009-07-28'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --since 090727', "t/pt-query-digest/samples/slow033-since-yymmdd.txt"),
|
||||
'--since 090727'
|
||||
);
|
||||
|
||||
# This test will fail come July 2014.
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --since 1825d', "t/pt-query-digest/samples/slow033-since-Nd.txt"),
|
||||
'--since 1825d (5 years ago)'
|
||||
);
|
||||
|
||||
# --until
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --until 2009-07-27', "t/pt-query-digest/samples/slow033-until-date.txt"),
|
||||
'--until 2009-07-27'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --until 090727', "t/pt-query-digest/samples/slow033-until-date.txt"),
|
||||
'--until 090727'
|
||||
);
|
||||
|
||||
# The result file is correct: it's the one that has all quries from slow033.txt.
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --until 1d', "t/pt-query-digest/samples/slow033-since-Nd.txt"),
|
||||
'--until 1d'
|
||||
);
|
||||
|
||||
# And one very precise --since --until.
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --since "2009-07-26 11:19:28" --until "090727 11:30:00"', "t/pt-query-digest/samples/slow033-precise-since-until.txt"),
|
||||
'--since "2009-07-26 11:19:28" --until "090727 11:30:00"'
|
||||
);
|
||||
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 2 unless $dbh;
|
||||
|
||||
# The result file is correct: it's the one that has all quries from
|
||||
# slow033.txt.
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --aux-dsn h=127.1,P=12345,u=msandbox,p=msandbox --since "\'2009-07-08\' - INTERVAL 7 DAY"', "t/pt-query-digest/samples/slow033-since-Nd.txt"),
|
||||
'--since "\'2009-07-08\' - INTERVAL 7 DAY"',
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff($run_with.'slow033.txt --aux-dsn h=127.1,P=12345,u=msandbox,p=msandbox --until "\'2009-07-28\' - INTERVAL 1 DAY"', "t/pt-query-digest/samples/slow033-until-date.txt"),
|
||||
'--until "\'2009-07-28\' - INTERVAL 1 DAY"',
|
||||
);
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
};
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
Reference in New Issue
Block a user