"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/08-update-msg.tcl" (21 Sep 2022, 1982 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 UPDATE messages sent by other nodes when the currently authorirative
    2 # master is unavailable. The test is performed in the following steps:
    3 #
    4 # 1) Master goes down.
    5 # 2) Slave failover and becomes new master.
    6 # 3) New master is partitioned away.
    7 # 4) Old master returns.
    8 # 5) At this point we expect the old master to turn into a slave ASAP because
    9 #    of the UPDATE messages it will receive from the other nodes when its
   10 #    configuration will be found to be outdated.
   11 
   12 source "../tests/includes/init-tests.tcl"
   13 
   14 test "Create a 5 nodes cluster" {
   15     create_cluster 5 5
   16 }
   17 
   18 test "Cluster is up" {
   19     assert_cluster_state ok
   20 }
   21 
   22 test "Cluster is writable" {
   23     cluster_write_test 0
   24 }
   25 
   26 test "Instance #5 is a slave" {
   27     assert {[RI 5 role] eq {slave}}
   28 }
   29 
   30 test "Instance #5 synced with the master" {
   31     wait_for_condition 1000 50 {
   32         [RI 5 master_link_status] eq {up}
   33     } else {
   34         fail "Instance #5 master link status is not up"
   35     }
   36 }
   37 
   38 set current_epoch [CI 1 cluster_current_epoch]
   39 
   40 test "Killing one master node" {
   41     kill_instance redis 0
   42 }
   43 
   44 test "Wait for failover" {
   45     wait_for_condition 1000 50 {
   46         [CI 1 cluster_current_epoch] > $current_epoch
   47     } else {
   48         fail "No failover detected"
   49     }
   50 }
   51 
   52 test "Cluster should eventually be up again" {
   53     assert_cluster_state ok
   54 }
   55 
   56 test "Cluster is writable" {
   57     cluster_write_test 1
   58 }
   59 
   60 test "Instance #5 is now a master" {
   61     assert {[RI 5 role] eq {master}}
   62 }
   63 
   64 test "Killing the new master #5" {
   65     kill_instance redis 5
   66 }
   67 
   68 test "Cluster should be down now" {
   69     assert_cluster_state fail
   70 }
   71 
   72 test "Restarting the old master node" {
   73     restart_instance redis 0
   74 }
   75 
   76 test "Instance #0 gets converted into a slave" {
   77     wait_for_condition 1000 50 {
   78         [RI 0 role] eq {slave}
   79     } else {
   80         fail "Old master was not converted into slave"
   81     }
   82 }
   83 
   84 test "Restarting the new master node" {
   85     restart_instance redis 5
   86 }
   87 
   88 test "Cluster is up again" {
   89     assert_cluster_state ok
   90 }