1
package GenTest::Validator::ReplicationSlaveStatus;
4
@ISA = qw(GenTest::Validator GenTest);
10
use GenTest::Constants;
12
use GenTest::Validator;
14
use constant SLAVE_STATUS_LAST_ERROR => 19;
15
use constant SLAVE_STATUS_LAST_SQL_ERROR => 35;
16
use constant SLAVE_STATUS_LAST_IO_ERROR => 38;
19
my ($validator, $executors) = @_;
20
my $master_executor = $executors->[0];
22
my ($slave_host, $slave_port) = $master_executor->slaveInfo();
25
($slave_host eq '') ||
28
say("SHOW SLAVE HOSTS returns no data.");
29
return STATUS_REPLICATION_FAILURE;
31
my $slave_dsn = 'dbi:mysql:host='.$slave_host.':port='.$slave_port.':user=root';
33
my $slave_dbh = DBI->connect($slave_dsn, undef, undef, { PrintError => 0 });
34
$validator->setDbh($slave_dbh);
39
my ($validator, $executors, $results) = @_;
41
my $master_executor = $executors->[0];
43
my $slave_status = $validator->dbh()->selectrow_arrayref("SHOW SLAVE STATUS");
45
if ($slave_status->[SLAVE_STATUS_LAST_IO_ERROR] ne '') {
46
say("Slave IO thread has stopped with error: ".$slave_status->[SLAVE_STATUS_LAST_IO_ERROR]);
47
return STATUS_REPLICATION_FAILURE;
48
} elsif ($slave_status->[SLAVE_STATUS_LAST_SQL_ERROR] ne '') {
49
say("Slave SQL thread has stopped with error: ".$slave_status->[SLAVE_STATUS_LAST_SQL_ERROR]);
50
return STATUS_REPLICATION_FAILURE;
51
} elsif ($slave_status->[SLAVE_STATUS_LAST_ERROR] ne '') {
52
say("Slave has stopped with error: ".$slave_status->[SLAVE_STATUS_LAST_ERROR]);
53
return STATUS_REPLICATION_FAILURE;