Wait for the role change and fix the timing issue in the new test ()

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 <binloveplay1314@qq.com>
This commit is contained in:
Binbin 2024-08-28 09:51:10 +08:00 committed by GitHub
parent 4f29ad4583
commit 6a84e06b05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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"