latency-monitor.tcl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. start_server {tags {"latency-monitor"}} {
  2. # Set a threshold high enough to avoid spurious latency events.
  3. r config set latency-monitor-threshold 200
  4. r latency reset
  5. test {Test latency events logging} {
  6. r debug sleep 0.3
  7. after 1100
  8. r debug sleep 0.4
  9. after 1100
  10. r debug sleep 0.5
  11. assert {[r latency history command] >= 3}
  12. }
  13. test {LATENCY HISTORY output is ok} {
  14. set min 250
  15. set max 450
  16. foreach event [r latency history command] {
  17. lassign $event time latency
  18. assert {$latency >= $min && $latency <= $max}
  19. incr min 100
  20. incr max 100
  21. set last_time $time ; # Used in the next test
  22. }
  23. }
  24. test {LATENCY LATEST output is ok} {
  25. foreach event [r latency latest] {
  26. lassign $event eventname time latency max
  27. assert {$eventname eq "command"}
  28. assert {$max >= 450 & $max <= 650}
  29. assert {$time == $last_time}
  30. break
  31. }
  32. }
  33. test {LATENCY HISTORY / RESET with wrong event name is fine} {
  34. assert {[llength [r latency history blabla]] == 0}
  35. assert {[r latency reset blabla] == 0}
  36. }
  37. test {LATENCY DOCTOR produces some output} {
  38. assert {[string length [r latency doctor]] > 0}
  39. }
  40. test {LATENCY RESET is able to reset events} {
  41. assert {[r latency reset] > 0}
  42. assert {[r latency latest] eq {}}
  43. }
  44. }