Files
percona-toolkit/t/pt-diskstats/group_by_all.t
Brian Fraser 43b29d6374 Work in progress: Redesign pt-diskstats in Perl.
Mostly bits and pieces at the moments. ReadKeyMini is a portable-ish
Term::ReadKey. Used here by DiskstatsMenu, which is currently only
for show.

Diskstats has most of the logic of the old pt-diskstats, with parts
now implemented by the DiskstatsGroupBy* classes; The latter subclass
the former.

As mentioned at the start, this is a work in progress. In addition to to
not having all the parts attached, also missing are the data-gathering mode,
the command-line argument parsing, and a large amount of tests.
2011-12-08 19:26:04 -03:00

75 lines
2.0 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 DiskstatsGroupByAll;
my $obj = DiskstatsGroupByAll->new();
for my $filename ( map "diskstats-00$_.txt", 1..5 ) {
my $expected = load_file(
File::Spec->catfile( "t", "pt-diskstats", "expected", "all_$filename"),
);
my $got = output(
sub {
my $orig_re = $obj->column_regex();
$obj->column_regex(qr/./);
$obj->group_by_all(
filename => File::Spec->catfile( $trunk, "t", "pt-diskstats", "samples", $filename ),
);
$obj->column_regex($orig_re);
});
is($got, $expected, "$filename via filename");
$got = output(
sub {
my $orig_re = $obj->column_regex();
$obj->column_regex(qr/./);
open my $fh, "<", File::Spec->catfile( $trunk, "t", "pt-diskstats", "samples", $filename ) or die $!;
$obj->group_by_all(
filehandle => $fh,
);
$obj->column_regex($orig_re);
});
is($got, $expected, "$filename via filehandle");
$got = output(
sub {
my $orig_re = $obj->column_regex();
$obj->column_regex(qr/./);
$obj->group_by_all(
data => load_file( File::Spec->catfile( "t", "pt-diskstats", "samples", $filename ) ),
);
$obj->column_regex($orig_re);
});
is($got, $expected, "$filename via data");
$obj->filename( File::Spec->catfile( $trunk, "t", "pt-diskstats", "samples", $filename ) );
$got = output(
sub {
my $orig_re = $obj->column_regex();
$obj->column_regex(qr/./);
$obj->group_by_all();
$obj->column_regex($orig_re);
});
is($got, $expected, "$filename via obj->filename()");
}