introspection-2.tcl 2.3 KB

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