-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# vim:set ft= ts=4 sts=4 sw=4 et fdm=marker: | ||
|
||
use strict; | ||
use lib '.'; | ||
use t::TestWasm; | ||
|
||
plan tests => repeat_each() * (blocks() * 5); | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: client connection drop - send_local_response() | ||
Despite client connection drop, the client receives a response. | ||
An `eof: 1, avail:0` entry should be seen in error.log. | ||
--- shutdown | ||
--- wasm_modules: hostcalls | ||
--- config | ||
location /t { | ||
proxy_wasm hostcalls 'test=/t/send_local_response/status/204'; | ||
} | ||
--- error_code: 204 | ||
--- grep_error_log eval: qr/(http lingering|recv: eof:1, avail:0).*/ | ||
--- grep_error_log_out eval | ||
qr/http lingering close handler.* | ||
recv: eof:1, avail:0/ | ||
--- no_error_log | ||
[warn] | ||
[error] | ||
[crit] | ||
=== TEST 2: client connection drop - dispatch_http_call() | ||
Despite client connection drop, the client receives a response. | ||
An `eof: 1, avail:0` entry should be seen in error.log. | ||
--- shutdown | ||
--- load_nginx_modules: ngx_http_echo_module | ||
--- wasm_modules: hostcalls | ||
--- http_config eval | ||
qq{ | ||
server { | ||
listen unix:$ENV{TEST_NGINX_UNIX_SOCKET}; | ||
location / { | ||
return 201; | ||
} | ||
} | ||
} | ||
--- config | ||
location /t { | ||
proxy_wasm hostcalls 'test=/t/dispatch_http_call \ | ||
host=unix:$TEST_NGINX_UNIX_SOCKET \ | ||
on_http_call_response=echo_response_headers'; | ||
echo fail; | ||
} | ||
--- grep_error_log eval: qr/(http lingering|recv: eof:1, avail:0).*/ | ||
--- grep_error_log_out eval | ||
qr/http lingering close handler.* | ||
recv: eof:1, avail:0/ | ||
--- no_error_log | ||
[warn] | ||
[error] | ||
[crit] | ||
=== TEST 3: client connection drop - dispatch_http_call(), delayed upstream response | ||
Despite client connection drop and delayed upstream repsonse, the client | ||
receives a response. | ||
An `eof: 1, avail:0` entry should be seen in error.log. | ||
--- shutdown | ||
--- load_nginx_modules: ngx_http_echo_module | ||
--- wasm_modules: hostcalls | ||
--- http_config eval | ||
qq{ | ||
server { | ||
listen unix:$ENV{TEST_NGINX_UNIX_SOCKET}; | ||
location / { | ||
echo_sleep 0.01; | ||
echo ok; | ||
} | ||
} | ||
} | ||
--- config | ||
location /t { | ||
proxy_wasm hostcalls 'test=/t/dispatch_http_call \ | ||
host=unix:$TEST_NGINX_UNIX_SOCKET \ | ||
on_http_call_response=echo_response_headers'; | ||
echo fail; | ||
} | ||
--- grep_error_log eval: qr/(http lingering|recv: eof:1, avail:0).*/ | ||
--- grep_error_log_out eval | ||
qr/http lingering close handler.* | ||
recv: eof:1, avail:0/ | ||
--- no_error_log | ||
[warn] | ||
[error] | ||
[crit] | ||
=== TEST 4: client connection drop - proxy_wasm on_phases, echo | ||
Despite client connection drop, the client receives a response and | ||
proxy_wasm response phases are invoked. | ||
--- shutdown | ||
--- load_nginx_modules: ngx_http_echo_module | ||
--- wasm_modules: on_phases | ||
--- config | ||
location /t { | ||
proxy_wasm on_phases; | ||
echo ok; | ||
} | ||
--- response_body | ||
ok | ||
--- grep_error_log eval: qr/(#\d+ on_*|http lingering|recv: eof).*/ | ||
--- grep_error_log_out eval | ||
qr/#\d+ on_request_headers.* | ||
#\d+ on_response_headers.* | ||
#\d+ on_response_body.* | ||
#\d+ on_response_body.* | ||
http lingering close handler | ||
recv: eof:1, avail:0/ | ||
--- no_error_log | ||
[error] | ||
[crit] | ||
=== TEST 5: client connection drop - proxy_wasm on_phases, proxy_pass | ||
Client does not receive a response and proxy_wasm response phases are not | ||
invoked. | ||
--- shutdown | ||
--- wasm_modules: on_phases | ||
--- http_config eval | ||
qq{ | ||
server { | ||
listen unix:$ENV{TEST_NGINX_UNIX_SOCKET}; | ||
location / { | ||
return 201; | ||
} | ||
} | ||
} | ||
--- config | ||
location /t { | ||
proxy_wasm on_phases; | ||
proxy_pass http://unix:$TEST_NGINX_UNIX_SOCKET:/; | ||
} | ||
--- ignore_response | ||
--- grep_error_log eval: qr/(#\d+ on_*|client prematurely closed).*/ | ||
--- grep_error_log_out eval | ||
qr/#\d+ on_request_headers.* | ||
client prematurely closed connection.* | ||
#\d+ on_log.*/ | ||
--- no_error_log | ||
[warn] | ||
[error] | ||
[crit] | ||
[stub] |