introspection.tcl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. test {MONITOR can log executed commands} {
  6. set rd [redis_deferring_client]
  7. $rd monitor
  8. assert_match {*OK*} [$rd read]
  9. r set foo bar
  10. r get foo
  11. list [$rd read] [$rd read]
  12. } {*"set" "foo"*"get" "foo"*}
  13. test {MONITOR can log commands issued by the scripting engine} {
  14. set rd [redis_deferring_client]
  15. $rd monitor
  16. $rd read ;# Discard the OK
  17. r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar
  18. assert_match {*eval*} [$rd read]
  19. assert_match {*lua*"set"*"foo"*"bar"*} [$rd read]
  20. }
  21. test {CLIENT GETNAME should return NIL if name is not assigned} {
  22. r client getname
  23. } {}
  24. test {CLIENT LIST shows empty fields for unassigned names} {
  25. r client list
  26. } {*name= *}
  27. test {CLIENT SETNAME does not accept spaces} {
  28. catch {r client setname "foo bar"} e
  29. set e
  30. } {ERR*}
  31. test {CLIENT SETNAME can assign a name to this connection} {
  32. assert_equal [r client setname myname] {OK}
  33. r client list
  34. } {*name=myname*}
  35. test {CLIENT SETNAME can change the name of an existing connection} {
  36. assert_equal [r client setname someothername] {OK}
  37. r client list
  38. } {*name=someothername*}
  39. test {After CLIENT SETNAME, connection can still be closed} {
  40. set rd [redis_deferring_client]
  41. $rd client setname foobar
  42. assert_equal [$rd read] "OK"
  43. assert_match {*foobar*} [r client list]
  44. $rd close
  45. # Now the client should no longer be listed
  46. wait_for_condition 50 100 {
  47. [string match {*foobar*} [r client list]] == 0
  48. } else {
  49. fail "Client still listed in CLIENT LIST after SETNAME."
  50. }
  51. }
  52. test {CONFIG sanity} {
  53. # Do CONFIG GET, CONFIG SET and then CONFIG GET again
  54. # Skip immutable configs, one with no get, and other complicated configs
  55. set skip_configs {
  56. rdbchecksum
  57. daemonize
  58. io-threads-do-reads
  59. tcp-backlog
  60. always-show-logo
  61. syslog-enabled
  62. cluster-enabled
  63. aclfile
  64. unixsocket
  65. pidfile
  66. syslog-ident
  67. appendfilename
  68. supervised
  69. syslog-facility
  70. databases
  71. port
  72. io-threads
  73. tls-port
  74. tls-prefer-server-ciphers
  75. tls-cert-file
  76. tls-key-file
  77. tls-dh-params-file
  78. tls-ca-cert-file
  79. tls-ca-cert-dir
  80. tls-protocols
  81. tls-ciphers
  82. tls-ciphersuites
  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. set configs {}
  94. foreach {k v} [r config get *] {
  95. if {[lsearch $skip_configs $k] != -1} {
  96. continue
  97. }
  98. dict set configs $k $v
  99. # try to set the config to the same value it already has
  100. r config set $k $v
  101. }
  102. set newconfigs {}
  103. foreach {k v} [r config get *] {
  104. if {[lsearch $skip_configs $k] != -1} {
  105. continue
  106. }
  107. dict set newconfigs $k $v
  108. }
  109. dict for {k v} $configs {
  110. set vv [dict get $newconfigs $k]
  111. if {$v != $vv} {
  112. fail "config $k mismatch, expecting $v but got $vv"
  113. }
  114. }
  115. }
  116. }