Unverified Commit a3075ca4 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix cluster slot migration test (#10495)

Fix three timing issues in the test
parent 7da1cc3e
...@@ -264,6 +264,21 @@ test {Migrate the last slot away from a node using redis-cli} { ...@@ -264,6 +264,21 @@ test {Migrate the last slot away from a node using redis-cli} {
assert_equal OK [$newnode_r CLUSTER SETSLOT $slot NODE $newnode_id] assert_equal OK [$newnode_r CLUSTER SETSLOT $slot NODE $newnode_id]
assert_equal OK [$owner_r CLUSTER SETSLOT $slot NODE $newnode_id] assert_equal OK [$owner_r CLUSTER SETSLOT $slot NODE $newnode_id]
# Using --cluster check make sure we won't get `Not all slots are covered by nodes`.
# Wait for the cluster to become stable make sure the cluster is up during MIGRATE.
wait_for_condition 1000 50 {
[catch {exec src/redis-cli --cluster check 127.0.0.1:[srv 0 port]}] == 0 &&
[catch {exec src/redis-cli --cluster check 127.0.0.1:[srv -1 port]}] == 0 &&
[catch {exec src/redis-cli --cluster check 127.0.0.1:[srv -2 port]}] == 0 &&
[catch {exec src/redis-cli --cluster check 127.0.0.1:[srv -3 port]}] == 0 &&
[csi 0 cluster_state] eq {ok} &&
[csi -1 cluster_state] eq {ok} &&
[csi -2 cluster_state] eq {ok} &&
[csi -3 cluster_state] eq {ok}
} else {
fail "Cluster doesn't stabilize"
}
# Move the only slot back to original node using redis-cli # Move the only slot back to original node using redis-cli
exec src/redis-cli --cluster reshard 127.0.0.1:[srv -3 port] \ exec src/redis-cli --cluster reshard 127.0.0.1:[srv -3 port] \
--cluster-from $newnode_id \ --cluster-from $newnode_id \
...@@ -271,6 +286,17 @@ test {Migrate the last slot away from a node using redis-cli} { ...@@ -271,6 +286,17 @@ test {Migrate the last slot away from a node using redis-cli} {
--cluster-slots 1 \ --cluster-slots 1 \
--cluster-yes --cluster-yes
# The empty node will become a replica of the new owner before the
# `MOVED` check, so let's wait for the cluster to become stable.
wait_for_condition 1000 50 {
[csi 0 cluster_state] eq {ok} &&
[csi -1 cluster_state] eq {ok} &&
[csi -2 cluster_state] eq {ok} &&
[csi -3 cluster_state] eq {ok}
} else {
fail "Cluster doesn't stabilize"
}
# Check that the key foo has been migrated back to the original owner. # Check that the key foo has been migrated back to the original owner.
catch { $newnode_r get foo } e catch { $newnode_r get foo } e
assert_equal "MOVED $slot $owner_host:$owner_port" $e assert_equal "MOVED $slot $owner_host:$owner_port" $e
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment