summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-12-10 12:58:28 +0100
committerantirez <antirez@gmail.com>2015-12-10 13:00:18 +0100
commit5ad4f7e0b1606687de383fddc894cf14a2dddcd9 (patch)
tree78d0944040b3e380f4ed0a7ee3c2921ab3bada48
parent711bf140f3b9f600a4bd028f787bab5364fc7368 (diff)
downloadredis-5ad4f7e0b1606687de383fddc894cf14a2dddcd9.tar.gz
Cluster: more reliable migration tests.
The old version was modeled with two failovers, however after the first it is possible that another slave will migrate to the new master, since for some time the new master is not backed by any slave. Probably there should be some pause after a failover, before the migration. Anyway the test is simpler in this way, and depends less on timing.
-rw-r--r--tests/cluster/tests/07-replica-migration.tcl67
1 files changed, 24 insertions, 43 deletions
diff --git a/tests/cluster/tests/07-replica-migration.tcl b/tests/cluster/tests/07-replica-migration.tcl
index 1e3efc9ff..68231cd28 100644
--- a/tests/cluster/tests/07-replica-migration.tcl
+++ b/tests/cluster/tests/07-replica-migration.tcl
@@ -61,62 +61,43 @@ test "Cluster is up" {
assert_cluster_state ok
}
-set failover_cycle 0
-set new_master 2
-
-while {$failover_cycle != 2} {
- incr failover_cycle
- set current_epoch [CI 1 cluster_current_epoch]
-
- test "Wait for slave of #$new_master to sync" {
- wait_for_condition 1000 50 {
- [string match {*state=online*} [RI $new_master slave0]]
- } else {
- fail "Slave of node #$new_master is not ok"
- }
- }
+test "Kill slave #7 of master #2. Only slave left is #12 now" {
+ kill_instance redis 7
+}
- test "Killing master node #$new_master" {
- kill_instance redis $new_master
- }
+set current_epoch [CI 1 cluster_current_epoch]
- test "Wait for failover" {
- wait_for_condition 1000 50 {
- [CI 1 cluster_current_epoch] > $current_epoch
- } else {
- fail "No failover detected"
- }
- }
+test "Killing master node #2, #12 should failover" {
+ kill_instance redis 2
+}
- test "Cluster should eventually be up again" {
- assert_cluster_state ok
+test "Wait for failover" {
+ wait_for_condition 1000 50 {
+ [CI 1 cluster_current_epoch] > $current_epoch
+ } else {
+ fail "No failover detected"
}
+}
- test "Cluster is writable" {
- cluster_write_test 1
- }
+test "Cluster should eventually be up again" {
+ assert_cluster_state ok
+}
- test "Instance #7 or #12 is now a master" {
- assert {
- (![instance_is_killed redis 7] && [RI 7 role] eq {master}) ||
- (![instance_is_killed redis 12] && [RI 12 role] eq {master})
- }
- }
+test "Cluster is writable" {
+ cluster_write_test 1
+}
- if {![instance_is_killed redis 7] && [RI 7 role] eq {master}} {
- set new_master 7
- } else {
- set new_master 12
- }
+test "Instance 12 is now a master without slaves" {
+ assert {[RI 12 role] eq {master}}
}
# The remaining instance is now without slaves. Some other slave
# should migrate to it.
-test "Master #$new_master should have at least one replica" {
+test "Master #12 should get at least one migrated replica" {
wait_for_condition 1000 50 {
- [llength [lindex [R $new_master role] 2]] >= 1
+ [llength [lindex [R 12 role] 2]] >= 1
} else {
- fail "Master #$new_master has no replicas"
+ fail "Master #12 has no replicas"
}
}