1
# Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
package GenTest::Reporter;
21
@ISA = qw(GenTest Exporter);
23
REPORTER_TYPE_PERIODIC
24
REPORTER_TYPE_DEADLOCK
27
REPORTER_TYPE_SERVER_KILLED
39
use constant REPORTER_PRNG => 0;
40
use constant REPORTER_SERVER_DSN => 1;
41
use constant REPORTER_SERVER_VARIABLES => 2;
42
use constant REPORTER_SERVER_INFO => 3;
43
use constant REPORTER_SERVER_PLUGINS => 4;
44
use constant REPORTER_TEST_START => 5;
45
use constant REPORTER_TEST_END => 6;
46
use constant REPORTER_TEST_DURATION => 7;
48
use constant REPORTER_TYPE_PERIODIC => 2;
49
use constant REPORTER_TYPE_DEADLOCK => 4;
50
use constant REPORTER_TYPE_CRASH => 8;
51
use constant REPORTER_TYPE_SUCCESS => 16;
52
use constant REPORTER_TYPE_SERVER_KILLED => 32;
53
use constant REPORTER_TYPE_ALWAYS => 64;
54
use constant REPORTER_TYPE_DATA => 128;
61
my $reporter = $class->SUPER::new({
62
dsn => REPORTER_SERVER_DSN,
63
test_start => REPORTER_TEST_START,
64
test_end => REPORTER_TEST_END,
65
test_duration => REPORTER_TEST_DURATION
68
my $dbh = DBI->connect($reporter->dsn(), undef, undef, { RaiseError => 0 , PrintError => 1 } );
69
return undef if not defined $dbh;
70
my $sth = $dbh->prepare("SHOW VARIABLES");
74
while (my $array_ref = $sth->fetchrow_arrayref()) {
75
$reporter->[REPORTER_SERVER_VARIABLES]->{$array_ref->[0]} = $array_ref->[1];
80
my $slave_info = $dbh->selectrow_arrayref("SHOW SLAVE HOSTS");
81
$reporter->[REPORTER_SERVER_INFO]->{slave_host} = $slave_info->[1];
82
$reporter->[REPORTER_SERVER_INFO]->{slave_port} = $slave_info->[2];
84
if ($reporter->serverVariable('version') !~ m{^5\.0}sgio) {
85
$reporter->[REPORTER_SERVER_PLUGINS] = $dbh->selectall_arrayref("
86
SELECT PLUGIN_NAME, PLUGIN_LIBRARY
87
FROM INFORMATION_SCHEMA.PLUGINS
88
WHERE PLUGIN_LIBRARY IS NOT NULL
94
my $pid_file = $reporter->serverVariable('pid_file');
97
read (PF, my $pid, -s $pid_file);
100
$pid =~ s{[\r\n]}{}sio;
102
$reporter->[REPORTER_SERVER_INFO]->{pid} = $pid;
104
foreach my $server_path (
105
'bin', 'sbin', 'sql', 'libexec',
106
'../bin', '../sbin', '../sql', '../libexec',
107
'../sql/RelWithDebInfo', '../sql/Debug',
109
my $binary_unix = $reporter->serverVariable('basedir').'/'.$server_path."/mysqld";
110
my $binary_windows = $reporter->serverVariable('basedir').'/'.$server_path."/mysqld.exe";
116
$reporter->[REPORTER_SERVER_INFO]->{bindir} = $reporter->serverVariable('basedir').'/'.$server_path;
117
$reporter->[REPORTER_SERVER_INFO]->{binary} = $binary_unix if -e $binary_unix;
118
$reporter->[REPORTER_SERVER_INFO]->{binary} = $binary_windows if -e $binary_windows;
122
foreach my $client_path (
123
"client/RelWithDebInfo", "client/Debug",
124
"client", "../client", "bin", "../bin"
126
if (-e $reporter->serverVariable('basedir').'/'.$client_path) {
127
$reporter->[REPORTER_SERVER_INFO]->{'client_bindir'} = $reporter->serverVariable('basedir').'/'.$client_path;
132
# look for error log relative to datadir
133
foreach my $errorlog_path (
134
"../log/master.err", # MTRv1 regular layout
135
"../log/mysqld1.err", # MTRv2 regular layout
136
"../mysql.err" # DBServer::MySQL layout
138
my $possible_path = abs_path($reporter->serverVariable('datadir').'/'.$errorlog_path);
139
if (-e $possible_path) {
140
$reporter->[REPORTER_SERVER_INFO]->{'errorlog'} = $possible_path;
144
my $prng = GenTest::Random->new( seed => 1 );
145
$reporter->[REPORTER_PRNG] = $prng;
151
die "Default monitor() called.";
155
die "Default report() called.";
159
return $_[0]->[REPORTER_SERVER_DSN];
163
return $_[0]->[REPORTER_SERVER_VARIABLES]->{$_[1]};
167
$_[0]->[REPORTER_SERVER_INFO]->{$_[1]};
171
return $_[0]->[REPORTER_SERVER_PLUGINS];
175
return $_[0]->[REPORTER_TEST_START];
179
return $_[0]->[REPORTER_TEST_END];
183
return $_[0]->[REPORTER_TEST_DURATION];
187
return $_[0]->[REPORTER_PRNG];
1
# Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
package GenTest::Reporter;
21
@ISA = qw(GenTest Exporter);
23
REPORTER_TYPE_PERIODIC
24
REPORTER_TYPE_DEADLOCK
27
REPORTER_TYPE_SERVER_KILLED
39
use constant REPORTER_PRNG => 0;
40
use constant REPORTER_SERVER_DSN => 1;
41
use constant REPORTER_SERVER_VARIABLES => 2;
42
use constant REPORTER_SERVER_INFO => 3;
43
use constant REPORTER_SERVER_PLUGINS => 4;
44
use constant REPORTER_TEST_START => 5;
45
use constant REPORTER_TEST_END => 6;
46
use constant REPORTER_TEST_DURATION => 7;
47
use constant REPORTER_PROPERTIES => 8;
49
use constant REPORTER_TYPE_PERIODIC => 2;
50
use constant REPORTER_TYPE_DEADLOCK => 4;
51
use constant REPORTER_TYPE_CRASH => 8;
52
use constant REPORTER_TYPE_SUCCESS => 16;
53
use constant REPORTER_TYPE_SERVER_KILLED => 32;
54
use constant REPORTER_TYPE_ALWAYS => 64;
55
use constant REPORTER_TYPE_DATA => 128;
62
my $reporter = $class->SUPER::new({
63
dsn => REPORTER_SERVER_DSN,
64
test_start => REPORTER_TEST_START,
65
test_end => REPORTER_TEST_END,
66
test_duration => REPORTER_TEST_DURATION,
67
properties => REPORTER_PROPERTIES
70
my $dbh = DBI->connect($reporter->dsn(), undef, undef, { RaiseError => 0 , PrintError => 1 } );
71
return undef if not defined $dbh;
72
my $sth = $dbh->prepare("SHOW VARIABLES");
76
while (my $array_ref = $sth->fetchrow_arrayref()) {
77
$reporter->[REPORTER_SERVER_VARIABLES]->{$array_ref->[0]} = $array_ref->[1];
82
my $slave_info = $dbh->selectrow_arrayref("SHOW SLAVE HOSTS");
83
$reporter->[REPORTER_SERVER_INFO]->{slave_host} = $slave_info->[1];
84
$reporter->[REPORTER_SERVER_INFO]->{slave_port} = $slave_info->[2];
86
if ($reporter->serverVariable('version') !~ m{^5\.0}sgio) {
87
$reporter->[REPORTER_SERVER_PLUGINS] = $dbh->selectall_arrayref("
88
SELECT PLUGIN_NAME, PLUGIN_LIBRARY
89
FROM INFORMATION_SCHEMA.PLUGINS
90
WHERE PLUGIN_LIBRARY IS NOT NULL
96
my $pid_file = $reporter->serverVariable('pid_file');
99
read (PF, my $pid, -s $pid_file);
102
$pid =~ s{[\r\n]}{}sio;
104
$reporter->[REPORTER_SERVER_INFO]->{pid} = $pid;
106
foreach my $server_path (
107
'bin', 'sbin', 'sql', 'libexec',
108
'../bin', '../sbin', '../sql', '../libexec',
109
'../sql/RelWithDebInfo', '../sql/Debug',
111
my $binary_unix = $reporter->serverVariable('basedir').'/'.$server_path."/mysqld";
112
my $binary_windows = $reporter->serverVariable('basedir').'/'.$server_path."/mysqld.exe";
118
$reporter->[REPORTER_SERVER_INFO]->{bindir} = $reporter->serverVariable('basedir').'/'.$server_path;
119
$reporter->[REPORTER_SERVER_INFO]->{binary} = $binary_unix if -e $binary_unix;
120
$reporter->[REPORTER_SERVER_INFO]->{binary} = $binary_windows if -e $binary_windows;
124
foreach my $client_path (
125
"client/RelWithDebInfo", "client/Debug",
126
"client", "../client", "bin", "../bin"
128
if (-e $reporter->serverVariable('basedir').'/'.$client_path) {
129
$reporter->[REPORTER_SERVER_INFO]->{'client_bindir'} = $reporter->serverVariable('basedir').'/'.$client_path;
134
# look for error log relative to datadir
135
foreach my $errorlog_path (
136
"../log/master.err", # MTRv1 regular layout
137
"../log/mysqld1.err", # MTRv2 regular layout
138
"../mysql.err" # DBServer::MySQL layout
140
my $possible_path = abs_path($reporter->serverVariable('datadir').'/'.$errorlog_path);
141
if (-e $possible_path) {
142
$reporter->[REPORTER_SERVER_INFO]->{'errorlog'} = $possible_path;
146
my $prng = GenTest::Random->new( seed => 1 );
147
$reporter->[REPORTER_PRNG] = $prng;
153
die "Default monitor() called.";
157
die "Default report() called.";
161
return $_[0]->[REPORTER_SERVER_DSN];
165
return $_[0]->[REPORTER_SERVER_VARIABLES]->{$_[1]};
169
$_[0]->[REPORTER_SERVER_INFO]->{$_[1]};
173
return $_[0]->[REPORTER_SERVER_PLUGINS];
177
return $_[0]->[REPORTER_TEST_START];
181
return $_[0]->[REPORTER_TEST_END];
185
return $_[0]->[REPORTER_PRNG];
189
return $_[0]->[REPORTER_PROPERTIES];