diff --git a/tests/cluster/tests/07-replica-migration.tcl b/tests/cluster/tests/07-replica-migration.tcl index 1e3efc9f..68231cd2 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 +test "Kill slave #7 of master #2. Only slave left is #12 now" { + kill_instance redis 7 +} -while {$failover_cycle != 2} { - incr failover_cycle - set current_epoch [CI 1 cluster_current_epoch] +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 "Killing master node #2, #12 should failover" { + kill_instance redis 2 +} - test "Killing master node #$new_master" { - kill_instance redis $new_master - } - - test "Wait for failover" { - wait_for_condition 1000 50 { - [CI 1 cluster_current_epoch] > $current_epoch - } else { - fail "No failover detected" - } - } - - test "Cluster should eventually be up again" { - assert_cluster_state ok - } - - test "Cluster is writable" { - cluster_write_test 1 - } - - 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}) - } - } - - if {![instance_is_killed redis 7] && [RI 7 role] eq {master}} { - set new_master 7 +test "Wait for failover" { + wait_for_condition 1000 50 { + [CI 1 cluster_current_epoch] > $current_epoch } else { - set new_master 12 + fail "No failover detected" } } +test "Cluster should eventually be up again" { + assert_cluster_state ok +} + +test "Cluster is writable" { + cluster_write_test 1 +} + +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" } }