From c0ce97faccb314f00cdda38a233508d38bd1b855 Mon Sep 17 00:00:00 2001 From: ranshid <88133677+ranshid@users.noreply.github.com> Date: Wed, 7 Sep 2022 02:54:24 +0300 Subject: fix test Migrate the last slot away from a node using redis-cli (#11221) When using cli to add node, there can potentially be a race condition in which all nodes presenting cluster state o.k even though the added node did not yet meet all cluster nodes. this adds another utility function to wait until all cluster nodes see the same cluster size --- tests/support/cluster_helper.tcl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/support') diff --git a/tests/support/cluster_helper.tcl b/tests/support/cluster_helper.tcl index 42b99ca83..6d70e44c1 100644 --- a/tests/support/cluster_helper.tcl +++ b/tests/support/cluster_helper.tcl @@ -16,6 +16,16 @@ proc cluster_config_consistent {} { return 1 } +# Check if cluster size is consistent. +proc cluster_size_consistent {cluster_size} { + for {set j 0} {$j < $cluster_size} {incr j} { + if {[CI $j cluster_known_nodes] ne $cluster_size} { + return 0 + } + } + return 1 +} + # Wait for cluster configuration to propagate and be consistent across nodes. proc wait_for_cluster_propagation {} { wait_for_condition 50 100 { @@ -25,6 +35,15 @@ proc wait_for_cluster_propagation {} { } } +# Wait for cluster size to be consistent across nodes. +proc wait_for_cluster_size {cluster_size} { + wait_for_condition 50 100 { + [cluster_size_consistent $cluster_size] eq 1 + } else { + fail "cluster size did not reach a consistent size $cluster_size" + } +} + # Check that cluster nodes agree about "state", or raise an error. proc wait_for_cluster_state {state} { for {set j 0} {$j < [llength $::servers]} {incr j} { -- cgit v1.2.1