06-ckquorum.tcl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Test for the SENTINEL CKQUORUM command
  2. source "../tests/includes/init-tests.tcl"
  3. set num_sentinels [llength $::sentinel_instances]
  4. test "CKQUORUM reports OK and the right amount of Sentinels" {
  5. foreach_sentinel_id id {
  6. assert_match "*OK $num_sentinels usable*" [S $id SENTINEL CKQUORUM mymaster]
  7. }
  8. }
  9. test "CKQUORUM detects quorum cannot be reached" {
  10. set orig_quorum [expr {$num_sentinels/2+1}]
  11. S 0 SENTINEL SET mymaster quorum [expr {$num_sentinels+1}]
  12. catch {[S 0 SENTINEL CKQUORUM mymaster]} err
  13. assert_match "*NOQUORUM*" $err
  14. S 0 SENTINEL SET mymaster quorum $orig_quorum
  15. }
  16. test "CKQUORUM detects failover authorization cannot be reached" {
  17. set orig_quorum [expr {$num_sentinels/2+1}]
  18. S 0 SENTINEL SET mymaster quorum 1
  19. for {set i 0} {$i < $orig_quorum} {incr i} {
  20. kill_instance sentinel [expr {$i + 1}]
  21. }
  22. after 5000
  23. catch {[S 0 SENTINEL CKQUORUM mymaster]} err
  24. assert_match "*NOQUORUM*" $err
  25. S 0 SENTINEL SET mymaster quorum $orig_quorum
  26. for {set i 0} {$i < $orig_quorum} {incr i} {
  27. restart_instance sentinel [expr {$i + 1}]
  28. }
  29. }