slowlog.tcl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. start_server {tags {"slowlog"}} {
  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. }