From 1f463ff875cb04449060915e725248507360754f Mon Sep 17 00:00:00 2001 From: Binbin Date: Wed, 28 Aug 2024 09:51:10 +0800 Subject: [PATCH] Wait for the role change and fix the timing issue in the new test (#947) The test might be fast enough and then there is no change in the role causing the test to fail. Adding a wait to avoid the timing issue: ``` *** [err]: valkey-cli make source node ignores NOREPLICAS error when doing the last CLUSTER SETSLOT Expected '{127.0.0.1 23154 267}' to be equal to '' (context: type eval line 24 cmd {assert_equal [lindex [R 3 role] 2] {}} proc ::test) ``` Signed-off-by: Binbin Signed-off-by: Ping Xie --- tests/unit/cluster/replica-migration.tcl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/cluster/replica-migration.tcl b/tests/unit/cluster/replica-migration.tcl index 9145bbfb318..918cee417b7 100644 --- a/tests/unit/cluster/replica-migration.tcl +++ b/tests/unit/cluster/replica-migration.tcl @@ -164,6 +164,7 @@ start_cluster 4 4 {tags {external:skip cluster} overrides {cluster-node-timeout R 7 config set cluster-allow-replica-migration yes # Record the current primary node, server 7 will be migrated later. + set old_role_response [R 7 role] set old_primary_ip [lindex [R 7 role] 1] set old_primary_port [lindex [R 7 role] 2] @@ -177,6 +178,15 @@ start_cluster 4 4 {tags {external:skip cluster} overrides {cluster-node-timeout fail "valkey-cli --cluster rebalance returns non-zero exit code, output below:\n$result" } + # Wait for server 7 role response to change. + wait_for_condition 1000 50 { + [R 7 role] ne $old_role_response + } else { + puts "R 3 role: [R 3 role]" + puts "R 7 role: [R 7 role]" + fail "Server 7 role response has not changed" + } + wait_for_cluster_propagation wait_for_cluster_state "ok"