summaryrefslogtreecommitdiff
path: root/tests/cluster/cluster.tcl
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-29 18:40:43 +0200
committerantirez <antirez@gmail.com>2014-04-29 18:40:43 +0200
commit7b5ce1ffb1d730774f1d8e990fea38e9ab54a148 (patch)
tree41039b274ec2130bd0b492564f8d04edcb6f951b /tests/cluster/cluster.tcl
parent4a3db2550441423f84c964a0d519426cf44020dc (diff)
downloadredis-7b5ce1ffb1d730774f1d8e990fea38e9ab54a148.tar.gz
Cluster test: slots allocation.
Diffstat (limited to 'tests/cluster/cluster.tcl')
-rw-r--r--tests/cluster/cluster.tcl19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl
index f85f96fd6..824f3a80f 100644
--- a/tests/cluster/cluster.tcl
+++ b/tests/cluster/cluster.tcl
@@ -42,3 +42,22 @@ proc get_myself id {
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}]
+ }
+}