comparison proxy_limit_rate.t @ 1255:b113eeca94ad

Tests: added proxy_limit_rate tests with upstream keepalive.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 05 Dec 2017 13:52:50 +0300
parents 516070bada7d
children 97c8280de681
comparison
equal deleted inserted replaced
1254:6fff42643fd7 1255:b113eeca94ad
20 ############################################################################### 20 ###############################################################################
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(2); 25 my $t = Test::Nginx->new()->has(qw/http proxy upstream_keepalive/)->plan(4);
26 26
27 $t->write_file_expand('nginx.conf', <<'EOF'); 27 $t->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
34 } 34 }
35 35
36 http { 36 http {
37 %%TEST_GLOBALS_HTTP%% 37 %%TEST_GLOBALS_HTTP%%
38 38
39 upstream u {
40 server 127.0.0.1:8080;
41 keepalive 1;
42 }
43
39 server { 44 server {
40 listen 127.0.0.1:8080; 45 listen 127.0.0.1:8080;
41 server_name localhost; 46 server_name localhost;
42 47
43 location / { 48 location / {
44 proxy_pass http://127.0.0.1:8080/data; 49 proxy_pass http://127.0.0.1:8080/data;
50 proxy_buffer_size 4k;
51 proxy_limit_rate 12000;
52 add_header X-Msec $msec;
53 }
54
55 location /keepalive {
56 proxy_http_version 1.1;
57 proxy_set_header Connection "";
58 proxy_pass http://u/data;
45 proxy_buffer_size 4k; 59 proxy_buffer_size 4k;
46 proxy_limit_rate 12000; 60 proxy_limit_rate 12000;
47 add_header X-Msec $msec; 61 add_header X-Msec $msec;
48 } 62 }
49 63
67 # four chunks are split with three 1s delays 81 # four chunks are split with three 1s delays
68 82
69 cmp_ok($diff, '>=', 3, 'proxy_limit_rate'); 83 cmp_ok($diff, '>=', 3, 'proxy_limit_rate');
70 like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body'); 84 like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body');
71 85
86 # in case keepalive connection was saved with the delayed flag,
87 # the read timer used to be a delay timer in the next request
88
89 like(http_get('/keepalive'), qr/200 OK/, 'keepalive');
90
91 TODO: {
92 local $TODO = 'not yet' unless $t->has_version('1.13.8');
93
94 like(http_get('/keepalive'), qr/200 OK/, 'keepalive 2');
95
96 }
97
72 ############################################################################### 98 ###############################################################################