Sentinel test: 02 unit better coverage + refactoring.
This commit is contained in:
parent
c870142fca
commit
ebdf5ddfa9
@ -13,6 +13,7 @@ proc 03_test_slaves_replication {} {
|
|||||||
set master_port [RI $master_id tcp_port]
|
set master_port [RI $master_id tcp_port]
|
||||||
foreach_redis_id id {
|
foreach_redis_id id {
|
||||||
if {$id == $master_id} continue
|
if {$id == $master_id} continue
|
||||||
|
if {[instance_is_killed redis $id]} continue
|
||||||
wait_for_condition 1000 50 {
|
wait_for_condition 1000 50 {
|
||||||
[RI $id master_port] == $master_port
|
[RI $id master_port] == $master_port
|
||||||
} else {
|
} else {
|
||||||
@ -23,9 +24,9 @@ proc 03_test_slaves_replication {} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
03_test_slaves_replication
|
proc 03_crash_and_failover {} {
|
||||||
|
uplevel 1 {
|
||||||
test "Crash the master and force a failover" {
|
test "Crash the master and force a failover" {
|
||||||
set old_port [RI $master_id tcp_port]
|
set old_port [RI $master_id tcp_port]
|
||||||
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
|
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
|
||||||
assert {[lindex $addr 1] == $old_port}
|
assert {[lindex $addr 1] == $old_port}
|
||||||
@ -40,6 +41,43 @@ test "Crash the master and force a failover" {
|
|||||||
restart_instance redis $master_id
|
restart_instance redis $master_id
|
||||||
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
|
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
|
||||||
set master_id [get_instance_id_by_port redis [lindex $addr 1]]
|
set master_id [get_instance_id_by_port redis [lindex $addr 1]]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
03_test_slaves_replication
|
03_test_slaves_replication
|
||||||
|
03_crash_and_failover
|
||||||
|
03_test_slaves_replication
|
||||||
|
|
||||||
|
test "Kill a slave instance" {
|
||||||
|
foreach_redis_id id {
|
||||||
|
if {$id == $master_id} continue
|
||||||
|
set killed_slave_id $id
|
||||||
|
kill_instance redis $id
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
03_crash_and_failover
|
||||||
|
03_test_slaves_replication
|
||||||
|
|
||||||
|
test "Wait for failover to end" {
|
||||||
|
set inprogress 1
|
||||||
|
while {$inprogress} {
|
||||||
|
set inprogress 0
|
||||||
|
foreach_sentinel_id id {
|
||||||
|
if {[dict exists [S $id SENTINEL MASTER mymaster] failover-state]} {
|
||||||
|
incr inprogress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$inprogress} {after 100}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test "Restart killed slave and test replication of slaves again..." {
|
||||||
|
restart_instance redis $killed_slave_id
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now we check if the slave rejoining the partition is reconfigured even
|
||||||
|
# if the failover finished.
|
||||||
|
03_test_slaves_replication
|
||||||
|
Loading…
x
Reference in New Issue
Block a user