Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
casimiro committed Sep 20, 2023
1 parent f57914c commit 7435d6e
Showing 1 changed file with 161 additions and 0 deletions.
161 changes: 161 additions & 0 deletions t/05-others/010-connection_drop.t
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]

0 comments on commit 7435d6e

Please sign in to comment.