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";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
12
use Test::More tests => 3;
18
use UpgradeReportFormatter;
23
my ($meta_events, $events1, $events2, $meta_ea, $ea1, $ea2);
25
my $qr = new QueryRewriter();
26
my $urf = new UpgradeReportFormatter();
29
foreach my $event (@$meta_events) {
30
$event->{fingerprint} = $qr->fingerprint( $event->{arg} );
31
$meta_ea->aggregate($event);
33
foreach my $event (@$events1) {
34
$event->{fingerprint} = $qr->fingerprint( $event->{arg} );
35
$ea1->aggregate($event);
37
$ea1->calculate_statistical_metrics();
38
foreach my $event (@$events2) {
39
$event->{fingerprint} = $qr->fingerprint( $event->{arg} );
40
$ea2->aggregate($event);
42
$ea2->calculate_statistical_metrics();
45
$meta_ea = new EventAggregator(
46
groupby => 'fingerprint',
47
worst => 'differences',
49
$ea1 = new EventAggregator(
50
groupby => 'fingerprint',
51
worst => 'Query_time',
53
$ea2 = new EventAggregator(
54
groupby => 'fingerprint',
55
worst => 'Query_time',
58
isa_ok($urf, 'UpgradeReportFormatter');
63
arg => "SELECT id FROM users WHERE name='foo'",
64
Query_time => '8.000652',
71
arg => "SELECT id FROM users WHERE name='foo'",
72
Query_time => '1.001943',
79
arg => "SELECT id FROM users WHERE name='bar'",
80
Query_time => '1.000682',
89
arg => "SELECT id FROM users WHERE name='bar'",
91
different_row_counts => 0,
92
different_checksums => 0,
96
arg => "SELECT id FROM users WHERE name='bar'",
98
different_row_counts => 0,
99
different_checksums => 0,
103
arg => "SELECT id FROM users WHERE name='bar'",
105
different_row_counts => 1,
106
different_checksums => 0,
112
# Query 1: ID 0x82860EDA9A88FCC5 at byte 0 _______________________________
113
# host1: host1.domain.com:3306
114
# host2: host2.domain.com:3307
115
# Found 1 differences in 3 samples:
133
$result = $urf->event_report(
135
hosts => [ {name=>'host1.domain.com:3306', ea=>$ea1},
136
{name=>'host2.domain.com:3307', ea=>$ea2} ],
137
where => 'select id from users where name=?',
139
worst => 'differences',
142
is($result, $expected, 'Event report');
144
# #############################################################################
146
# #############################################################################
150
open STDERR, '>', \$output;
151
$urf->_d('Complete test coverage');
155
qr/Complete test coverage/,