comparison limit_conn.t @ 468:684278f71783

Tests: the "limit_zone" directive was removed.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 24 Sep 2014 23:56:41 +0400
parents 60888e2c3f5a
children 1c5a8265f386
comparison
equal deleted inserted replaced
467:43e05ac6c23c 468:684278f71783
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 plan(skip_all => 'win32') if $^O eq 'MSWin32'; 26 plan(skip_all => 'win32') if $^O eq 'MSWin32';
27 27
28 my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req/)->plan(10); 28 my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req/)->plan(8);
29 29
30 $t->write_file_expand('nginx.conf', <<'EOF'); 30 $t->write_file_expand('nginx.conf', <<'EOF');
31 31
32 %%TEST_GLOBALS%% 32 %%TEST_GLOBALS%%
33 33
42 limit_req_zone $binary_remote_addr zone=req:1m rate=30r/m; 42 limit_req_zone $binary_remote_addr zone=req:1m rate=30r/m;
43 43
44 limit_conn_zone $binary_remote_addr zone=zone:1m; 44 limit_conn_zone $binary_remote_addr zone=zone:1m;
45 limit_conn_zone $binary_remote_addr zone=zone2:1m; 45 limit_conn_zone $binary_remote_addr zone=zone2:1m;
46 limit_conn_zone $binary_remote_addr zone=custom:1m; 46 limit_conn_zone $binary_remote_addr zone=custom:1m;
47 limit_zone legacy $binary_remote_addr 1m;
48 47
49 server { 48 server {
50 listen 127.0.0.1:8081; 49 listen 127.0.0.1:8081;
51 server_name localhost; 50 server_name localhost;
52 51
80 proxy_pass http://127.0.0.1:8081/; 79 proxy_pass http://127.0.0.1:8081/;
81 limit_conn_log_level info; 80 limit_conn_log_level info;
82 limit_conn_status 501; 81 limit_conn_status 501;
83 limit_conn custom 1; 82 limit_conn custom 1;
84 } 83 }
85
86 location /legacy {
87 proxy_pass http://127.0.0.1:8081/;
88 limit_conn legacy 1;
89 }
90 } 84 }
91 } 85 }
92 86
93 EOF 87 EOF
94 88
95 open OLDERR, ">&", \*STDERR; close STDERR;
96 $t->run(); 89 $t->run();
97 open STDERR, ">&", \*OLDERR;
98 90
99 ############################################################################### 91 ###############################################################################
100 92
101 # charge limit_req 93 # charge limit_req
102 94
119 111
120 like(`grep -F '[info]' ${\($t->testdir())}/error.log`, 112 like(`grep -F '[info]' ${\($t->testdir())}/error.log`,
121 qr/limiting connections by zone "custom"/s, 113 qr/limiting connections by zone "custom"/s,
122 'limit_conn_log_level'); 114 'limit_conn_log_level');
123 115
124 # limit_zone
125
126 $s = http_get('/legacy/w', start => 1);
127 like(http_get('/legacy'), qr/^HTTP\/1.. 503 /, 'legacy rejected');
128
129 $s->close;
130 unlike(http_get('/legacy'), qr/^HTTP\/.. 503 /, 'legacy passed');
131
132 # limited after unlimited 116 # limited after unlimited
133 117
134 $s = http_get('/w', start => 1); 118 $s = http_get('/w', start => 1);
135 like(http_get('/unlim'), qr/404 Not Found/, 'unlimited passed'); 119 like(http_get('/unlim'), qr/404 Not Found/, 'unlimited passed');
136 like(http_get('/'), qr/503 Service/, 'limited rejected'); 120 like(http_get('/'), qr/503 Service/, 'limited rejected');