Conditionalize IO::Uncompress::Inflate test. Make test names shorter, uniform.

This commit is contained in:
Daniel Nichter
2012-02-14 11:19:23 -07:00
parent 1c57fe8ee2
commit da051b3371
3 changed files with 86 additions and 80 deletions

View File

@@ -324,17 +324,18 @@ sub test_log_parser {
close $fh; close $fh;
}; };
my ($base_file_name) = $args{file} =~ m/([^\/]+)$/;
is( is(
$EVAL_ERROR, $EVAL_ERROR,
'', '',
"No error on $args{file}" "$base_file_name: no errors"
); );
if ( defined $args{result} ) { if ( defined $args{result} ) {
is_deeply( is_deeply(
\@e, \@e,
$args{result}, $args{result},
$args{file} "$base_file_name: results"
) or print "Got: ", Dumper(\@e); ) or print "Got: ", Dumper(\@e);
} }
@@ -342,7 +343,7 @@ sub test_log_parser {
is( is(
scalar @e, scalar @e,
$args{num_events}, $args{num_events},
"$args{file} num_events" "$base_file_name: $args{num_events} events"
); );
} }
@@ -380,17 +381,18 @@ sub test_protocol_parser {
close $fh; close $fh;
}; };
my ($base_file_name) = $args{file} =~ m/([^\/]+)$/;
is( is(
$EVAL_ERROR, $EVAL_ERROR,
'', '',
"No error on $args{file}" "$base_file_name: no errors"
); );
if ( defined $args{result} ) { if ( defined $args{result} ) {
is_deeply( is_deeply(
\@e, \@e,
$args{result}, $args{result},
$args{file} . ($args{desc} ? ": $args{desc}" : '') "$base_file_name: " . ($args{desc} || "results")
) or print "Got: ", Dumper(\@e); ) or print "Got: ", Dumper(\@e);
} }
@@ -398,7 +400,7 @@ sub test_protocol_parser {
is( is(
scalar @e, scalar @e,
$args{num_events}, $args{num_events},
"$args{file} num_events" "$base_file_name: $args{num_events} events"
); );
} }

View File

@@ -15,7 +15,7 @@ use MySQLProtocolParser;
use TcpdumpParser; use TcpdumpParser;
use PerconaTest; use PerconaTest;
my $sample = "t/lib/samples/tcpdump/"; my $sample = "t/lib/samples/tcpdump";
my $tcpdump = new TcpdumpParser(); my $tcpdump = new TcpdumpParser();
my $protocol; # Create a new MySQLProtocolParser for each test. my $protocol; # Create a new MySQLProtocolParser for each test.
@@ -487,79 +487,83 @@ test_protocol_parser(
], ],
); );
# Check data decompression. eval { require IO::Uncompress::Inflate; };
$protocol = new MySQLProtocolParser( SKIP: {
server => '127.0.0.1', skip "IO::Uncompress::Inflate not installed", 2 if $EVAL_ERROR;
port => '12345',
); # Check data decompression.
test_protocol_parser( $protocol = new MySQLProtocolParser(
parser => $tcpdump, server => '127.0.0.1',
protocol => $protocol, port => '12345',
file => "$sample/tcpdump015.txt", );
desc => 'compressed data', test_protocol_parser(
result => [ parser => $tcpdump,
{ protocol => $protocol,
Error_no => 'none', file => "$sample/tcpdump015.txt",
No_good_index_used => 'No', desc => 'compressed data',
No_index_used => 'No', result => [
Query_time => '0.006415', {
Rows_affected => 0, Error_no => 'none',
Thread_id => 20, No_good_index_used => 'No',
Warning_count => 0, No_index_used => 'No',
arg => 'administrator command: Connect', Query_time => '0.006415',
bytes => 30, Rows_affected => 0,
cmd => 'Admin', Thread_id => 20,
db => 'mysql', Warning_count => 0,
host => '127.0.0.1', arg => 'administrator command: Connect',
ip => '127.0.0.1', bytes => 30,
port => '44489', cmd => 'Admin',
pos_in_log => 664, db => 'mysql',
ts => '090612 08:39:05.316805', host => '127.0.0.1',
user => 'msandbox', ip => '127.0.0.1',
}, port => '44489',
{ pos_in_log => 664,
Error_no => 'none', ts => '090612 08:39:05.316805',
No_good_index_used => 'No', user => 'msandbox',
No_index_used => 'Yes', },
Query_time => '0.002884', {
Rows_affected => 0, Error_no => 'none',
Thread_id => 20, No_good_index_used => 'No',
Warning_count => 0, No_index_used => 'Yes',
arg => 'select * from help_relation', Query_time => '0.002884',
bytes => 27, Rows_affected => 0,
cmd => 'Query', Thread_id => 20,
db => 'mysql', Warning_count => 0,
host => '127.0.0.1', arg => 'select * from help_relation',
ip => '127.0.0.1', bytes => 27,
port => '44489', cmd => 'Query',
pos_in_log => 1637, db => 'mysql',
ts => '090612 08:39:08.428913', host => '127.0.0.1',
user => 'msandbox', ip => '127.0.0.1',
}, port => '44489',
{ pos_in_log => 1637,
Error_no => 'none', ts => '090612 08:39:08.428913',
No_good_index_used => 'No', user => 'msandbox',
No_index_used => 'No', },
Query_time => '0.000000', {
Rows_affected => 0, Error_no => 'none',
Thread_id => 20, No_good_index_used => 'No',
Warning_count => 0, No_index_used => 'No',
arg => 'administrator command: Quit', Query_time => '0.000000',
bytes => 27, Rows_affected => 0,
cmd => 'Admin', Thread_id => 20,
db => 'mysql', Warning_count => 0,
host => '127.0.0.1', arg => 'administrator command: Quit',
ip => '127.0.0.1', bytes => 27,
port => '44489', cmd => 'Admin',
pos_in_log => 15782, db => 'mysql',
ts => '090612 08:39:09.145334', host => '127.0.0.1',
user => 'msandbox', ip => '127.0.0.1',
}, port => '44489',
], pos_in_log => 15782,
); ts => '090612 08:39:09.145334',
user => 'msandbox',
},
],
);
}
# TCP retransmission. # TCP retransmission.
# Check data decompression.
$protocol = new MySQLProtocolParser( $protocol = new MySQLProtocolParser(
server => '10.55.200.15', server => '10.55.200.15',
); );

View File

@@ -15,7 +15,7 @@ use SlowLogParser;
use PerconaTest; use PerconaTest;
my $p = new SlowLogParser; my $p = new SlowLogParser;
my $sample = "t/lib/samples/slowlogs/"; my $sample = "t/lib/samples/slowlogs";
# Check that I can parse a slow log in the default slow log format. # Check that I can parse a slow log in the default slow log format.
test_log_parser( test_log_parser(