1
0

01-conf-update.tcl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Test Sentinel configuration consistency after partitions heal.
  2. source "../tests/includes/init-tests.tcl"
  3. test "We can failover with Sentinel 1 crashed" {
  4. set old_port [RPort $master_id]
  5. set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
  6. assert {[lindex $addr 1] == $old_port}
  7. # Crash Sentinel 1
  8. kill_instance sentinel 1
  9. kill_instance redis $master_id
  10. foreach_sentinel_id id {
  11. if {$id != 1} {
  12. wait_for_condition 1000 50 {
  13. [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port
  14. } else {
  15. fail "Sentinel $id did not receive failover info"
  16. }
  17. }
  18. }
  19. restart_instance redis $master_id
  20. set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
  21. set master_id [get_instance_id_by_port redis [lindex $addr 1]]
  22. }
  23. test "After Sentinel 1 is restarted, its config gets updated" {
  24. restart_instance sentinel 1
  25. wait_for_condition 1000 50 {
  26. [lindex [S 1 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port
  27. } else {
  28. fail "Restarted Sentinel did not receive failover info"
  29. }
  30. }
  31. test "New master [join $addr {:}] role matches" {
  32. assert {[RI $master_id role] eq {master}}
  33. }