1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#!/usr/bin/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";
# The timestamps for unix_timestamp are East Coast (EST), so GMT-4.
$ENV{TZ}='EST5EDT';
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 3;
use SimpleTCPDumpParser;
use PerconaTest;
my $in = "t/lib/samples/simple-tcpdump/";
my $p = new SimpleTCPDumpParser(watch => ':3306');
# Check that I can parse a log in the default format.
test_log_parser(
parser => $p,
file => "$in/simpletcp001.txt",
result => [
{ ts => '1301957863.804195',
ts0 => '1301957863.804195',
id => 0,
end => '1301957863.804465',
end1 => '1301957863.804473',
arg => undef,
host => '10.10.18.253',
port => '58297',
pos_in_log => 0,
},
{ ts => '1301957863.805481',
ts0 => '1301957863.805481',
id => 1,
end => '1301957863.806026',
end1 => '1301957863.806032',
arg => undef,
host => '10.10.18.253',
port => 40135,
pos_in_log => 231,
},
{ ts => '1301957863.805801',
ts0 => '1301957863.805801',
id => 2,
end => '1301957863.806003',
end1 => '1301957863.806003',
arg => undef,
host => '10.10.18.253',
port => 52726,
pos_in_log => 308,
},
],
);
# #############################################################################
# Done.
# #############################################################################
my $output = '';
{
local *STDERR;
open STDERR, '>', \$output;
$p->_d('Complete test coverage');
}
like(
$output,
qr/Complete test coverage/,
'_d() works'
);
exit;
|