"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/12.1-replica-migration-3.tcl" (21 Sep 2022, 1820 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 # Replica migration test #2.
    2 #
    3 # Check that if 'cluster-allow-replica-migration' is set to 'no', slaves do not
    4 # migrate when master becomes empty.
    5 
    6 source "../tests/includes/init-tests.tcl"
    7 source "../tests/includes/utils.tcl"
    8 
    9 # Create a cluster with 5 master and 15 slaves, to make sure there are no
   10 # empty masters and make rebalancing simpler to handle during the test.
   11 test "Create a 5 nodes cluster" {
   12     cluster_create_with_continuous_slots 5 15
   13 }
   14 
   15 test "Cluster is up" {
   16     assert_cluster_state ok
   17 }
   18 
   19 test "Each master should have at least two replicas attached" {
   20     foreach_redis_id id {
   21         if {$id < 5} {
   22             wait_for_condition 1000 50 {
   23                 [llength [lindex [R $id role] 2]] >= 2
   24             } else {
   25                 fail "Master #$id does not have 2 slaves as expected"
   26             }
   27         }
   28     }
   29 }
   30 
   31 test "Set allow-replica-migration no" {
   32     foreach_redis_id id {
   33         R $id CONFIG SET cluster-allow-replica-migration no
   34     }
   35 }
   36 
   37 set master0_id [dict get [get_myself 0] id]
   38 test "Resharding all the master #0 slots away from it" {
   39     set output [exec \
   40         ../../../src/redis-cli --cluster rebalance \
   41         127.0.0.1:[get_instance_attrib redis 0 port] \
   42         {*}[rediscli_tls_config "../../../tests"] \
   43         --cluster-weight ${master0_id}=0 >@ stdout ]
   44 }
   45 
   46 test "Wait cluster to be stable" {
   47     wait_cluster_stable
   48 }
   49 
   50 test "Master #0 still should have its replicas" {
   51     assert { [llength [lindex [R 0 role] 2]] >= 2 }
   52 }
   53 
   54 test "Each master should have at least two replicas attached" {
   55     foreach_redis_id id {
   56         if {$id < 5} {
   57             wait_for_condition 1000 50 {
   58                 [llength [lindex [R $id role] 2]] >= 2
   59             } else {
   60                 fail "Master #$id does not have 2 slaves as expected"
   61             }
   62         }
   63     }
   64 }
   65