Skip to content

Commit 82810a5

Browse files
committed
Tests: added proxy_limit_rate tests with upstream keepalive.
1 parent 3361c57 commit 82810a5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

proxy_limit_rate.t

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use Test::Nginx;
2222
select STDERR; $| = 1;
2323
select STDOUT; $| = 1;
2424

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);
2626

2727
$t->write_file_expand('nginx.conf', <<'EOF');
2828
@@ -36,6 +36,11 @@ events {
3636
http {
3737
%%TEST_GLOBALS_HTTP%%
3838
39+
upstream u {
40+
server 127.0.0.1:8080;
41+
keepalive 1;
42+
}
43+
3944
server {
4045
listen 127.0.0.1:8080;
4146
server_name localhost;
@@ -47,6 +52,15 @@ http {
4752
add_header X-Msec $msec;
4853
}
4954
55+
location /keepalive {
56+
proxy_http_version 1.1;
57+
proxy_set_header Connection "";
58+
proxy_pass http://u/data;
59+
proxy_buffer_size 4k;
60+
proxy_limit_rate 12000;
61+
add_header X-Msec $msec;
62+
}
63+
5064
location /data {
5165
}
5266
}
@@ -69,4 +83,16 @@ my $diff = time() - $t1;
6983
cmp_ok($diff, '>=', 3, 'proxy_limit_rate');
7084
like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body');
7185

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+
7298
###############################################################################

0 commit comments

Comments
 (0)