summaryrefslogtreecommitdiff
path: root/tests/support
diff options
context:
space:
mode:
authorranshid <88133677+ranshid@users.noreply.github.com>2022-09-07 02:54:24 +0300
committerGitHub <noreply@github.com>2022-09-06 16:54:24 -0700
commitc0ce97faccb314f00cdda38a233508d38bd1b855 (patch)
tree2ac37882ed8539694d698b98abfd0fd2458de11b /tests/support
parent3761fdb048e22a5277bd577f87c462dfe019823a (diff)
downloadredis-c0ce97faccb314f00cdda38a233508d38bd1b855.tar.gz
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
Diffstat (limited to 'tests/support')
-rw-r--r--tests/support/cluster_helper.tcl19
1 files changed, 19 insertions, 0 deletions
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} {