~percona-toolkit-dev/percona-toolkit/fix-log-parser-writer-bug-963225

« back to all changes in this revision

Viewing changes to t/lib/TCPRequestAggregator.t

  • Committer: Daniel Nichter
  • Date: 2011-06-24 17:22:06 UTC
  • Revision ID: daniel@percona.com-20110624172206-c7q4s4ad6r260zz6
Add lib/, t/lib/, and sandbox/.  All modules are updated and passing on MySQL 5.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
BEGIN {
 
4
   die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
 
5
      unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
 
6
   unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
 
7
};
 
8
 
 
9
use strict;
 
10
use warnings FATAL => 'all';
 
11
use English qw(-no_match_vars);
 
12
use Test::More tests => 5;
 
13
 
 
14
use TCPRequestAggregator;
 
15
use MaatkitTest;
 
16
 
 
17
my $in = "t/lib/samples/simple-tcprequests/";
 
18
my $p;
 
19
 
 
20
# Check that I can parse a simple log and aggregate it into 100ths of a second
 
21
$p = new TCPRequestAggregator(interval => '.01', quantile => '.99');
 
22
# intervals.
 
23
test_log_parser(
 
24
   parser => $p,
 
25
   file   => "$in/simpletcp-requests001.txt",
 
26
   result => [
 
27
      {  ts            => '1301957863.82',
 
28
         concurrency   => '0.346932',
 
29
         throughput    => '1800.173395',
 
30
         arrivals      => 18,
 
31
         completions   => 17,
 
32
         weighted_time => '0.003469',
 
33
         sum_time      => '0.003492',
 
34
         variance_mean => '0.000022',
 
35
         quantile_time => '0.000321',
 
36
         obs_time      => '0.009999',
 
37
         busy_time     => '0.002861',
 
38
         pos_in_log    => 0,
 
39
      },
 
40
      {  ts            => '1301957863.83',
 
41
         concurrency   => '0.649048',
 
42
         throughput    => '1600.001526',
 
43
         arrivals      => 16,
 
44
         completions   => 16,
 
45
         weighted_time => '0.006490',
 
46
         sum_time      => '0.011227',
 
47
         variance_mean => '0.004070',
 
48
         quantile_time => '0.007201',
 
49
         obs_time      => '0.010000',
 
50
         busy_time     => '0.004933',
 
51
         pos_in_log    => 1296,
 
52
      },
 
53
      {  ts            => '1301957863.84',
 
54
         concurrency   => '1.000000',
 
55
         throughput    => '0.000000',
 
56
         arrivals      => 0,
 
57
         completions   => 1,
 
58
         weighted_time => '0.004759',
 
59
         sum_time      => '0.000000',
 
60
         variance_mean => '0.000000',
 
61
         quantile_time => '0.000000',
 
62
         obs_time      => '0.004759',
 
63
         busy_time     => '0.004759',
 
64
         pos_in_log    => '2448',
 
65
      },
 
66
   ],
 
67
);
 
68
 
 
69
# Check that I can parse a log whose first event is ID = 0, and whose events all
 
70
# fit within one time interval.
 
71
$p = new TCPRequestAggregator(interval => '.01', quantile => '.99');
 
72
test_log_parser(
 
73
   parser => $p,
 
74
   file   => "$in/simpletcp-requests002.txt",
 
75
   result => [
 
76
      {  ts            => '1301957863.82',
 
77
         concurrency   => '0.353948',
 
78
         throughput    => '1789.648311',
 
79
         arrivals      => 17,
 
80
         completions   => 17,
 
81
         weighted_time => '0.003362',
 
82
         variance_mean => '0.000022',
 
83
         sum_time      => '0.003362',
 
84
         quantile_time => '0.000321',
 
85
         obs_time      => '0.009499',
 
86
         busy_time     => '0.002754',
 
87
         pos_in_log    => 0,
 
88
      },
 
89
   ],
 
90
);
 
91
 
 
92
# #############################################################################
 
93
# Done.
 
94
# #############################################################################
 
95
my $output = '';
 
96
{
 
97
   local *STDERR;
 
98
   open STDERR, '>', \$output;
 
99
   $p->_d('Complete test coverage');
 
100
}
 
101
like(
 
102
   $output,
 
103
   qr/Complete test coverage/,
 
104
   '_d() works'
 
105
);
 
106
exit;