02-failover.tcl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Check the basic monitoring and failover capabilities.
  2. source "../tests/includes/init-tests.tcl"
  3. test "Create a 5 nodes cluster" {
  4. create_cluster 5 5
  5. }
  6. test "Cluster is up" {
  7. assert_cluster_state ok
  8. }
  9. test "Cluster is writable" {
  10. cluster_write_test 0
  11. }
  12. test "Instance #5 is a slave" {
  13. assert {[RI 5 role] eq {slave}}
  14. }
  15. test "Instance #5 synced with the master" {
  16. wait_for_condition 1000 50 {
  17. [RI 5 master_link_status] eq {up}
  18. } else {
  19. fail "Instance #5 master link status is not up"
  20. }
  21. }
  22. set current_epoch [CI 1 cluster_current_epoch]
  23. test "Killing one master node" {
  24. kill_instance redis 0
  25. }
  26. test "Wait for failover" {
  27. wait_for_condition 1000 50 {
  28. [CI 1 cluster_current_epoch] > $current_epoch
  29. } else {
  30. fail "No failover detected"
  31. }
  32. }
  33. test "Cluster should eventually be up again" {
  34. assert_cluster_state ok
  35. }
  36. test "Cluster is writable" {
  37. cluster_write_test 1
  38. }
  39. test "Instance #5 is now a master" {
  40. assert {[RI 5 role] eq {master}}
  41. }
  42. test "Restarting the previously killed master node" {
  43. restart_instance redis 0
  44. }
  45. test "Instance #0 gets converted into a slave" {
  46. wait_for_condition 1000 50 {
  47. [RI 0 role] eq {slave}
  48. } else {
  49. fail "Old master was not converted into slave"
  50. }
  51. }