introspection.tcl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. 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. }