summaryrefslogtreecommitdiff
path: root/tests/cluster/tests
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-05-02 18:36:09 +0200
committerantirez <antirez@gmail.com>2016-05-02 18:37:37 +0200
commit9c48f28e54336c07d5d7764293e41fe6f753d95d (patch)
tree77513f4f9f7051671ecb091b365efcf6f8e50538 /tests/cluster/tests
parent4fdde78c72ac18f51460be9ac96d1d638a969c9d (diff)
downloadredis-9c48f28e54336c07d5d7764293e41fe6f753d95d.tar.gz
Cluster regression test for #3043.
The test works but is very slow so far, since it involves resharding 1/5 of all the cluster slots from master 0 to the other 4 masters and back into the original master.
Diffstat (limited to 'tests/cluster/tests')
-rw-r--r--tests/cluster/tests/12-replica-migration-2.tcl61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/cluster/tests/12-replica-migration-2.tcl b/tests/cluster/tests/12-replica-migration-2.tcl
new file mode 100644
index 000000000..36a89d4bc
--- /dev/null
+++ b/tests/cluster/tests/12-replica-migration-2.tcl
@@ -0,0 +1,61 @@
+# Replica migration test #2.
+#
+# Check that the status of master that can be targeted by replica migration
+# is acquired again, after being getting slots again, in a cluster where the
+# other masters have slaves.
+
+source "../tests/includes/init-tests.tcl"
+
+# Create a cluster with 5 master and 10 slaves, so that we have 2
+# slaves for each master.
+test "Create a 5 nodes cluster" {
+ create_cluster 5 10
+}
+
+test "Cluster is up" {
+ assert_cluster_state ok
+}
+
+test "Each master should have two replicas attached" {
+ foreach_redis_id id {
+ if {$id < 5} {
+ wait_for_condition 1000 50 {
+ [llength [lindex [R 0 role] 2]] == 2
+ } else {
+ fail "Master #$id does not have 2 slaves as expected"
+ }
+ }
+ }
+}
+
+set master0_id [dict get [get_myself 0] id]
+test "Resharding all the master #0 slots away from it" {
+ set output [exec \
+ ../../../src/redis-trib.rb rebalance \
+ --weight ${master0_id}=0 \
+ 127.0.0.1:[get_instance_attrib redis 0 port] >@ stdout]
+}
+
+test "Master #0 should lose its replicas" {
+ wait_for_condition 1000 50 {
+ [llength [lindex [R 0 role] 2]] == 0
+ } else {
+ fail "Master #0 still has replicas"
+ }
+}
+
+test "Resharding all the master #0 slots back to it" {
+ set output [exec \
+ ../../../src/redis-trib.rb rebalance \
+ --weight ${master0_id}=1 \
+ --use-empty-masters \
+ 127.0.0.1:[get_instance_attrib redis 0 port]]
+}
+
+test "Master #0 should re-acquire one or more replicas" {
+ wait_for_condition 1000 50 {
+ [llength [lindex [R 0 role] 2]] >= 1
+ } else {
+ fail "Master #0 has no has replicas"
+ }
+}