"Fossies" - the Fresh Open Source Software Archive

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