summaryrefslogtreecommitdiff
path: root/tests/cluster
diff options
context:
space:
mode:
authoryanhui13 <yanhui13@meituan.com>2020-04-21 16:56:10 +0800
committeryanhui13 <yanhui13@meituan.com>2020-04-21 16:56:10 +0800
commit6b547c395692a2f124e573e3e79b0866c024a28d (patch)
tree8b900bedb5d38bec7a41d0592f9a3adabaa75d6d /tests/cluster
parent92974f9a98d22c96ec3bbd68002dacfaeb3c7960 (diff)
downloadredis-6b547c395692a2f124e573e3e79b0866c024a28d.tar.gz
add tcl test for cluster slots
Diffstat (limited to 'tests/cluster')
-rw-r--r--tests/cluster/tests/15-cluster-slots.tcl44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/cluster/tests/15-cluster-slots.tcl b/tests/cluster/tests/15-cluster-slots.tcl
new file mode 100644
index 000000000..dc9938ef6
--- /dev/null
+++ b/tests/cluster/tests/15-cluster-slots.tcl
@@ -0,0 +1,44 @@
+source "../tests/includes/init-tests.tcl"
+
+proc cluster_allocate_mixedSlots {n} {
+ set slot 16383
+ while {$slot >= 0} {
+ set node [expr {$slot % $n}]
+ lappend slots_$node $slot
+ incr slot -1
+ }
+ for {set j 0} {$j < $n} {incr j} {
+ R $j cluster addslots {*}[set slots_${j}]
+ }
+}
+
+proc create_cluster_with_mixedSlot {masters slaves} {
+ cluster_allocate_mixedSlots $masters
+ if {$slaves} {
+ cluster_allocate_slaves $masters $slaves
+ }
+ assert_cluster_state ok
+}
+
+test "Create a 5 nodes cluster" {
+ create_cluster_with_mixedSlot 5 15
+}
+
+test "Cluster is up" {
+ assert_cluster_state ok
+}
+
+test "Cluster is writable" {
+ cluster_write_test 0
+}
+
+test "Instance #5 is a slave" {
+ assert {[RI 5 role] eq {slave}}
+}
+
+test "client do not break when cluster slot" {
+ R 0 config set client-output-buffer-limit "normal 33554432 16777216 60"
+ if { [catch {R 0 cluster slots}] } {
+ fail "output overflow when cluster slots"
+ }
+} \ No newline at end of file