comparison limit_req.t @ 1364:62e2baa3bc60

Tests: added limit_req_status test.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 14 Aug 2018 13:07:04 +0300
parents 196d33c2bb45
children
comparison
equal deleted inserted replaced
1363:e91d80dd2527 1364:62e2baa3bc60
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(5); 24 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(6);
25 25
26 $t->write_file_expand('nginx.conf', <<'EOF'); 26 $t->write_file_expand('nginx.conf', <<'EOF');
27 27
28 %%TEST_GLOBALS%% 28 %%TEST_GLOBALS%%
29 29
43 listen 127.0.0.1:8080; 43 listen 127.0.0.1:8080;
44 server_name localhost; 44 server_name localhost;
45 location / { 45 location / {
46 limit_req zone=one burst=1 nodelay; 46 limit_req zone=one burst=1 nodelay;
47 } 47 }
48 location /status {
49 limit_req zone=one burst=1 nodelay;
50
51 limit_req_status 501;
52 }
48 location /long { 53 location /long {
49 limit_req zone=long burst=5; 54 limit_req zone=long burst=5;
50 } 55 }
51 location /fast { 56 location /fast {
52 limit_req zone=fast burst=1; 57 limit_req zone=fast burst=1;
64 ############################################################################### 69 ###############################################################################
65 70
66 like(http_get('/test1.html'), qr/^HTTP\/1.. 200 /m, 'request'); 71 like(http_get('/test1.html'), qr/^HTTP\/1.. 200 /m, 'request');
67 http_get('/test1.html'); 72 http_get('/test1.html');
68 like(http_get('/test1.html'), qr/^HTTP\/1.. 503 /m, 'request rejected'); 73 like(http_get('/test1.html'), qr/^HTTP\/1.. 503 /m, 'request rejected');
74 like(http_get('/status.html'), qr/^HTTP\/1.. 501 /m, 'request rejected status');
69 http_get('/test1.html'); 75 http_get('/test1.html');
70 http_get('/test1.html'); 76 http_get('/test1.html');
71 77
72 # Second request will be delayed by limit_req, make sure it isn't truncated. 78 # Second request will be delayed by limit_req, make sure it isn't truncated.
73 # The bug only manifests itself if buffer will be filled, so sleep for a while 79 # The bug only manifests itself if buffer will be filled, so sleep for a while