diff options
author | Binbin <binloveplay1314@qq.com> | 2022-10-03 14:21:41 +0800 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2022-12-12 17:36:34 +0200 |
commit | 3c525fab6ac61aaa3494cfa767f55d2967dc6004 (patch) | |
tree | d8bd4deb54e4182469c60a566053b558ceb89b84 | |
parent | e1557e6c7a973389af5773c6624fd0630a5f7caf (diff) | |
download | redis-3c525fab6ac61aaa3494cfa767f55d2967dc6004.tar.gz |
Fix redis-cli cluster add-node race in cli.tcl (#11349)
There is a race condition in the test:
```
*** [err]: redis-cli --cluster add-node with cluster-port in tests/unit/cluster/cli.tcl
Expected '5' to be equal to '4' {assert_equal 5 [CI 0 cluster_known_nodes]} proc ::test)
```
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 comment and the fix were taken from #11221. Also apply it in several
other similar places.
(cherry picked from commit a549b78c48121c698c84536d25404a23f01c167d)
-rw-r--r-- | tests/unit/cluster.tcl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/unit/cluster.tcl b/tests/unit/cluster.tcl index b6ba5224c..05df220dc 100644 --- a/tests/unit/cluster.tcl +++ b/tests/unit/cluster.tcl @@ -186,6 +186,8 @@ start_multiple_servers 5 [list overrides $base_conf] { 127.0.0.1:[srv -3 port] \ 127.0.0.1:[srv 0 port] + wait_for_cluster_size 4 + wait_for_condition 1000 50 { [csi 0 cluster_state] eq {ok} && [csi -1 cluster_state] eq {ok} && @@ -244,7 +246,7 @@ test {Migrate the last slot away from a node using redis-cli} { 127.0.0.1:[srv -3 port] \ 127.0.0.1:[srv 0 port] - # First we wait for new node to be recognized by entire cluster + # First we wait for new node to be recognized by entire cluster wait_for_cluster_size 4 wait_for_condition 1000 50 { @@ -364,6 +366,8 @@ start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1 cl 127.0.0.1:[srv -3 port] \ 127.0.0.1:[srv 0 port] + wait_for_cluster_size 4 + wait_for_condition 1000 50 { [csi 0 cluster_state] eq {ok} && [csi -1 cluster_state] eq {ok} && @@ -378,6 +382,8 @@ start_server [list overrides [list cluster-enabled yes cluster-node-timeout 1 cl 127.0.0.1:[srv -4 port] \ 127.0.0.1:[srv 0 port] + wait_for_cluster_size 5 + wait_for_condition 1000 50 { [csi 0 cluster_state] eq {ok} && [csi -1 cluster_state] eq {ok} && |