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