Mercurial > hg > nginx-tests
comparison limit_conn_complex.t @ 725:e5b1495299bd
Tests: made sure to test limit_conn with rate limited request.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 01 Oct 2015 12:45:58 +0300 |
parents | 2cd00179f4b2 |
children | 47139a1ce06e |
comparison
equal
deleted
inserted
replaced
724:4322541b80ed | 725:e5b1495299bd |
---|---|
38 | 38 |
39 http { | 39 http { |
40 %%TEST_GLOBALS_HTTP%% | 40 %%TEST_GLOBALS_HTTP%% |
41 | 41 |
42 limit_req_zone $binary_remote_addr$arg_r zone=req:1m rate=1r/s; | 42 limit_req_zone $binary_remote_addr$arg_r zone=req:1m rate=1r/s; |
43 limit_req_zone $binary_remote_addr zone=re2:1m rate=1r/s; | |
43 limit_conn_zone $binary_remote_addr$arg_c zone=conn:1m; | 44 limit_conn_zone $binary_remote_addr$arg_c zone=conn:1m; |
44 | 45 |
45 server { | 46 server { |
46 listen 127.0.0.1:8080; | 47 listen 127.0.0.1:8080; |
47 server_name localhost; | 48 server_name localhost; |
50 limit_conn conn 1; | 51 limit_conn conn 1; |
51 } | 52 } |
52 | 53 |
53 location /w { | 54 location /w { |
54 limit_conn conn 1; | 55 limit_conn conn 1; |
55 proxy_pass http://127.0.0.1:8080/req; | 56 proxy_pass http://127.0.0.1:8080/req2; |
56 } | 57 } |
57 | 58 |
58 location /req { | 59 location /req { |
59 limit_req zone=req burst=2; | 60 limit_req zone=req burst=2; |
61 } | |
62 | |
63 location /req2 { | |
64 limit_req zone=re2 burst=2; | |
60 } | 65 } |
61 } | 66 } |
62 } | 67 } |
63 | 68 |
64 EOF | 69 EOF |
81 $s = http_get('/req?r=2', start => 1); | 86 $s = http_get('/req?r=2', start => 1); |
82 ok(IO::Select->new($s)->can_read(0.1), 'limit_req different key'); | 87 ok(IO::Select->new($s)->can_read(0.1), 'limit_req different key'); |
83 | 88 |
84 # limit_conn tests | 89 # limit_conn tests |
85 | 90 |
91 http_get('/req2'); | |
92 | |
86 $s = http_get('/w', start => 1); | 93 $s = http_get('/w', start => 1); |
87 select undef, undef, undef, 0.2; | 94 select undef, undef, undef, 0.2; |
88 | 95 |
89 like(http_get('/'), qr/^HTTP\/1.. 503 /, 'limit_conn same key'); | 96 like(http_get('/'), qr/^HTTP\/1.. 503 /, 'limit_conn same key'); |
90 unlike(http_get('/?c=2'), qr/^HTTP\/1.. 503 /, 'limit_conn different key'); | 97 unlike(http_get('/?c=2'), qr/^HTTP\/1.. 503 /, 'limit_conn different key'); |