diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl index 9931eac84..83168f091 100644 --- a/tests/cluster/cluster.tcl +++ b/tests/cluster/cluster.tcl @@ -182,8 +182,21 @@ proc cluster_write_test {id} { } # Check if cluster configuration is consistent. +# All the nodes in the cluster should show same slots configuration and have health +# state "online" to be considered as consistent. proc cluster_config_consistent {} { for {set j 0} {$j < $::cluster_master_nodes + $::cluster_replica_nodes} {incr j} { + # Check if all the nodes are online + set shards_cfg [R $j CLUSTER SHARDS] + foreach shard_cfg $shards_cfg { + set nodes [dict get $shard_cfg nodes] + foreach node $nodes { + if {[dict get $node health] ne "online"} { + return 0 + } + } + } + if {$j == 0} { set base_cfg [R $j cluster slots] } else { @@ -199,7 +212,7 @@ proc cluster_config_consistent {} { # Wait for cluster configuration to propagate and be consistent across nodes. proc wait_for_cluster_propagation {} { - wait_for_condition 50 100 { + wait_for_condition 1000 50 { [cluster_config_consistent] eq 1 } else { fail "cluster config did not reach a consistent state" diff --git a/tests/support/cluster_util.tcl b/tests/support/cluster_util.tcl index 516046647..d89a5a384 100644 --- a/tests/support/cluster_util.tcl +++ b/tests/support/cluster_util.tcl @@ -1,8 +1,21 @@ # Cluster helper functions # Check if cluster configuration is consistent. +# All the nodes in the cluster should show same slots configuration and have health +# state "online" to be considered as consistent. proc cluster_config_consistent {} { for {set j 0} {$j < [llength $::servers]} {incr j} { + # Check if all the nodes are online + set shards_cfg [R $j CLUSTER SHARDS] + foreach shard_cfg $shards_cfg { + set nodes [dict get $shard_cfg nodes] + foreach node $nodes { + if {[dict get $node health] ne "online"} { + return 0 + } + } + } + if {$j == 0} { set base_cfg [R $j cluster slots] } else { @@ -27,7 +40,7 @@ proc cluster_size_consistent {cluster_size} { # Wait for cluster configuration to propagate and be consistent across nodes. proc wait_for_cluster_propagation {} { - wait_for_condition 50 100 { + wait_for_condition 1000 50 { [cluster_config_consistent] eq 1 } else { fail "cluster config did not reach a consistent state"