From cd81dcf18bf9dafbe0edf29d9bba8c626cd2459e Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Tue, 30 Mar 2021 11:41:06 +0300 Subject: [PATCH] solve race conditions in psync2-pingoff test (#8720) Another test race condition in the macos tests. the test was waiting for PINGs to be generated and put on the replication stream, but waiting for 1 or 2 seconds doesn't really guarantee that. then the test that expected 6 full syncs, found only 4 --- tests/integration/psync2-pingoff.tcl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/integration/psync2-pingoff.tcl b/tests/integration/psync2-pingoff.tcl index cdecfc5c..7744010a 100644 --- a/tests/integration/psync2-pingoff.tcl +++ b/tests/integration/psync2-pingoff.tcl @@ -111,7 +111,13 @@ start_server {} { $replica1 replicaof no one $replica2 replicaof 127.0.0.1 1 ;# we can't promote it to master since that will cycle the replication id $master config set repl-ping-replica-period 1 - after 1500 + set replofs [status $master master_repl_offset] + wait_for_condition 50 100 { + [status $replica3 master_repl_offset] > $replofs && + [status $replica4 master_repl_offset] > $replofs + } else { + fail "replica didn't sync in time" + } # make everyone sync from the replica1 that didn't get the last ping from the old master # replica4 will keep syncing from the old master which now syncs from replica1 @@ -195,10 +201,16 @@ start_server {} { fail "Chained replica not replicating from its master" } - # Do a write on the master, and wait for 3 seconds for the master to + # Do a write on the master, and wait for the master to # send some PINGs to its replica $R(0) INCR counter2 - after 2000 + set replofs [status $R(0) master_repl_offset] + wait_for_condition 50 100 { + [status $R(1) master_repl_offset] > $replofs && + [status $R(2) master_repl_offset] > $replofs + } else { + fail "replica didn't sync in time" + } set sync_partial_master [status $R(0) sync_partial_ok] set sync_partial_replica [status $R(1) sync_partial_ok] $R(0) CONFIG SET repl-ping-replica-period 100