"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/11-manual-takeover.tcl" (21 Sep 2022, 1555 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 # Manual takeover test
    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 # For this test, disable replica failover until
   18 # all of the primaries are confirmed killed. Otherwise
   19 # there might be enough time to elect a replica.
   20 set replica_ids { 5 6 7 }
   21 foreach id $replica_ids {
   22     R $id config set cluster-replica-no-failover yes
   23 }
   24 
   25 test "Killing majority of master nodes" {
   26     kill_instance redis 0
   27     kill_instance redis 1
   28     kill_instance redis 2
   29 }
   30 
   31 foreach id $replica_ids {
   32     R $id config set cluster-replica-no-failover no
   33 }
   34 
   35 test "Cluster should eventually be down" {
   36     assert_cluster_state fail
   37 }
   38 
   39 test "Use takeover to bring slaves back" {
   40     foreach id $replica_ids {
   41         R $id cluster failover takeover
   42     }
   43 }
   44 
   45 test "Cluster should eventually be up again" {
   46     assert_cluster_state ok
   47 }
   48 
   49 test "Cluster is writable" {
   50     cluster_write_test 4
   51 }
   52 
   53 test "Instance #5, #6, #7 are now masters" {
   54     foreach id $replica_ids {
   55         assert {[RI $id role] eq {master}}
   56     }
   57 }
   58 
   59 test "Restarting the previously killed master nodes" {
   60     restart_instance redis 0
   61     restart_instance redis 1
   62     restart_instance redis 2
   63 }
   64 
   65 test "Instance #0, #1, #2 gets converted into a slaves" {
   66     wait_for_condition 1000 50 {
   67         [RI 0 role] eq {slave} && [RI 1 role] eq {slave} && [RI 2 role] eq {slave}
   68     } else {
   69         fail "Old masters not converted into slaves"
   70     }
   71 }