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
6fc17adc
Commit
6fc17adc
authored
Apr 29, 2014
by
antirez
Browse files
Cluster test: slots allocation.
parent
0906ca8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/cluster/cluster.tcl
View file @
6fc17adc
...
@@ -42,3 +42,22 @@ proc get_myself id {
...
@@ -42,3 +42,22 @@ proc get_myself id {
return
{}
return
{}
}
}
# Return the value of the specified CLUSTER INFO field.
proc CI
{
n field
}
{
get_info_field
[
R $n cluster info
]
$field
}
# Assuming nodes are reest, this function performs slots allocation.
# Only the first 'n' nodes are used.
proc cluster_allocate_slots
{
n
}
{
set slot 16383
while
{
$slot
>= 0
}
{
# Allocate successive slots to random nodes.
set node
[
randomInt $n
]
lappend slots_$node $slot
incr slot -1
}
for
{
set j 0
}
{
$j
< $n
}
{
incr j
}
{
R $j cluster addslots
{*}
[
set slots_$
{
j
}]
}
}
tests/cluster/tests/00-base.tcl
View file @
6fc17adc
...
@@ -51,6 +51,16 @@ test "Check if nodes auto-discovery works" {
...
@@ -51,6 +51,16 @@ test "Check if nodes auto-discovery works" {
}
}
}
}
test
"Before slots allocation, all nodes report cluster failure"
{
foreach_redis_id id
{
assert
{[
CI $id cluster_state
]
eq
{
fail
}}
}
}
test
"It is possible to perform slot allocation"
{
cluster_allocate_slots 5
}
test
"After the join, every node gets a different config epoch"
{
test
"After the join, every node gets a different config epoch"
{
set trynum 60
set trynum 60
while
{[
incr trynum -1
]
!= 0
}
{
while
{[
incr trynum -1
]
!= 0
}
{
...
...
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