"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/17-diskless-load-swapdb.tcl" (21 Sep 2022, 2483 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 # Check that replica keys and keys to slots map are right after failing to diskless load using SWAPDB.
    2 
    3 source "../tests/includes/init-tests.tcl"
    4 
    5 test "Create a primary with a replica" {
    6     create_cluster 1 1
    7 }
    8 
    9 test "Cluster should start ok" {
   10     assert_cluster_state ok
   11 }
   12 
   13 test "Cluster is writable" {
   14     cluster_write_test 0
   15 }
   16 
   17 test "Main db not affected when fail to diskless load" {
   18     set master [Rn 0]
   19     set replica [Rn 1]
   20     set master_id 0
   21     set replica_id 1
   22 
   23     $replica READONLY
   24     $replica config set repl-diskless-load swapdb
   25     $replica config set appendonly no
   26     $replica config set save ""
   27     $replica config rewrite
   28     $master config set repl-backlog-size 1024
   29     $master config set repl-diskless-sync yes
   30     $master config set repl-diskless-sync-delay 0
   31     $master config set rdb-key-save-delay 10000
   32     $master config set rdbcompression no
   33     $master config set appendonly no
   34     $master config set save ""
   35 
   36     # Write a key that belongs to slot 0
   37     set slot0_key "06S"
   38     $master set $slot0_key 1
   39     wait_for_ofs_sync $master $replica
   40     assert_equal {1} [$replica get $slot0_key]
   41     assert_equal $slot0_key [$replica CLUSTER GETKEYSINSLOT 0 1]
   42 
   43     # Save an RDB and kill the replica
   44     $replica save
   45     kill_instance redis $replica_id
   46 
   47     # Delete the key from master
   48     $master del $slot0_key
   49 
   50     # Replica must full sync with master when start because replication
   51     # backlog size is very small, and dumping rdb will cost several seconds.
   52     set num 10000
   53     set value [string repeat A 1024]
   54     set rd [redis_deferring_client redis $master_id]
   55     for {set j 0} {$j < $num} {incr j} {
   56         $rd set $j $value
   57     }
   58     for {set j 0} {$j < $num} {incr j} {
   59         $rd read
   60     }
   61 
   62     # Start the replica again
   63     restart_instance redis $replica_id
   64     $replica READONLY
   65 
   66     # Start full sync, wait till after db started loading in background
   67     wait_for_condition 500 10 {
   68         [s $replica_id async_loading] eq 1
   69     } else {
   70         fail "Fail to full sync"
   71     }
   72 
   73     # Kill master, abort full sync
   74     kill_instance redis $master_id
   75 
   76     # Start full sync, wait till the replica detects the disconnection
   77     wait_for_condition 500 10 {
   78         [s $replica_id async_loading] eq 0
   79     } else {
   80         fail "Fail to full sync"
   81     }
   82 
   83     # Replica keys and keys to slots map still both are right
   84     assert_equal {1} [$replica get $slot0_key]
   85     assert_equal $slot0_key [$replica CLUSTER GETKEYSINSLOT 0 1]
   86 }