mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00

Missing a doc overhaul and tests, but this deals with most of the feature upgrades in the blueprint. The shell version of pt-diskstats is now in bin has pt-diskstats-shell, in case that's needed.
62 lines
1.6 KiB
Perl
62 lines
1.6 KiB
Perl
#!/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 qw( no_plan );
|
|
use File::Spec;
|
|
|
|
use PerconaTest;
|
|
use pt_diskstats;
|
|
|
|
{
|
|
# Tie magic. During the tests we tie STDIN to always return a lone "q".
|
|
# See the note in the bottom of this file about *DATA. Please don't close it.
|
|
sub Test::TIEHANDLE {
|
|
return bless {}, "Test";
|
|
}
|
|
|
|
sub Test::FILENO {
|
|
return fileno(*DATA);
|
|
}
|
|
|
|
sub Test::READLINE {
|
|
return "q";
|
|
}
|
|
}
|
|
|
|
for my $ext ( qw( all disk sample ) ) {
|
|
for my $filename ( map "diskstats-00$_.txt", 1..5 ) {
|
|
my $expected = load_file(
|
|
File::Spec->catfile( "t", "pt-diskstats",
|
|
"expected", "${ext}_int_$filename"
|
|
),
|
|
);
|
|
|
|
my $got = output( sub {
|
|
tie local *STDIN, "Test";
|
|
my $file = File::Spec->catfile( $trunk, "t", "pt-diskstats",
|
|
"samples", $filename );
|
|
pt_diskstats->main(
|
|
"--group-by" => $ext,
|
|
"--columns" => "cnc|rt|mb|busy|prg",
|
|
$file
|
|
);
|
|
} );
|
|
|
|
is($got, $expected, "--group-by $ext for $filename gets the same results as the shell version");
|
|
}
|
|
}
|
|
|
|
__DATA__
|
|
Leave this here!
|
|
We tie STDIN during the tests, and fake the fileno by giving it *DATA's result;
|
|
These lines here make Perl leave *DATA open.
|
|
|