2
0

obuf-limits.tcl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. start_server {tags {"obuf-limits"}} {
  2. test {Client output buffer hard limit is enforced} {
  3. r config set client-output-buffer-limit {pubsub 100000 0 0}
  4. set rd1 [redis_deferring_client]
  5. $rd1 subscribe foo
  6. set reply [$rd1 read]
  7. assert {$reply eq "subscribe foo 1"}
  8. set omem 0
  9. while 1 {
  10. r publish foo bar
  11. set clients [split [r client list] "\r\n"]
  12. set c [split [lindex $clients 1] " "]
  13. if {![regexp {omem=([0-9]+)} $c - omem]} break
  14. if {$omem > 200000} break
  15. }
  16. assert {$omem >= 70000 && $omem < 200000}
  17. $rd1 close
  18. }
  19. test {Client output buffer soft limit is not enforced if time is not overreached} {
  20. r config set client-output-buffer-limit {pubsub 0 100000 10}
  21. set rd1 [redis_deferring_client]
  22. $rd1 subscribe foo
  23. set reply [$rd1 read]
  24. assert {$reply eq "subscribe foo 1"}
  25. set omem 0
  26. set start_time 0
  27. set time_elapsed 0
  28. while 1 {
  29. r publish foo bar
  30. set clients [split [r client list] "\r\n"]
  31. set c [split [lindex $clients 1] " "]
  32. if {![regexp {omem=([0-9]+)} $c - omem]} break
  33. if {$omem > 100000} {
  34. if {$start_time == 0} {set start_time [clock seconds]}
  35. set time_elapsed [expr {[clock seconds]-$start_time}]
  36. if {$time_elapsed >= 5} break
  37. }
  38. }
  39. assert {$omem >= 100000 && $time_elapsed >= 5 && $time_elapsed <= 10}
  40. $rd1 close
  41. }
  42. test {Client output buffer soft limit is enforced if time is overreached} {
  43. r config set client-output-buffer-limit {pubsub 0 100000 3}
  44. set rd1 [redis_deferring_client]
  45. $rd1 subscribe foo
  46. set reply [$rd1 read]
  47. assert {$reply eq "subscribe foo 1"}
  48. set omem 0
  49. set start_time 0
  50. set time_elapsed 0
  51. while 1 {
  52. r publish foo bar
  53. set clients [split [r client list] "\r\n"]
  54. set c [split [lindex $clients 1] " "]
  55. if {![regexp {omem=([0-9]+)} $c - omem]} break
  56. if {$omem > 100000} {
  57. if {$start_time == 0} {set start_time [clock seconds]}
  58. set time_elapsed [expr {[clock seconds]-$start_time}]
  59. if {$time_elapsed >= 10} break
  60. }
  61. }
  62. assert {$omem >= 100000 && $time_elapsed < 6}
  63. $rd1 close
  64. }
  65. }