diff options
author | antirez <antirez@gmail.com> | 2014-05-23 11:41:50 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-05-23 15:54:53 +0200 |
commit | 29aed9c48ff9ec87a747922a769ca3a5bfc84028 (patch) | |
tree | b75adbae6da8aa40f4d5d03913950dad9cc585e8 | |
parent | 81af783fecfd303a68a840116e79478ba2d400d1 (diff) | |
download | redis-29aed9c48ff9ec87a747922a769ca3a5bfc84028.tar.gz |
Cluster test: move basic read/write test into a procedure.
-rw-r--r-- | tests/cluster/cluster.tcl | 22 | ||||
-rw-r--r-- | tests/cluster/tests/00-base.tcl | 10 |
2 files changed, 23 insertions, 9 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl index 46b4a6303..55f979f2f 100644 --- a/tests/cluster/cluster.tcl +++ b/tests/cluster/cluster.tcl @@ -106,3 +106,25 @@ proc create_cluster {masters slaves} { } assert_cluster_state ok } + +# Set the cluster node-timeout to all the reachalbe nodes. +proc set_cluster_node_timeout {to} { + foreach_redis_id id { + catch {R $id CONFIG SET cluster-node-timeout $to} + } +} + +# Check if the cluster is writable and readable. Use node "id" +# as a starting point to talk with the cluster. +proc cluster_write_test {id} { + set prefix [randstring 20 20 alpha] + set port [get_instance_attrib redis $id port] + set cluster [redis_cluster 127.0.0.1:$port] + for {set j 0} {$j < 100} {incr j} { + $cluster set key.$j $prefix.$j + } + for {set j 0} {$j < 100} {incr j} { + assert {[$cluster get key.$j] eq "$prefix.$j"} + } + $cluster close +} diff --git a/tests/cluster/tests/00-base.tcl b/tests/cluster/tests/00-base.tcl index 2c6585970..280befb9d 100644 --- a/tests/cluster/tests/00-base.tcl +++ b/tests/cluster/tests/00-base.tcl @@ -55,13 +55,5 @@ test "Nodes should report cluster_state is ok now" { } test "It is possible to write and read from the cluster" { - set port [get_instance_attrib redis 0 port] - set cluster [redis_cluster 127.0.0.1:$port] - for {set j 0} {$j < 100} {incr j} { - $cluster set key.$j $j - } - for {set j 0} {$j < 100} {incr j} { - assert {[$cluster get key.$j] eq $j} - } - $cluster close + cluster_write_test 0 } |