2
0

introspection.tcl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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=0 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. r set foo bar
  9. r get foo
  10. list [$rd read] [$rd read] [$rd read]
  11. } {*OK*"set" "foo"*"get" "foo"*}
  12. test {MONITOR can log commands issued by the scripting engine} {
  13. set rd [redis_deferring_client]
  14. $rd monitor
  15. r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar
  16. $rd read ;# Discard the OK
  17. assert_match {*eval*} [$rd read]
  18. assert_match {*lua*"set"*"foo"*"bar"*} [$rd read]
  19. }
  20. test {CLIENT GETNAME should return NIL if name is not assigned} {
  21. r client getname
  22. } {}
  23. test {CLIENT LIST shows empty fields for unassigned names} {
  24. r client list
  25. } {*name= *}
  26. test {CLIENT SETNAME does not accept spaces} {
  27. catch {r client setname "foo bar"} e
  28. set e
  29. } {ERR*}
  30. test {CLIENT SETNAME can assign a name to this connection} {
  31. assert_equal [r client setname myname] {OK}
  32. r client list
  33. } {*name=myname*}
  34. test {CLIENT SETNAME can change the name of an existing connection} {
  35. assert_equal [r client setname someothername] {OK}
  36. r client list
  37. } {*name=someothername*}
  38. test {After CLIENT SETNAME, connection can still be closed} {
  39. set rd [redis_deferring_client]
  40. $rd client setname foobar
  41. assert_equal [$rd read] "OK"
  42. assert_match {*foobar*} [r client list]
  43. $rd close
  44. # Now the client should no longer be listed
  45. wait_for_condition 50 100 {
  46. [string match {*foobar*} [r client list]] == 0
  47. } else {
  48. fail "Client still listed in CLIENT LIST after SETNAME."
  49. }
  50. }
  51. }