Removed PerconaTest::{wait_until_no_lag|wait_until_slaves_running}, replaced them with Sandbox::wait_for_slaves

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-06-07 12:00:40 -03:00
parent dac0731251
commit 03a9461daf
3 changed files with 5 additions and 41 deletions

View File

@@ -246,42 +246,6 @@ sub wait_until {
return 0;
}
sub wait_until_slave_running {
my (@dbhs) = @_;
foreach my $dbh (@dbhs) {
PTDEVDEBUG && _d('Waiting for slaves to be running');
wait_until(
sub {
my $row = $dbh->selectrow_hashref('SHOW SLAVE STATUS');
my $sqlt = $row->{slave_sql_running} || $row->{Slave_SQL_Running} || 'NULL';
my $iot = $row->{Slave_IO_Running} || $row->{slave_io_running} || 'NULL';
PTDEVDEBUG && _d('Slave SQL:', $sqlt, 'Slave IO:', $iot);
return $sqlt eq 'Yes' && $iot eq 'Yes';
}
);
}
}
sub wait_until_no_lag {
my (@dbhs) = @_;
foreach my $dbh (@dbhs) {
PTDEVDEBUG && _d('Waiting for no slave lag');
wait_until( # slaves aren't lagging
sub {
my $row = $dbh->selectrow_hashref('SHOW SLAVE STATUS');
my $lag = exists $row->{Seconds_Behind_Master}
? $row->{Seconds_Behind_Master}
: $row->{seconds_behind_master};
PTDEVDEBUG && _d('Slave lag:', $lag);
if ( !defined $lag ) {
BAIL_OUT("Slave is stopped: " . Dumper($row));
}
return $lag ? 0 : 1;
}
);
}
}
# Wait t seconds for code to return.
sub wait_for {
my ( $code, $t ) = @_;

View File

@@ -63,7 +63,7 @@ my $scripts = "$trunk/t/pt-table-checksum/scripts/";
$master_dbh->do('drop table if exists percona.checksums');
# Must not be lagging.
wait_until_no_lag($slave1_dbh, $slave2_dbh);
$sb->wait_for_slaves();
# This big fancy command waits until it sees the checksum for sakila.city
# in the repl table on the master, then it stops slave2 for 2 seconds,
@@ -96,7 +96,7 @@ is(
);
# Now wait until the SQL thread is started again.
wait_until_slave_running($slave1_dbh, $slave2_dbh);
$sb->wait_for_slaves();
# #############################################################################
# Wait for --replicate table to replicate.
@@ -130,7 +130,7 @@ like(
);
$slave2_dbh->do("START SLAVE");
wait_until_slave_running($slave2_dbh);
$sb->wait_for_slaves();
# #############################################################################
# Done.

View File

@@ -58,7 +58,7 @@ pt_table_checksum::main(@args, qw(-t sakila.city --quiet));
# ############################################################################
# Stop slave1.
PerconaTest::wait_until_no_lag($slave1_dbh, $slave2_dbh);
$sb->wait_for_slaves();
$slave1_dbh->do('stop slave sql_thread');
wait_until(sub {
my $ss = $slave1_dbh->selectrow_hashref("SHOW SLAVE STATUS");
@@ -98,7 +98,7 @@ is(
$slave1_dbh->do('START SLAVE sql_thread');
$slave2_dbh->do('STOP SLAVE');
$slave2_dbh->do('START SLAVE');
PerconaTest::wait_until_slave_running($slave1_dbh, $slave2_dbh);
$sb->wait_for_slaves();
# #############################################################################
# Done.