"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/sentinel/tests/06-ckquorum.tcl" (21 Sep 2022, 1418 Bytes) of package /linux/misc/redis-7.0.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Test for the SENTINEL CKQUORUM command
    2 
    3 source "../tests/includes/init-tests.tcl"
    4 set num_sentinels [llength $::sentinel_instances]
    5 
    6 test "CKQUORUM reports OK and the right amount of Sentinels" {
    7     foreach_sentinel_id id {
    8         assert_match "*OK $num_sentinels usable*" [S $id SENTINEL CKQUORUM mymaster]
    9     }
   10 }
   11 
   12 test "CKQUORUM detects quorum cannot be reached" {
   13     set orig_quorum [expr {$num_sentinels/2+1}]
   14     S 0 SENTINEL SET mymaster quorum [expr {$num_sentinels+1}]
   15     catch {[S 0 SENTINEL CKQUORUM mymaster]} err
   16     assert_match "*NOQUORUM*" $err
   17     S 0 SENTINEL SET mymaster quorum $orig_quorum
   18 }
   19 
   20 test "CKQUORUM detects failover authorization cannot be reached" {
   21     set orig_quorum [expr {$num_sentinels/2+1}]
   22     S 0 SENTINEL SET mymaster quorum 1
   23     for {set i 0} {$i < $orig_quorum} {incr i} {
   24         kill_instance sentinel [expr {$i + 1}]
   25     }
   26 
   27     # We need to make sure that other sentinels are in `DOWN` state
   28     # from the point of view of S 0 before we executing `CKQUORUM`.
   29     wait_for_condition 300 50 {
   30         [catch {S 0 SENTINEL CKQUORUM mymaster}] == 1
   31     } else {
   32         fail "At least $orig_quorum sentinels did not enter the down state."
   33     }
   34 
   35     assert_error "*NOQUORUM*" {S 0 SENTINEL CKQUORUM mymaster}
   36 
   37     S 0 SENTINEL SET mymaster quorum $orig_quorum
   38     for {set i 0} {$i < $orig_quorum} {incr i} {
   39         restart_instance sentinel [expr {$i + 1}]
   40     }
   41 }
   42