mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 23:45:44 +00:00
Add back --quiet and test pt-trend.
This commit is contained in:
21
bin/pt-trend
21
bin/pt-trend
@@ -1797,10 +1797,9 @@ sub _d {
|
||||
package pt_trend;
|
||||
|
||||
use English qw(-no_match_vars);
|
||||
|
||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||
Transformers->import(qw(any_unix_timestamp));
|
||||
|
||||
if ( !caller ) { exit main(@ARGV); } # Run the program.
|
||||
sub main {
|
||||
@ARGV = @_; # set global ARGV for this package
|
||||
|
||||
@@ -1810,7 +1809,7 @@ sub main {
|
||||
my $o = new OptionParser();
|
||||
$o->get_specs();
|
||||
$o->get_opts();
|
||||
$o->set('progress', undef) if $o->get('q');
|
||||
$o->set('progress', undef) if $o->get('quiet');
|
||||
if ( !$o->got('help') ) {
|
||||
if ( $o->get('progress') ) {
|
||||
eval { Progress->validate_spec($o->get('progress')) };
|
||||
@@ -1887,7 +1886,10 @@ sub main {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Transformers->import(qw(any_unix_timestamp));
|
||||
# ############################################################################
|
||||
# Subroutines
|
||||
# ############################################################################
|
||||
|
||||
sub print_report {
|
||||
my ( $stats ) = @_;
|
||||
my $ts = any_unix_timestamp($stats->{ts});
|
||||
@@ -1903,6 +1905,11 @@ sub _d {
|
||||
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
|
||||
}
|
||||
|
||||
# ############################################################################
|
||||
# Run the program.
|
||||
# ############################################################################
|
||||
if ( !caller ) { exit main(@ARGV); }
|
||||
|
||||
1; # Because this is a module as well as a script.
|
||||
|
||||
# ############################################################################
|
||||
@@ -1984,6 +1991,12 @@ parts. The first part can be percentage, time, or iterations; the second part
|
||||
specifies how often an update should be printed, in percentage, seconds, or
|
||||
number of iterations.
|
||||
|
||||
=item --quiet
|
||||
|
||||
short form: -q
|
||||
|
||||
Disables L<"--progress">.
|
||||
|
||||
=item --version
|
||||
|
||||
Show version and exit.
|
||||
|
33
t/pt-trend/basics.t
Normal file
33
t/pt-trend/basics.t
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/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;
|
||||
require "$trunk/bin/pt-trend";
|
||||
|
||||
|
||||
my $in = "$trunk/t/lib/samples/slowlogs";
|
||||
my $out = "t/pt-trend/samples/";
|
||||
my @args = ();
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_trend::main(@args, "$in/slow053.txt") },
|
||||
"$out/slow053.txt",
|
||||
),
|
||||
"Analysis for slow053.txt"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
9
t/pt-trend/samples/slow053.txt
Normal file
9
t/pt-trend/samples/slow053.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
1297191601 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191602 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191603 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191604 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191605 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191606 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191607 1.000000 0.000012 0.000012 0.000012 0.000012
|
||||
1297191608 1.000000 0.050012 0.050012 0.050012 0.050012
|
||||
1297191609 1.000000 1.000012 1.000012 1.000012 1.000012
|
Reference in New Issue
Block a user