"Fossies" - the Fresh Open Source Software Archive

Member "redis-6.0.8/tests/unit/introspection.tcl" (10 Sep 2020, 4847 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. See also the latest Fossies "Diffs" side-by-side code changes report for "introspection.tcl": 6.0.7_vs_6.0.8.

    1 start_server {tags {"introspection"}} {
    2     test {CLIENT LIST} {
    3         r client list
    4     } {*addr=*:* fd=* age=* idle=* flags=N db=9 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=* obl=0 oll=0 omem=0 events=r cmd=client*}
    5 
    6     test {MONITOR can log executed commands} {
    7         set rd [redis_deferring_client]
    8         $rd monitor
    9         assert_match {*OK*} [$rd read]
   10         r set foo bar
   11         r get foo
   12         list [$rd read] [$rd read]
   13     } {*"set" "foo"*"get" "foo"*}
   14 
   15     test {MONITOR can log commands issued by the scripting engine} {
   16         set rd [redis_deferring_client]
   17         $rd monitor
   18         $rd read ;# Discard the OK
   19         r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar
   20         assert_match {*eval*} [$rd read]
   21         assert_match {*lua*"set"*"foo"*"bar"*} [$rd read]
   22     }
   23 
   24     test {CLIENT GETNAME should return NIL if name is not assigned} {
   25         r client getname
   26     } {}
   27 
   28     test {CLIENT LIST shows empty fields for unassigned names} {
   29         r client list
   30     } {*name= *}
   31 
   32     test {CLIENT SETNAME does not accept spaces} {
   33         catch {r client setname "foo bar"} e
   34         set e
   35     } {ERR*}
   36 
   37     test {CLIENT SETNAME can assign a name to this connection} {
   38         assert_equal [r client setname myname] {OK}
   39         r client list
   40     } {*name=myname*}
   41 
   42     test {CLIENT SETNAME can change the name of an existing connection} {
   43         assert_equal [r client setname someothername] {OK}
   44         r client list
   45     } {*name=someothername*}
   46 
   47     test {After CLIENT SETNAME, connection can still be closed} {
   48         set rd [redis_deferring_client]
   49         $rd client setname foobar
   50         assert_equal [$rd read] "OK"
   51         assert_match {*foobar*} [r client list]
   52         $rd close
   53         # Now the client should no longer be listed
   54         wait_for_condition 50 100 {
   55             [string match {*foobar*} [r client list]] == 0
   56         } else {
   57             fail "Client still listed in CLIENT LIST after SETNAME."
   58         }
   59     }
   60 
   61     test {CONFIG sanity} {
   62         # Do CONFIG GET, CONFIG SET and then CONFIG GET again
   63         # Skip immutable configs, one with no get, and other complicated configs
   64         set skip_configs {
   65             rdbchecksum
   66             daemonize
   67             io-threads-do-reads
   68             tcp-backlog
   69             always-show-logo
   70             syslog-enabled
   71             cluster-enabled
   72             aclfile
   73             unixsocket
   74             pidfile
   75             syslog-ident
   76             appendfilename
   77             supervised
   78             syslog-facility
   79             databases
   80             port
   81             tls-port
   82             io-threads
   83             logfile
   84             unixsocketperm
   85             slaveof
   86             bind
   87             requirepass
   88             server_cpulist
   89             bio_cpulist
   90             aof_rewrite_cpulist
   91             bgsave_cpulist
   92         }
   93 
   94         if {!$::tls} {
   95             append skip_configs {
   96                 tls-prefer-server-ciphers
   97                 tls-session-cache-timeout
   98                 tls-session-cache-size
   99                 tls-session-caching
  100                 tls-cert-file
  101                 tls-key-file
  102                 tls-dh-params-file
  103                 tls-ca-cert-file
  104                 tls-ca-cert-dir
  105                 tls-protocols
  106                 tls-ciphers
  107                 tls-ciphersuites
  108             }
  109         }
  110 
  111         set configs {}
  112         foreach {k v} [r config get *] {
  113             if {[lsearch $skip_configs $k] != -1} {
  114                 continue
  115             }
  116             dict set configs $k $v
  117             # try to set the config to the same value it already has
  118             r config set $k $v
  119         }
  120 
  121         set newconfigs {}
  122         foreach {k v} [r config get *] {
  123             if {[lsearch $skip_configs $k] != -1} {
  124                 continue
  125             }
  126             dict set newconfigs $k $v
  127         }
  128 
  129         dict for {k v} $configs {
  130             set vv [dict get $newconfigs $k]
  131             if {$v != $vv} {
  132                 fail "config $k mismatch, expecting $v but got $vv"
  133             }
  134 
  135         }
  136     }
  137 
  138     # Do a force-all config rewrite and make sure we're able to parse
  139     # it.
  140     test {CONFIG REWRITE sanity} {
  141         # Capture state of config before
  142         set configs {}
  143         foreach {k v} [r config get *] {
  144             dict set configs $k $v
  145         }
  146 
  147         # Rewrite entire configuration, restart and confirm the
  148         # server is able to parse it and start.
  149         assert_equal [r debug config-rewrite-force-all] "OK"
  150         restart_server 0 0
  151         assert_equal [r ping] "PONG"
  152 
  153         # Verify no changes were introduced
  154         dict for {k v} $configs {
  155             assert_equal $v [lindex [r config get $k] 1]
  156         }
  157     }
  158 
  159     # Config file at this point is at a wierd state, and includes all
  160     # known keywords. Might be a good idea to avoid adding tests here.
  161 }