aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl')
-rw-r--r--examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl182
1 files changed, 0 insertions, 182 deletions
diff --git a/examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl b/examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl
deleted file mode 100644
index 5d2d03e..0000000
--- a/examples/redis-unstable/tests/unit/cluster/multi-slot-operations.tcl
+++ /dev/null
@@ -1,182 +0,0 @@
1# This test uses a custom slot allocation for testing
2proc cluster_allocate_with_continuous_slots_local {n} {
3 R 0 cluster ADDSLOTSRANGE 0 3276
4 R 1 cluster ADDSLOTSRANGE 3277 6552
5 R 2 cluster ADDSLOTSRANGE 6553 9828
6 R 3 cluster ADDSLOTSRANGE 9829 13104
7 R 4 cluster ADDSLOTSRANGE 13105 16383
8}
9
10start_cluster 5 0 {tags {external:skip cluster}} {
11
12set master1 [srv 0 "client"]
13set master2 [srv -1 "client"]
14set master3 [srv -2 "client"]
15set master4 [srv -3 "client"]
16set master5 [srv -4 "client"]
17
18test "Continuous slots distribution" {
19 assert_match "* 0-3276*" [$master1 CLUSTER NODES]
20 assert_match "* 3277-6552*" [$master2 CLUSTER NODES]
21 assert_match "* 6553-9828*" [$master3 CLUSTER NODES]
22 assert_match "* 9829-13104*" [$master4 CLUSTER NODES]
23 assert_match "* 13105-16383*" [$master5 CLUSTER NODES]
24 assert_match "*0 3276*" [$master1 CLUSTER SLOTS]
25 assert_match "*3277 6552*" [$master2 CLUSTER SLOTS]
26 assert_match "*6553 9828*" [$master3 CLUSTER SLOTS]
27 assert_match "*9829 13104*" [$master4 CLUSTER SLOTS]
28 assert_match "*13105 16383*" [$master5 CLUSTER SLOTS]
29
30 $master1 CLUSTER DELSLOTSRANGE 3001 3050
31 assert_match "* 0-3000 3051-3276*" [$master1 CLUSTER NODES]
32 assert_match "*0 3000*3051 3276*" [$master1 CLUSTER SLOTS]
33
34 $master2 CLUSTER DELSLOTSRANGE 5001 5500
35 assert_match "* 3277-5000 5501-6552*" [$master2 CLUSTER NODES]
36 assert_match "*3277 5000*5501 6552*" [$master2 CLUSTER SLOTS]
37
38 $master3 CLUSTER DELSLOTSRANGE 7001 7100 8001 8500
39 assert_match "* 6553-7000 7101-8000 8501-9828*" [$master3 CLUSTER NODES]
40 assert_match "*6553 7000*7101 8000*8501 9828*" [$master3 CLUSTER SLOTS]
41
42 $master4 CLUSTER DELSLOTSRANGE 11001 12000 12101 12200
43 assert_match "* 9829-11000 12001-12100 12201-13104*" [$master4 CLUSTER NODES]
44 assert_match "*9829 11000*12001 12100*12201 13104*" [$master4 CLUSTER SLOTS]
45
46 $master5 CLUSTER DELSLOTSRANGE 13501 14000 15001 16000
47 assert_match "* 13105-13500 14001-15000 16001-16383*" [$master5 CLUSTER NODES]
48 assert_match "*13105 13500*14001 15000*16001 16383*" [$master5 CLUSTER SLOTS]
49}
50
51test "ADDSLOTS command with several boundary conditions test suite" {
52 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTS 3001 aaa}
53 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTS 3001 -1000}
54 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTS 3001 30003}
55
56 assert_error "ERR Slot 3200 is already busy" {R 0 cluster ADDSLOTS 3200}
57 assert_error "ERR Slot 8501 is already busy" {R 0 cluster ADDSLOTS 8501}
58
59 assert_error "ERR Slot 3001 specified multiple times" {R 0 cluster ADDSLOTS 3001 3002 3001}
60}
61
62test "ADDSLOTSRANGE command with several boundary conditions test suite" {
63 # Add multiple slots with incorrect argument number
64 assert_error "ERR wrong number of arguments for 'cluster|addslotsrange' command" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030}
65
66 # Add multiple slots with invalid input slot
67 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 aaa}
68 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 70000}
69 assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 -1000 3030}
70
71 # Add multiple slots when start slot number is greater than the end slot
72 assert_error "ERR start slot number 3030 is greater than end slot number 3025" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 3025}
73
74 # Add multiple slots with busy slot
75 assert_error "ERR Slot 3200 is already busy" {R 0 cluster ADDSLOTSRANGE 3001 3020 3200 3250}
76
77 # Add multiple slots with assigned multiple times
78 assert_error "ERR Slot 3001 specified multiple times" {R 0 cluster ADDSLOTSRANGE 3001 3020 3001 3020}
79}
80
81test "DELSLOTSRANGE command with several boundary conditions test suite" {
82 # Delete multiple slots with incorrect argument number
83 assert_error "ERR wrong number of arguments for 'cluster|delslotsrange' command" {R 0 cluster DELSLOTSRANGE 1000 2000 2100}
84 assert_match "* 0-3000 3051-3276*" [$master1 CLUSTER NODES]
85 assert_match "*0 3000*3051 3276*" [$master1 CLUSTER SLOTS]
86
87 # Delete multiple slots with invalid input slot
88 assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 2100 aaa}
89 assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 2100 70000}
90 assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 -2100 2200}
91 assert_match "* 0-3000 3051-3276*" [$master1 CLUSTER NODES]
92 assert_match "*0 3000*3051 3276*" [$master1 CLUSTER SLOTS]
93
94 # Delete multiple slots when start slot number is greater than the end slot
95 assert_error "ERR start slot number 5800 is greater than end slot number 5750" {R 1 cluster DELSLOTSRANGE 5600 5700 5800 5750}
96 assert_match "* 3277-5000 5501-6552*" [$master2 CLUSTER NODES]
97 assert_match "*3277 5000*5501 6552*" [$master2 CLUSTER SLOTS]
98
99 # Delete multiple slots with already unassigned
100 assert_error "ERR Slot 7001 is already unassigned" {R 2 cluster DELSLOTSRANGE 7001 7100 9000 9200}
101 assert_match "* 6553-7000 7101-8000 8501-9828*" [$master3 CLUSTER NODES]
102 assert_match "*6553 7000*7101 8000*8501 9828*" [$master3 CLUSTER SLOTS]
103
104 # Delete multiple slots with assigned multiple times
105 assert_error "ERR Slot 12500 specified multiple times" {R 3 cluster DELSLOTSRANGE 12500 12600 12500 12600}
106 assert_match "* 9829-11000 12001-12100 12201-13104*" [$master4 CLUSTER NODES]
107 assert_match "*9829 11000*12001 12100*12201 13104*" [$master4 CLUSTER SLOTS]
108}
109} cluster_allocate_with_continuous_slots_local
110
111start_cluster 2 0 {tags {external:skip cluster experimental}} {
112
113set master1 [srv 0 "client"]
114set master2 [srv -1 "client"]
115
116test "SFLUSH - Errors and output validation" {
117 assert_match "* 0-8191*" [$master1 CLUSTER NODES]
118 assert_match "* 8192-16383*" [$master2 CLUSTER NODES]
119 assert_match "*0 8191*" [$master1 CLUSTER SLOTS]
120 assert_match "*8192 16383*" [$master2 CLUSTER SLOTS]
121
122 # make master1 non-continuous slots
123 $master1 cluster DELSLOTSRANGE 1000 2000
124
125 # Test SFLUSH errors validation
126 assert_error {ERR wrong number of arguments*} {$master1 SFLUSH 4}
127 assert_error {ERR wrong number of arguments*} {$master1 SFLUSH 4 SYNC}
128 assert_error {ERR Invalid or out of range slot} {$master1 SFLUSH x 4}
129 assert_error {ERR Invalid or out of range slot} {$master1 SFLUSH 0 12x}
130 assert_error {ERR Slot 3 specified multiple times} {$master1 SFLUSH 2 4 3 5}
131 assert_error {ERR start slot number 8 is greater than*} {$master1 SFLUSH 8 4}
132 assert_error {ERR wrong number of arguments*} {$master1 SFLUSH 4 8 10}
133 assert_error {ERR wrong number of arguments*} {$master1 SFLUSH 0 999 2001 8191 ASYNCX}
134
135 # Test SFLUSH output validation
136 assert_match "" [$master1 SFLUSH 2 4]
137 assert_match "" [$master1 SFLUSH 0 4]
138 assert_match "" [$master2 SFLUSH 0 4]
139 assert_match "" [$master1 SFLUSH 1 8191]
140 assert_match "" [$master1 SFLUSH 0 8190]
141 assert_match "" [$master1 SFLUSH 0 998 2001 8191]
142 assert_match "" [$master1 SFLUSH 1 999 2001 8191]
143 assert_match "" [$master1 SFLUSH 0 999 2001 8190]
144 assert_match "" [$master1 SFLUSH 0 999 2002 8191]
145 assert_match "{0 999} {2001 8191}" [$master1 SFLUSH 0 999 2001 8191]
146 assert_match "{0 999} {2001 8191}" [$master1 SFLUSH 0 8191]
147 assert_match "{0 999} {2001 8191}" [$master1 SFLUSH 0 4000 4001 8191]
148 assert_match "" [$master2 SFLUSH 8193 16383]
149 assert_match "" [$master2 SFLUSH 8192 16382]
150 assert_match "{8192 16383}" [$master2 SFLUSH 8192 16383]
151 assert_match "{8192 16383}" [$master2 SFLUSH 8192 16383 SYNC]
152 assert_match "{8192 16383}" [$master2 SFLUSH 8192 16383 ASYNC]
153 assert_match "{8192 16383}" [$master2 SFLUSH 8192 9000 9001 16383]
154 assert_match "{8192 16383}" [$master2 SFLUSH 8192 9000 9001 16383 SYNC]
155 assert_match "{8192 16383}" [$master2 SFLUSH 8192 9000 9001 16383 ASYNC]
156
157 # restore master1 continuous slots
158 $master1 cluster ADDSLOTSRANGE 1000 2000
159}
160
161test "SFLUSH - Deletes the keys with argument <NONE>/SYNC/ASYNC" {
162 foreach op {"" "SYNC" "ASYNC"} {
163 for {set i 0} {$i < 100} {incr i} {
164 catch {$master1 SET key$i val$i}
165 catch {$master2 SET key$i val$i}
166 }
167
168 assert {[$master1 DBSIZE] > 0}
169 assert {[$master2 DBSIZE] > 0}
170 if {$op eq ""} {
171 assert_match "{0 8191}" [ $master1 SFLUSH 0 8191]
172 } else {
173 assert_match "{0 8191}" [ $master1 SFLUSH 0 8191 $op]
174 }
175 assert {[$master1 DBSIZE] == 0}
176 assert {[$master2 DBSIZE] > 0}
177 assert_match "{8192 16383}" [ $master2 SFLUSH 8192 16383]
178 assert {[$master2 DBSIZE] == 0}
179 }
180}
181
182}