Skip to content

Commit

Permalink
Wait for the role change and fix the timing issue in the new test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
enjoy-binbin committed Aug 26, 2024
1 parent 9f4b1ad commit 22ebf5a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unit/cluster/replica-migration.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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]

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

Expand Down

0 comments on commit 22ebf5a

Please sign in to comment.