Skip to content

Commit b128981

Browse files
committed
added (passing) tests for using parallel subrequests after ngx.eof().
1 parent e0adfe5 commit b128981

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

t/092-eof.t

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# vim:set ft= ts=4 sw=4 et fdm=marker:
2+
use lib 'lib';
3+
use Test::Nginx::Socket;
4+
5+
#worker_connections(1014);
6+
#master_on();
7+
#workers(2);
8+
#log_level('warn');
9+
10+
repeat_each(2);
11+
#repeat_each(1);
12+
13+
plan tests => repeat_each() * (blocks() * 6);
14+
15+
master_on();
16+
workers(2);
17+
no_root_location();
18+
#no_diff();
19+
#no_long_string();
20+
run_tests();
21+
22+
__DATA__
23+
24+
=== TEST 1: 404 parallel subrequests after ngx.eof()
25+
--- config
26+
location = /lua {
27+
content_by_lua '
28+
ngx.say(1)
29+
ngx.eof()
30+
local res1, res2 = ngx.location.capture_multi{
31+
{ "/bad1" },
32+
{ "/bad2" }
33+
}
34+
ngx.log(ngx.WARN, "res1: ", res1.status)
35+
ngx.log(ngx.WARN, "res2: ", res2.status)
36+
';
37+
}
38+
--- request
39+
GET /lua
40+
--- response_body
41+
1
42+
--- no_error_log
43+
[alert]
44+
--- error_log
45+
res1: 404
46+
res2: 404
47+
No such file or directory
48+
49+
50+
51+
=== TEST 2: parallel normal subrequests after ngx.eof()
52+
--- config
53+
location = /t {
54+
content_by_lua '
55+
ngx.say(1)
56+
ngx.eof()
57+
local r1, r2 = ngx.location.capture_multi{
58+
{ "/proxy/tom" },
59+
{ "/proxy/jim" }
60+
}
61+
ngx.log(ngx.WARN, r1.body)
62+
ngx.log(ngx.WARN, r2.body)
63+
';
64+
}
65+
66+
location ~ '^/proxy/(\w+)' {
67+
proxy_pass http://127.0.0.1:$server_port/hello?a=$1;
68+
}
69+
70+
location = /hello {
71+
echo_sleep 0.5;
72+
echo -n "hello, $arg_a";
73+
}
74+
--- request
75+
GET /t
76+
--- response_body
77+
1
78+
--- no_error_log
79+
[alert]
80+
[error]
81+
--- error_log
82+
hello, tom
83+
hello, jim
84+

0 commit comments

Comments
 (0)