2
0

slowlog.tcl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
  2. test {SLOWLOG - check that it starts with an empty log} {
  3. r slowlog len
  4. } {0}
  5. test {SLOWLOG - only logs commands taking more time than specified} {
  6. r config set slowlog-log-slower-than 100000
  7. r ping
  8. assert_equal [r slowlog len] 0
  9. r debug sleep 0.2
  10. assert_equal [r slowlog len] 1
  11. }
  12. test {SLOWLOG - max entries is correctly handled} {
  13. r config set slowlog-log-slower-than 0
  14. r config set slowlog-max-len 10
  15. for {set i 0} {$i < 100} {incr i} {
  16. r ping
  17. }
  18. r slowlog len
  19. } {10}
  20. test {SLOWLOG - GET optional argument to limit output len works} {
  21. llength [r slowlog get 5]
  22. } {5}
  23. test {SLOWLOG - RESET subcommand works} {
  24. r config set slowlog-log-slower-than 100000
  25. r slowlog reset
  26. r slowlog len
  27. } {0}
  28. test {SLOWLOG - logged entry sanity check} {
  29. r debug sleep 0.2
  30. set e [lindex [r slowlog get] 0]
  31. assert_equal [llength $e] 4
  32. assert_equal [lindex $e 0] 105
  33. assert_equal [expr {[lindex $e 2] > 100000}] 1
  34. assert_equal [lindex $e 3] {debug sleep 0.2}
  35. }
  36. test {SLOWLOG - commands with too many arguments are trimmed} {
  37. r config set slowlog-log-slower-than 0
  38. r slowlog reset
  39. r sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  40. set e [lindex [r slowlog get] 0]
  41. lindex $e 3
  42. } {sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 {... (2 more arguments)}}
  43. test {SLOWLOG - too long arguments are trimmed} {
  44. r config set slowlog-log-slower-than 0
  45. r slowlog reset
  46. set arg [string repeat A 129]
  47. r sadd set foo $arg
  48. set e [lindex [r slowlog get] 0]
  49. lindex $e 3
  50. } {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}}
  51. test {SLOWLOG - EXEC is not logged, just executed commands} {
  52. r config set slowlog-log-slower-than 100000
  53. r slowlog reset
  54. assert_equal [r slowlog len] 0
  55. r multi
  56. r debug sleep 0.2
  57. r exec
  58. assert_equal [r slowlog len] 1
  59. set e [lindex [r slowlog get] 0]
  60. assert_equal [lindex $e 3] {debug sleep 0.2}
  61. }
  62. }