Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
a3075ca4
Unverified
Commit
a3075ca4
authored
Mar 31, 2022
by
Binbin
Committed by
GitHub
Mar 30, 2022
Browse files
Fix cluster slot migration test (#10495)
Fix three timing issues in the test
parent
7da1cc3e
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/unit/cluster.tcl
View file @
a3075ca4
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment