"Fossies" - the Fresh Open Source Software Archive

Member "redis-6.0.8/tests/cluster/tests/16-transactions-on-replica.tcl" (10 Sep 2020, 1187 Bytes) of package /linux/misc/redis-6.0.8.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 and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # Check basic transactions on a replica.
    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 set primary [Rn 0]
   14 set replica [Rn 1]
   15 
   16 test "Cant read from replica without READONLY" {
   17     $primary SET a 1
   18     catch {$replica GET a} err
   19     assert {[string range $err 0 4] eq {MOVED}}
   20 }
   21 
   22 test "Can read from replica after READONLY" {
   23     $replica READONLY
   24     assert {[$replica GET a] eq {1}}
   25 }
   26 
   27 test "Can preform HSET primary and HGET from replica" {
   28     $primary HSET h a 1
   29     $primary HSET h b 2
   30     $primary HSET h c 3
   31     assert {[$replica HGET h a] eq {1}}
   32     assert {[$replica HGET h b] eq {2}}
   33     assert {[$replica HGET h c] eq {3}}
   34 }
   35 
   36 test "Can MULTI-EXEC transaction of HGET operations from replica" {
   37     $replica MULTI
   38     assert {[$replica HGET h a] eq {QUEUED}}
   39     assert {[$replica HGET h b] eq {QUEUED}}
   40     assert {[$replica HGET h c] eq {QUEUED}}
   41     assert {[$replica EXEC] eq {1 2 3}}
   42 }
   43 
   44 test "MULTI-EXEC with write operations is MOVED" {
   45     $replica MULTI
   46     catch {$replica HSET h b 4} err
   47     assert {[string range $err 0 4] eq {MOVED}}
   48 }