diff options
author | antirez <antirez@gmail.com> | 2014-05-14 15:21:57 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-05-20 17:45:50 +0200 |
commit | d279024081dc76a59e4e66fb3ec4ab206eac20cd (patch) | |
tree | 4b3f30b1114cac932bb75a18b792af6151b64e14 | |
parent | be1594905fba5929c3723ce97a9019f44f67c7c1 (diff) | |
download | redis-d279024081dc76a59e4e66fb3ec4ab206eac20cd.tar.gz |
Cluster test: added function assert_cluster_state.
-rw-r--r-- | tests/cluster/cluster.tcl | 12 | ||||
-rw-r--r-- | tests/cluster/tests/00-base.tcl | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl index 824f3a80f..a7d71ab47 100644 --- a/tests/cluster/cluster.tcl +++ b/tests/cluster/cluster.tcl @@ -61,3 +61,15 @@ proc cluster_allocate_slots {n} { R $j cluster addslots {*}[set slots_${j}] } } + +# Check that cluster nodes agree about "state", or raise an error. +proc assert_cluster_state {state} { + foreach_redis_id id { + if {[instance_is_killed redis $id]} continue + wait_for_condition 1000 50 { + [CI $id cluster_state] eq $state + } else { + fail "Cluster node $id cluster_state:[CI $id cluster_state]" + } + } +} diff --git a/tests/cluster/tests/00-base.tcl b/tests/cluster/tests/00-base.tcl index c3badb9b5..5048aa230 100644 --- a/tests/cluster/tests/00-base.tcl +++ b/tests/cluster/tests/00-base.tcl @@ -52,9 +52,7 @@ 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}} - } + assert_cluster_state fail } test "It is possible to perform slot allocation" { @@ -86,13 +84,7 @@ test "After the join, every node gets a different config epoch" { } test "Nodes should report cluster_state is ok now" { - foreach_redis_id id { - wait_for_condition 1000 50 { - [CI $id cluster_state] eq {ok} - } else { - fail "Cluster node $id cluster_state:[CI $id cluster_state]" - } - } + assert_cluster_state ok } test "It is possible to write and read from the cluster" { |