"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/19-cluster-nodes-slots.tcl" (21 Sep 2022, 1884 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 # Optimize CLUSTER NODES command by generating all nodes slot topology firstly
    2 
    3 source "../tests/includes/init-tests.tcl"
    4 
    5 test "Create a 2 nodes cluster" {
    6     cluster_create_with_continuous_slots 2 2
    7 }
    8 
    9 test "Cluster should start ok" {
   10     assert_cluster_state ok
   11 }
   12 
   13 set master1 [Rn 0]
   14 set master2 [Rn 1]
   15 
   16 test "Continuous slots distribution" {
   17     assert_match "* 0-8191*" [$master1 CLUSTER NODES]
   18     assert_match "* 8192-16383*" [$master2 CLUSTER NODES]
   19     assert_match "*0 8191*" [$master1 CLUSTER SLOTS]
   20     assert_match "*8192 16383*" [$master2 CLUSTER SLOTS]
   21 
   22     $master1 CLUSTER DELSLOTS 4096
   23     assert_match "* 0-4095 4097-8191*" [$master1 CLUSTER NODES]
   24     assert_match "*0 4095*4097 8191*" [$master1 CLUSTER SLOTS]
   25 
   26 
   27     $master2 CLUSTER DELSLOTS 12288
   28     assert_match "* 8192-12287 12289-16383*" [$master2 CLUSTER NODES]
   29     assert_match "*8192 12287*12289 16383*" [$master2 CLUSTER SLOTS]
   30 }
   31 
   32 test "Discontinuous slots distribution" {
   33     # Remove middle slots
   34     $master1 CLUSTER DELSLOTS 4092 4094
   35     assert_match "* 0-4091 4093 4095 4097-8191*" [$master1 CLUSTER NODES]
   36     assert_match "*0 4091*4093 4093*4095 4095*4097 8191*" [$master1 CLUSTER SLOTS]
   37     $master2 CLUSTER DELSLOTS 12284 12286
   38     assert_match "* 8192-12283 12285 12287 12289-16383*" [$master2 CLUSTER NODES]
   39     assert_match "*8192 12283*12285 12285*12287 12287*12289 16383*" [$master2 CLUSTER SLOTS]
   40 
   41     # Remove head slots
   42     $master1 CLUSTER DELSLOTS 0 2
   43     assert_match "* 1 3-4091 4093 4095 4097-8191*" [$master1 CLUSTER NODES]
   44     assert_match "*1 1*3 4091*4093 4093*4095 4095*4097 8191*" [$master1 CLUSTER SLOTS]
   45 
   46     # Remove tail slots
   47     $master2 CLUSTER DELSLOTS 16380 16382 16383
   48     assert_match "* 8192-12283 12285 12287 12289-16379 16381*" [$master2 CLUSTER NODES]
   49     assert_match "*8192 12283*12285 12285*12287 12287*12289 16379*16381 16381*" [$master2 CLUSTER SLOTS]
   50 }