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
4c047447
Commit
4c047447
authored
May 19, 2014
by
antirez
Browse files
Cluster test: proper initialization at unit startup.
parent
67133d2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/cluster/tests/00-base.tcl
View file @
4c047447
...
@@ -8,13 +8,6 @@ if {$::simulate_error} {
...
@@ -8,13 +8,6 @@ if {$::simulate_error} {
}
}
}
}
test
"Cluster nodes are reachable"
{
foreach_redis_id id
{
# Every node should just know itself.
assert
{[
R $id ping
]
eq
{
PONG
}}
}
}
test
"Different nodes have different IDs"
{
test
"Different nodes have different IDs"
{
set ids
{}
set ids
{}
set numnodes 0
set numnodes 0
...
@@ -29,32 +22,6 @@ test "Different nodes have different IDs" {
...
@@ -29,32 +22,6 @@ test "Different nodes have different IDs" {
assert
{
$numids
== $numnodes
}
assert
{
$numids
== $numnodes
}
}
}
test
"Check if nodes auto-discovery works"
{
# Join node 0 with 1, 1 with 2, ... and so forth.
# If auto-discovery works all nodes will know every other node
# eventually.
set ids
{}
foreach_redis_id id
{
lappend ids $id
}
for
{
set j 0
}
{
$j
<
[
expr
[
llength $ids
]
-1
]}
{
incr j
}
{
set a
[
lindex $ids $j
]
set b
[
lindex $ids
[
expr $j+1
]]
set b_port
[
get_instance_attrib redis $b port
]
R $a cluster meet 127.0.0.1 $b_port
}
foreach_redis_id id
{
wait_for_condition 1000 50
{
[
llength
[
get_cluster_nodes $id
]]
==
[
llength $ids
]
}
else
{
fail
"Cluster failed to join into a full mesh."
}
}
}
test
"Before slots allocation, all nodes report cluster failure"
{
assert_cluster_state fail
}
test
"It is possible to perform slot allocation"
{
test
"It is possible to perform slot allocation"
{
cluster_allocate_slots 5
cluster_allocate_slots 5
}
}
...
...
tests/cluster/tests/includes/init-tests.tcl
View file @
4c047447
...
@@ -11,3 +11,43 @@ test "(init) Restart killed instances" {
...
@@ -11,3 +11,43 @@ test "(init) Restart killed instances" {
}
}
}
}
}
}
test
"Cluster nodes are reachable"
{
foreach_redis_id id
{
# Every node should just know itself.
assert
{[
R $id ping
]
eq
{
PONG
}}
}
}
test
"Cluster nodes hard reset"
{
foreach_redis_id id
{
R $id flushall
R $id cluster reset hard
}
}
test
"Cluster Join and auto-discovery test"
{
# Join node 0 with 1, 1 with 2, ... and so forth.
# If auto-discovery works all nodes will know every other node
# eventually.
set ids
{}
foreach_redis_id id
{
lappend ids $id
}
for
{
set j 0
}
{
$j
<
[
expr
[
llength $ids
]
-1
]}
{
incr j
}
{
set a
[
lindex $ids $j
]
set b
[
lindex $ids
[
expr $j+1
]]
set b_port
[
get_instance_attrib redis $b port
]
R $a cluster meet 127.0.0.1 $b_port
}
foreach_redis_id id
{
wait_for_condition 1000 50
{
[
llength
[
get_cluster_nodes $id
]]
==
[
llength $ids
]
}
else
{
fail
"Cluster failed to join into a full mesh."
}
}
}
test
"Before slots allocation, all nodes report cluster failure"
{
assert_cluster_state fail
}
tests/instances.tcl
View file @
4c047447
...
@@ -363,7 +363,7 @@ proc kill_instance {type id} {
...
@@ -363,7 +363,7 @@ proc kill_instance {type id} {
# Return true of the instance of the specified type/id is killed.
# Return true of the instance of the specified type/id is killed.
proc instance_is_killed
{
type id
}
{
proc instance_is_killed
{
type id
}
{
set pid
[
get_instance_attrib $type $id pid
]
set pid
[
get_instance_attrib $type $id pid
]
return
$pid == -1
expr
{
$pid
== -1
}
}
}
# Restart an instance previously killed by kill_instance
# Restart an instance previously killed by kill_instance
...
...
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