"Fossies" - the Fresh Open Source Software Archive

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