"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/cluster/tests/18-info.tcl" (21 Sep 2022, 1211 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 cluster info stats
    2 
    3 source "../tests/includes/init-tests.tcl"
    4 
    5 test "Create a primary with a replica" {
    6     create_cluster 2 0
    7 }
    8 
    9 test "Cluster should start ok" {
   10     assert_cluster_state ok
   11 }
   12 
   13 set primary1 [Rn 0]
   14 set primary2 [Rn 1]
   15 
   16 proc cmdstat {instance cmd} {
   17     return [cmdrstat $cmd $instance]
   18 }
   19 
   20 proc errorstat {instance cmd} {
   21     return [errorrstat $cmd $instance]
   22 }
   23 
   24 test "errorstats: rejected call due to MOVED Redirection" {
   25     $primary1 config resetstat
   26     $primary2 config resetstat
   27     assert_match {} [errorstat $primary1 MOVED]
   28     assert_match {} [errorstat $primary2 MOVED]
   29     # we know that one will have a MOVED reply and one will succeed
   30     catch {$primary1 set key b} replyP1
   31     catch {$primary2 set key b} replyP2
   32     # sort servers so we know which one failed
   33     if {$replyP1 eq {OK}} {
   34         assert_match {MOVED*} $replyP2
   35         set pok $primary1
   36         set perr $primary2
   37     } else {
   38         assert_match {MOVED*} $replyP1
   39         set pok $primary2
   40         set perr $primary1
   41     }
   42     assert_match {} [errorstat $pok MOVED]
   43     assert_match {*count=1*} [errorstat $perr MOVED]
   44     assert_match {*calls=0,*,rejected_calls=1,failed_calls=0} [cmdstat $perr set]
   45 }