From 447ce11a64bbcb79b0336a0940c2fb62993e7586 Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Mon, 22 Jul 2024 10:11:56 +0300 Subject: [PATCH] solve race conditions in tests (#13433) [exception]: Executing test client: ERR FAILOVER target replica is not online.. ERR FAILOVER target replica is not online. while executing "$node_0 failover to $node_1_host $node_1_port" ("uplevel" body line 16) invoked from within "uplevel 1 $code" (procedure "test" line 58) invoked from within "test {failover command to specific replica works} { [err]: client evicted due to percentage of maxmemory in tests/unit/client-eviction.tcl Expected 33622 >= 220200 && 33622 < 440401 (context: type eval line 17 cmd {assert {$tot_mem >= $n && $tot_mem < $maxmemory_clients_actual}} proc ::test) --- tests/integration/failover.tcl | 6 ++++++ tests/unit/client-eviction.tcl | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tests/integration/failover.tcl b/tests/integration/failover.tcl index 21fa3d2815..bd33f84aba 100644 --- a/tests/integration/failover.tcl +++ b/tests/integration/failover.tcl @@ -33,6 +33,12 @@ start_server {overrides {save {}}} { $node_2 replicaof $node_0_host $node_0_port wait_for_sync $node_1 wait_for_sync $node_2 + # wait for both replicas to be online from the perspective of the master + wait_for_condition 50 100 { + [string match "*slave0:*,state=online*slave1:*,state=online*" [$node_0 info replication]] + } else { + fail "replica didn't online in time" + } } test {failover command fails with invalid host} { diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index 1fc7c02ca9..7e8270aa8c 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -93,6 +93,11 @@ start_server {} { set n [expr $maxmemory_clients_actual / 2] $rr write [join [list "*1\r\n\$$n\r\n" [string repeat v $n]] ""] $rr flush + wait_for_condition 100 10 { + [client_field $cname tot-mem] >= $n + } else { + fail "Failed to fill qbuf for test" + } set tot_mem [client_field $cname tot-mem] assert {$tot_mem >= $n && $tot_mem < $maxmemory_clients_actual}