~percona-toolkit-dev/percona-toolkit/fix-stdin-bug-894255

« back to all changes in this revision

Viewing changes to t/lib/QueryReportFormatter.t

  • Committer: Daniel Nichter
  • Date: 2011-11-09 15:17:39 UTC
  • mfrom: (112.1.1 fix-bug-887688)
  • Revision ID: daniel@percona.com-20111109151739-i64deqii9zalmtci
Merge fix-bug-887688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
use strict;
10
10
use warnings FATAL => 'all';
11
11
use English qw(-no_match_vars);
12
 
use Test::More tests => 43;
 
12
use Test::More tests => 44;
13
13
 
14
14
use Data::Dumper;
15
15
$Data::Dumper::Indent    = 1;
1010
1010
   },
1011
1011
];
1012
1012
$ea = new EventAggregator(
1013
 
   groupby => 'fingerprint',
1014
 
   worst   => 'Query_time',
 
1013
   groupby  => 'fingerprint',
 
1014
   worst    => 'Query_time',
 
1015
   type_for => {
 
1016
      Statement_id => 'string',
 
1017
   },
1015
1018
);
1016
1019
foreach my $event ( @$events ) {
1017
1020
   $ea->aggregate($event);
1499
1502
   'Sparkchart in event header'
1500
1503
);
1501
1504
 
 
1505
# ############################################################################
 
1506
# Bug 887688: Prepared statements crash pt-query-digest
 
1507
# ############################################################################
 
1508
 
 
1509
# PREP without EXEC
 
1510
$events = [
 
1511
   {
 
1512
      Query_time    => '0.000286',
 
1513
      Warning_count => 0,
 
1514
      arg           => 'PREPARE SELECT i FROM d.t WHERE i=?',
 
1515
      fingerprint   => 'prepare select i from d.t where i=?',
 
1516
      bytes         => 35,
 
1517
      cmd           => 'Query',
 
1518
      db            => undef,
 
1519
      pos_in_log    => 0,
 
1520
      ts            => '091208 09:23:49.637394',
 
1521
      Statement_id  => 1,
 
1522
   },
 
1523
];
 
1524
$ea = new EventAggregator(
 
1525
   groupby  => 'fingerprint',
 
1526
   worst    => 'Query_time',
 
1527
   type_for => {
 
1528
      Statement_id => 'string',
 
1529
   },
 
1530
);
 
1531
foreach my $event ( @$events ) {
 
1532
   $ea->aggregate($event);
 
1533
}
 
1534
$ea->calculate_statistical_metrics();
 
1535
$report = new ReportFormatter(
 
1536
   line_width   => 82,
 
1537
   extend_right => 1,
 
1538
);
 
1539
$qrf->set_report_formatter(report=>'prepared', formatter=>$report);
 
1540
ok(
 
1541
   no_diff(
 
1542
      sub {
 
1543
         $qrf->print_reports(
 
1544
            reports => ['prepared'],
 
1545
            ea      => $ea,
 
1546
            worst   => [
 
1547
               ['prepare select i from d.t where i=?', 'top', 1],
 
1548
            ],
 
1549
            orderby    => 'Query_time',
 
1550
            groupby    => 'fingerprint',
 
1551
            variations => [qw(arg)],
 
1552
         );
 
1553
      },
 
1554
      "t/lib/samples/QueryReportFormatter/report030.txt",
 
1555
   ),
 
1556
   "PREP without EXEC (bug 887688)"
 
1557
);
 
1558
 
1502
1559
# #############################################################################
1503
1560
# Done.
1504
1561
# #############################################################################