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;
};
my ($base_file_name) = $args{file} =~ m/([^\/]+)$/;
is(
$EVAL_ERROR,
'',
"No error on $args{file}"
"$base_file_name: no errors"
);
if ( defined $args{result} ) {
is_deeply(
\@e,
$args{result},
$args{file}
"$base_file_name: results"
) or print "Got: ", Dumper(\@e);
}
@@ -342,7 +343,7 @@ sub test_log_parser {
is(
scalar @e,
$args{num_events},
"$args{file} num_events"
"$base_file_name: $args{num_events} events"
);
}
@@ -380,17 +381,18 @@ sub test_protocol_parser {
close $fh;
};
my ($base_file_name) = $args{file} =~ m/([^\/]+)$/;
is(
$EVAL_ERROR,
'',
"No error on $args{file}"
"$base_file_name: no errors"
);
if ( defined $args{result} ) {
is_deeply(
\@e,
$args{result},
$args{file} . ($args{desc} ? ": $args{desc}" : '')
"$base_file_name: " . ($args{desc} || "results")
) or print "Got: ", Dumper(\@e);
}
@@ -398,7 +400,7 @@ sub test_protocol_parser {
is(
scalar @e,
$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 PerconaTest;
my $sample = "t/lib/samples/tcpdump/";
my $sample = "t/lib/samples/tcpdump";
my $tcpdump = new TcpdumpParser();
my $protocol; # Create a new MySQLProtocolParser for each test.
@@ -487,79 +487,83 @@ test_protocol_parser(
],
);
# Check data decompression.
$protocol = new MySQLProtocolParser(
server => '127.0.0.1',
port => '12345',
);
test_protocol_parser(
parser => $tcpdump,
protocol => $protocol,
file => "$sample/tcpdump015.txt",
desc => 'compressed data',
result => [
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'No',
Query_time => '0.006415',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'administrator command: Connect',
bytes => 30,
cmd => 'Admin',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 664,
ts => '090612 08:39:05.316805',
user => 'msandbox',
},
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'Yes',
Query_time => '0.002884',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'select * from help_relation',
bytes => 27,
cmd => 'Query',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 1637,
ts => '090612 08:39:08.428913',
user => 'msandbox',
},
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'No',
Query_time => '0.000000',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'administrator command: Quit',
bytes => 27,
cmd => 'Admin',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 15782,
ts => '090612 08:39:09.145334',
user => 'msandbox',
},
],
);
eval { require IO::Uncompress::Inflate; };
SKIP: {
skip "IO::Uncompress::Inflate not installed", 2 if $EVAL_ERROR;
# Check data decompression.
$protocol = new MySQLProtocolParser(
server => '127.0.0.1',
port => '12345',
);
test_protocol_parser(
parser => $tcpdump,
protocol => $protocol,
file => "$sample/tcpdump015.txt",
desc => 'compressed data',
result => [
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'No',
Query_time => '0.006415',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'administrator command: Connect',
bytes => 30,
cmd => 'Admin',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 664,
ts => '090612 08:39:05.316805',
user => 'msandbox',
},
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'Yes',
Query_time => '0.002884',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'select * from help_relation',
bytes => 27,
cmd => 'Query',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 1637,
ts => '090612 08:39:08.428913',
user => 'msandbox',
},
{
Error_no => 'none',
No_good_index_used => 'No',
No_index_used => 'No',
Query_time => '0.000000',
Rows_affected => 0,
Thread_id => 20,
Warning_count => 0,
arg => 'administrator command: Quit',
bytes => 27,
cmd => 'Admin',
db => 'mysql',
host => '127.0.0.1',
ip => '127.0.0.1',
port => '44489',
pos_in_log => 15782,
ts => '090612 08:39:09.145334',
user => 'msandbox',
},
],
);
}
# TCP retransmission.
# Check data decompression.
$protocol = new MySQLProtocolParser(
server => '10.55.200.15',
);

View File

@@ -15,7 +15,7 @@ use SlowLogParser;
use PerconaTest;
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.
test_log_parser(