"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/29-slot-migration-response.tcl" (21 Sep 2022, 1358 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 # Tests for the response of slot migrations.
    2 
    3 source "../tests/includes/init-tests.tcl"
    4 source "../tests/includes/utils.tcl"
    5 
    6 test "Create a 2 nodes cluster" {
    7     create_cluster 2 0
    8     config_set_all_nodes cluster-allow-replica-migration no
    9 }
   10 
   11 test "Cluster is up" {
   12     assert_cluster_state ok
   13 }
   14 
   15 set cluster [redis_cluster 127.0.0.1:[get_instance_attrib redis 0 port]]
   16 catch {unset nodefrom}
   17 catch {unset nodeto}
   18 
   19 $cluster refresh_nodes_map
   20 
   21 test "Set many keys in the cluster" {
   22     for {set i 0} {$i < 5000} {incr i} {
   23         $cluster set $i $i
   24         assert { [$cluster get $i] eq $i }
   25     }
   26 }
   27 
   28 test "Test cluster responses during migration of slot x" {
   29 
   30     set slot 10
   31     array set nodefrom [$cluster masternode_for_slot $slot]
   32     array set nodeto [$cluster masternode_notfor_slot $slot]
   33 
   34     $nodeto(link) cluster setslot $slot importing $nodefrom(id)
   35     $nodefrom(link) cluster setslot $slot migrating $nodeto(id)
   36 
   37     # Get a key from that slot
   38     set key [$nodefrom(link) cluster GETKEYSINSLOT $slot "1"]
   39 
   40     # MOVED REPLY
   41     assert_error "*MOVED*" {$nodeto(link) set $key "newVal"}
   42 
   43     # ASK REPLY
   44     assert_error "*ASK*" {$nodefrom(link) set "abc{$key}" "newVal"}
   45 
   46     # UNSTABLE REPLY
   47     assert_error "*TRYAGAIN*" {$nodefrom(link) mset "a{$key}" "newVal" $key "newVal2"}
   48 }
   49 
   50 config_set_all_nodes cluster-allow-replica-migration yes