mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 01:16:14 +00:00
Explicit setter for device_regex and column_regex.
This commit is contained in:
@@ -175,21 +175,26 @@ sub set_out_fh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub column_regex {
|
sub column_regex {
|
||||||
my ( $self, $new_re ) = @_;
|
my ( $self ) = @_;
|
||||||
if ($new_re) {
|
|
||||||
return $self->{column_regex} = $new_re;
|
|
||||||
}
|
|
||||||
return $self->{column_regex};
|
return $self->{column_regex};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_column_regex {
|
||||||
|
my ( $self, $new_re ) = @_;
|
||||||
|
return $self->{column_regex} = $new_re;
|
||||||
|
}
|
||||||
|
|
||||||
sub device_regex {
|
sub device_regex {
|
||||||
|
my ( $self ) = @_;
|
||||||
|
return $self->{device_regex};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_device_regex {
|
||||||
my ( $self, $new_re ) = @_;
|
my ( $self, $new_re ) = @_;
|
||||||
if ($new_re) {
|
if ($new_re) {
|
||||||
return $self->{device_regex} = $new_re;
|
return $self->{device_regex} = $new_re;
|
||||||
}
|
}
|
||||||
return $self->{device_regex};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub filename {
|
sub filename {
|
||||||
|
@@ -398,6 +398,7 @@ sub get_new_value_for {
|
|||||||
sub get_new_regex_for {
|
sub get_new_regex_for {
|
||||||
my ($looking_for, $message) = @_;
|
my ($looking_for, $message) = @_;
|
||||||
(my $looking_for_o = $looking_for) =~ s/_.*$/s/;
|
(my $looking_for_o = $looking_for) =~ s/_.*$/s/;
|
||||||
|
$looking_for = "set_$looking_for";
|
||||||
return sub {
|
return sub {
|
||||||
my (%args) = @_;
|
my (%args) = @_;
|
||||||
my $new_regex = get_blocking_input($message);
|
my $new_regex = get_blocking_input($message);
|
||||||
|
@@ -96,7 +96,7 @@ my ($dev, $res) = $obj->parse_diskstats_line($line, $obj->block_size);
|
|||||||
|
|
||||||
is_deeply( $res, \%expected_results, "parse_diskstats_line works" );
|
is_deeply( $res, \%expected_results, "parse_diskstats_line works" );
|
||||||
|
|
||||||
$obj->column_regex(qr/./);
|
$obj->set_column_regex(qr/./);
|
||||||
my ($header, $rows, $cols) = $obj->design_print_formats();
|
my ($header, $rows, $cols) = $obj->design_print_formats();
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$cols,
|
$cols,
|
||||||
@@ -105,7 +105,7 @@ is_deeply(
|
|||||||
);
|
);
|
||||||
|
|
||||||
# qr/ \A (?!.*io_s$|\s*[qs]time$) /x
|
# qr/ \A (?!.*io_s$|\s*[qs]time$) /x
|
||||||
$obj->column_regex(qr/cnc|rt|busy|prg|[mk]b|[dr]_s|mrg/);
|
$obj->set_column_regex(qr/cnc|rt|busy|prg|[mk]b|[dr]_s|mrg/);
|
||||||
($header, $rows, $cols) = $obj->design_print_formats();
|
($header, $rows, $cols) = $obj->design_print_formats();
|
||||||
is(
|
is(
|
||||||
$header,
|
$header,
|
||||||
@@ -113,7 +113,7 @@ is(
|
|||||||
"design_print_formats: sanity check for defaults"
|
"design_print_formats: sanity check for defaults"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->column_regex(qr/./);
|
$obj->set_column_regex(qr/./);
|
||||||
($header, $rows, $cols) = $obj->design_print_formats(max_device_length => 10);
|
($header, $rows, $cols) = $obj->design_print_formats(max_device_length => 10);
|
||||||
my $all_columns_format = join(" ", q{%5s %-10s}, map { $_->[0] } @columns_in_order);
|
my $all_columns_format = join(" ", q{%5s %-10s}, map { $_->[0] } @columns_in_order);
|
||||||
is(
|
is(
|
||||||
@@ -122,7 +122,7 @@ is(
|
|||||||
"design_print_formats: max_device_length works"
|
"design_print_formats: max_device_length works"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->column_regex(qr/(?!)/); # Will never match
|
$obj->set_column_regex(qr/(?!)/); # Will never match
|
||||||
($header, $rows, $cols) = $obj->design_print_formats(max_device_length => 10);
|
($header, $rows, $cols) = $obj->design_print_formats(max_device_length => 10);
|
||||||
is(
|
is(
|
||||||
$header,
|
$header,
|
||||||
@@ -130,7 +130,7 @@ is(
|
|||||||
"design_print_formats respects column_regex"
|
"design_print_formats respects column_regex"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->column_regex(qr/./);
|
$obj->set_column_regex(qr/./);
|
||||||
($header, $rows, $cols) = $obj->design_print_formats(
|
($header, $rows, $cols) = $obj->design_print_formats(
|
||||||
max_device_length => 10,
|
max_device_length => 10,
|
||||||
columns => []
|
columns => []
|
||||||
@@ -141,7 +141,7 @@ is(
|
|||||||
"...unless we pass an explicit column array"
|
"...unless we pass an explicit column array"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->column_regex(qr/./);
|
$obj->set_column_regex(qr/./);
|
||||||
($header, $rows, $cols) = $obj->design_print_formats(
|
($header, $rows, $cols) = $obj->design_print_formats(
|
||||||
max_device_length => 10,
|
max_device_length => 10,
|
||||||
columns => [qw( busy )]
|
columns => [qw( busy )]
|
||||||
@@ -295,7 +295,7 @@ for my $test (
|
|||||||
my $method = $test->{method};
|
my $method = $test->{method};
|
||||||
my $prefix = $test->{results_file_prefix};
|
my $prefix = $test->{results_file_prefix};
|
||||||
|
|
||||||
$obj->column_regex(qr/ \A (?!.*io_s$|\s*[qs]time$) /x);
|
$obj->set_column_regex(qr/ \A (?!.*io_s$|\s*[qs]time$) /x);
|
||||||
|
|
||||||
for my $filename ( map "diskstats-00$_.txt", 1..5 ) {
|
for my $filename ( map "diskstats-00$_.txt", 1..5 ) {
|
||||||
my $file = File::Spec->catfile( "t", "pt-diskstats", "samples", $filename );
|
my $file = File::Spec->catfile( "t", "pt-diskstats", "samples", $filename );
|
||||||
|
Reference in New Issue
Block a user