t/pt-table-sync/wait.t: use wait_until() instead of sleep()

This commit is contained in:
Brian Fraser
2012-07-23 13:48:05 -03:00
parent a948014991
commit 0d26097f31

View File

@@ -61,15 +61,13 @@ if ( !$pid ) {
} }
# parent # parent
sleep 4; # give time slave to become lagged PerconaTest::wait_until(sub {
$slave_dbh->selectrow_hashref("show slave status")->{seconds_behind_master}
my $lag = $slave_dbh->selectrow_hashref("show slave status"); }) or do {
if ( !$lag->{seconds_behind_master} ) {
kill 15, $pid; kill 15, $pid;
waitpid ($pid, 0); waitpid ($pid, 0);
die "Slave did not lag"; die "Slave did not lag";
} };
my $start = time; my $start = time;
@@ -93,14 +91,13 @@ cmp_ok(
); );
# Repeat the test with --wait 0 to test that the sync happens without delay. # Repeat the test with --wait 0 to test that the sync happens without delay.
PerconaTest::wait_until(sub {
$lag = $slave_dbh->selectrow_hashref("show slave status"); $slave_dbh->selectrow_hashref("show slave status")->{seconds_behind_master}
}) or do {
if ( !$lag->{seconds_behind_master} ) {
kill 15, $pid; kill 15, $pid;
waitpid ($pid, 0); waitpid ($pid, 0);
die "Slave is not lagged"; die "Slave did not lag";
} };
$start = time; $start = time;