From 80e808b6d6ca40580899bda0397d7c0d9b19b1a8 Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 2 Jun 2012 23:29:57 +0200 Subject: [PATCH 1/1] EVAL replication test: less false positives. wait_for_condition is now used instead of the usual "after 1000" (that is the way to sleep in Tcl). This should avoid to find the replica in a state where it is loading the RDB in memory, returning -LOADING error. This test used to fail when running the test over valgrind, due to the added latencies. --- tests/support/util.tcl | 2 +- tests/unit/scripting.tcl | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/support/util.tcl b/tests/support/util.tcl index a2a9f851..96af279d 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -83,7 +83,7 @@ proc waitForBgrewriteaof r { proc wait_for_sync r { while 1 { - if {[status r master_link_status] eq "down"} { + if {[status $r master_link_status] eq "down"} { after 10 } else { break diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index daf0c0f2..ec6e5c2a 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -319,9 +319,13 @@ start_server {tags {"scripting repl"}} { test {Connect a slave to the main instance} { r -1 slaveof [srv 0 host] [srv 0 port] - after 1000 - s -1 role - } {slave} + wait_for_condition 50 100 { + [s -1 role] eq {slave} && + [string match {*master_link_status:up*} [r -1 info replication]] + } else { + fail "Can't turn the instance into a slave" + } + } test {Now use EVALSHA against the master} { r evalsha ae3477e27be955de7e1bc9adfdca626b478d3cb2 0 -- 2.45.2