introspection-2.tcl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. proc cmdstat {cmd} {
  2. return [cmdrstat $cmd r]
  3. }
  4. start_server {tags {"introspection"}} {
  5. test {TTL, TYPE and EXISTS do not alter the last access time of a key} {
  6. r set foo bar
  7. after 3000
  8. r ttl foo
  9. r type foo
  10. r exists foo
  11. assert {[r object idletime foo] >= 2}
  12. }
  13. test {TOUCH alters the last access time of a key} {
  14. r set foo bar
  15. after 3000
  16. r touch foo
  17. assert {[r object idletime foo] < 2}
  18. }
  19. test {TOUCH returns the number of existing keys specified} {
  20. r flushdb
  21. r set key1{t} 1
  22. r set key2{t} 2
  23. r touch key0{t} key1{t} key2{t} key3{t}
  24. } 2
  25. test {command stats for GEOADD} {
  26. r config resetstat
  27. r GEOADD foo 0 0 bar
  28. assert_match {*calls=1,*} [cmdstat geoadd]
  29. assert_match {} [cmdstat zadd]
  30. } {} {needs:config-resetstat}
  31. test {command stats for EXPIRE} {
  32. r config resetstat
  33. r SET foo bar
  34. r EXPIRE foo 0
  35. assert_match {*calls=1,*} [cmdstat expire]
  36. assert_match {} [cmdstat del]
  37. } {} {needs:config-resetstat}
  38. test {command stats for BRPOP} {
  39. r config resetstat
  40. r LPUSH list foo
  41. r BRPOP list 0
  42. assert_match {*calls=1,*} [cmdstat brpop]
  43. assert_match {} [cmdstat rpop]
  44. } {} {needs:config-resetstat}
  45. test {command stats for MULTI} {
  46. r config resetstat
  47. r MULTI
  48. r set foo{t} bar
  49. r GEOADD foo2{t} 0 0 bar
  50. r EXPIRE foo2{t} 0
  51. r EXEC
  52. assert_match {*calls=1,*} [cmdstat multi]
  53. assert_match {*calls=1,*} [cmdstat exec]
  54. assert_match {*calls=1,*} [cmdstat set]
  55. assert_match {*calls=1,*} [cmdstat expire]
  56. assert_match {*calls=1,*} [cmdstat geoadd]
  57. } {} {needs:config-resetstat}
  58. test {command stats for scripts} {
  59. r config resetstat
  60. r set mykey myval
  61. r eval {
  62. redis.call('set', KEYS[1], 0)
  63. redis.call('expire', KEYS[1], 0)
  64. redis.call('geoadd', KEYS[1], 0, 0, "bar")
  65. } 1 mykey
  66. assert_match {*calls=1,*} [cmdstat eval]
  67. assert_match {*calls=2,*} [cmdstat set]
  68. assert_match {*calls=1,*} [cmdstat expire]
  69. assert_match {*calls=1,*} [cmdstat geoadd]
  70. } {} {needs:config-resetstat}
  71. test {COMMAND GETKEYS GET} {
  72. assert_equal {key} [r command getkeys get key]
  73. }
  74. test {COMMAND GETKEYS MEMORY USAGE} {
  75. assert_equal {key} [r command getkeys memory usage key]
  76. }
  77. test {COMMAND GETKEYS XGROUP} {
  78. assert_equal {key} [r command getkeys xgroup create key groupname $]
  79. }
  80. test "COMMAND LIST FILTERBY ACLCAT" {
  81. set reply [r command list filterby aclcat hyperloglog]
  82. assert_equal [lsort $reply] {pfadd pfcount pfdebug pfmerge pfselftest}
  83. }
  84. test "COMMAND LIST FILTERBY PATTERN" {
  85. set reply [r command list filterby pattern pf*]
  86. assert_equal [lsort $reply] {pfadd pfcount pfdebug pfmerge pfselftest}
  87. }
  88. }