summaryrefslogtreecommitdiff
path: root/tests/cluster
diff options
context:
space:
mode:
authorWen Hui <wen.hui.ware@gmail.com>2022-02-02 21:22:46 -0500
committerGitHub <noreply@github.com>2022-02-02 18:22:46 -0800
commitc9e1602f9016c169e1e72ce305aab53cbc97c616 (patch)
treebcfefa080752fbf53df9c8bb579caebb8dbb7961 /tests/cluster
parent8eb19cc251ae7bfd5c2fda9d4515b9ddfc5e2476 (diff)
downloadredis-c9e1602f9016c169e1e72ce305aab53cbc97c616.tar.gz
Add test case to improve code coverage for Addslotsrange and Delslotsrange command (#10128)
add more test cases for addslotsrange and delslotsrange
Diffstat (limited to 'tests/cluster')
-rw-r--r--tests/cluster/tests/23-multiple-slot-operations.tcl51
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/cluster/tests/23-multiple-slot-operations.tcl b/tests/cluster/tests/23-multiple-slot-operations.tcl
index 965ecd5af..0d1042739 100644
--- a/tests/cluster/tests/23-multiple-slot-operations.tcl
+++ b/tests/cluster/tests/23-multiple-slot-operations.tcl
@@ -33,7 +33,6 @@ set master3 [Rn 2]
set master4 [Rn 3]
set master5 [Rn 4]
-
test "Continuous slots distribution" {
assert_match "* 0-3276*" [$master1 CLUSTER NODES]
assert_match "* 3277-6552*" [$master2 CLUSTER NODES]
@@ -66,3 +65,53 @@ test "Continuous slots distribution" {
assert_match "* 13105-13500 14001-15000 16001-16383*" [$master5 CLUSTER NODES]
assert_match "*13105 13500*14001 15000*16001 16383*" [$master5 CLUSTER SLOTS]
}
+
+test "ADDSLOTSRANGE command with several boundary conditions test suite" {
+
+ # Add multiple slots with incorrect argument number
+ assert_error "ERR wrong number of arguments for 'addslotsrange' command" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030}
+
+ # Add multiple slots with invalid input slot
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 aaa}
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 70000}
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster ADDSLOTSRANGE 3001 3020 -1000 3030}
+
+ # Add multiple slots when start slot number is greater than the end slot
+ assert_error "ERR start slot number 3030 is greater than end slot number 3025" {R 0 cluster ADDSLOTSRANGE 3001 3020 3030 3025}
+
+ # Add multiple slots with busy slot
+ assert_error "ERR Slot 3200 is already busy" {R 0 cluster ADDSLOTSRANGE 3001 3020 3200 3250}
+
+ # Add multiple slots with assigned multiple times
+ assert_error "ERR Slot 3001 specified multiple times" {R 0 cluster ADDSLOTSRANGE 3001 3020 3001 3020}
+}
+
+test "DELSLOTSRANGE command with several boundary conditions test suite" {
+
+ # Delete multiple slots with incorrect argument number
+ assert_error "ERR wrong number of arguments for 'delslotsrange' command" {R 0 cluster DELSLOTSRANGE 1000 2000 2100}
+ assert_match "* 0-3000 3051-3276*" [$master1 CLUSTER NODES]
+ assert_match "*0 3000*3051 3276*" [$master1 CLUSTER SLOTS]
+
+ # Delete multiple slots with invalid input slot
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 2100 aaa}
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 2100 70000}
+ assert_error "ERR Invalid or out of range slot" {R 0 cluster DELSLOTSRANGE 1000 2000 -2100 2200}
+ assert_match "* 0-3000 3051-3276*" [$master1 CLUSTER NODES]
+ assert_match "*0 3000*3051 3276*" [$master1 CLUSTER SLOTS]
+
+ # Delete multiple slots when start slot number is greater than the end slot
+ assert_error "ERR start slot number 5800 is greater than end slot number 5750" {R 1 cluster DELSLOTSRANGE 5600 5700 5800 5750}
+ assert_match "* 3277-5000 5501-6552*" [$master2 CLUSTER NODES]
+ assert_match "*3277 5000*5501 6552*" [$master2 CLUSTER SLOTS]
+
+ # Delete multiple slots with already unassigned
+ assert_error "ERR Slot 7001 is already unassigned" {R 2 cluster DELSLOTSRANGE 7001 7100 9000 9200}
+ assert_match "* 6553-7000 7101-8000 8501-9828*" [$master3 CLUSTER NODES]
+ assert_match "*6553 7000*7101 8000*8501 9828*" [$master3 CLUSTER SLOTS]
+
+ # Delete multiple slots with assigned multiple times
+ assert_error "ERR Slot 12500 specified multiple times" {R 3 cluster DELSLOTSRANGE 12500 12600 12500 12600}
+ assert_match "* 9829-11000 12001-12100 12201-13104*" [$master4 CLUSTER NODES]
+ assert_match "*9829 11000*12001 12100*12201 13104*" [$master4 CLUSTER SLOTS]
+}