Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
casimiro committed Oct 3, 2023
1 parent 96dfa7b commit 5cff5c7
Showing 1 changed file with 75 additions and 41 deletions.
116 changes: 75 additions & 41 deletions t/05-others/010-connection_drop.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ run_tests();

__DATA__
=== TEST 1: client connection drop - proxy_wasm & echo - chained filters
=== TEST 1: client connection drop - proxy_wasm & echo, chained filters
If a client drops the connection immediately after sending an HTTP request,
and the sent request is answered by the echo directive,
all filters executing on that request will have their on_response_headers,
Expand All @@ -28,7 +28,7 @@ on_response_body, on_log and on_done entrypoints invoked.
--- ignore_response
--- grep_error_log eval: qr/#\d+ on_(response|log|done).*/
--- grep_error_log_out eval
qr/#\d+ on_response_headers, 5 headers.*
qr/\A#\d+ on_response_headers, 5 headers.*
#\d+ on_response_headers, 5 headers.*
#\d+ on_response_body, 3 bytes, eof: false.*
#\d+ on_response_body, 3 bytes, eof: false.*
Expand All @@ -37,15 +37,15 @@ qr/#\d+ on_response_headers, 5 headers.*
#\d+ on_done.*
#\d+ on_log.*
#\d+ on_done.*
#\d+ on_log.*/
#\d+ on_log.*\Z/
--- no_error_log
[error]
[crit]
[stub]
[emerg]
=== TEST 2: client connection drop - proxy_wasm & proxy_pass - chained filters
=== TEST 2: client connection drop - proxy_wasm & proxy_pass, chained filters
If a client drops the connection immediately after sending an HTTP request,
and sent request is proxied by proxy_pass,
all filters executing on that request will only have their on_log and on_done
Expand Down Expand Up @@ -83,7 +83,7 @@ qr/\[info\] .*? on_done.*
=== TEST 3: client connection drop - proxy_wasm - filters dispatch HTTP call
=== TEST 3: client connection drop - proxy_wasm & dispatch_http_call(), chained filters
If a client drops the connection immediately after sending an HTTP request,
all filters executing on that request that have dispatched HTTP calls will have
their on_http_call_response entrypoint invoked.
Expand Down Expand Up @@ -118,16 +118,16 @@ qq{
--- ignore_response
--- grep_error_log eval: qr/\*\d+.*?on_http_call_response.*/
--- grep_error_log_out eval
qr/^\*\d+ .*? on_http_call_response \(id: \d+, status: 200[^*].*
\*\d+ .*? on_http_call_response \(id: \d+, status: 201[^*].*/
qr/\A\*\d+ .*? on_http_call_response \(id: \d+, status: 200[^*].*
\*\d+ .*? on_http_call_response \(id: \d+, status: 201[^*].*\Z/
--- no_error_log
[error]
[crit]
[stub]
[emerg]
=== TEST 4: client connection drop - proxy_wasm - send_local_response()
=== TEST 4: client connection drop - proxy_wasm, send_local_response()
If a client drops the connection immediately after sending an HTTP request,
and a filter running on that request calls send_local_response(),
a response will be produced;
Expand Down Expand Up @@ -169,7 +169,7 @@ qr/\A.*?\["on_phases" #1\].*? on_response_headers.*
=== TEST 5: client connection drop - wasm_call & echo - body_filter
=== TEST 5: client connection drop - wasm_call & echo, wasm_filter
If a client drops the connection immediately after sending an HTTP request,
and that request is answered by the echo directive,
wasm functions configured to execute on content/header_filter/body_filter phases
Expand All @@ -189,24 +189,23 @@ will be invoked.
--- ignore_response
--- grep_error_log eval: qr/\[debug\] .*? \*\d wasm ops calling .* in .* phase.*/
--- grep_error_log_out eval
qr/\[debug\] .* wasm ops calling "ngx_rust_tests.log_notice_hello" in "content" phase.*
\[debug\] .* wasm ops calling "ngx_rust_tests.log_notice_hello" in "header_filter" phase.*
\[debug\] .* wasm ops calling "ngx_rust_tests.log_notice_hello" in "body_filter" phase.*
\[debug\] .* wasm ops calling "ngx_rust_tests.log_notice_hello" in "body_filter" phase.*/
qr/\A.* wasm ops calling "ngx_rust_tests.log_notice_hello" in "content" phase.*
.* wasm ops calling "ngx_rust_tests.log_notice_hello" in "header_filter" phase.*
.* wasm ops calling "ngx_rust_tests.log_notice_hello" in "body_filter" phase.*
.* wasm ops calling "ngx_rust_tests.log_notice_hello" in "body_filter" phase.*\Z/
--- no_error_log
[error]
[crit]
[stub]
[emerg]
=== TEST 6: client connection drop - wasm_call & proxy_pass - body_filter
=== TEST 6: client connection drop - wasm_call & proxy_pass, wasm_filter
If a client drops the connection immediately after sending an HTTP request,
and that request is proxied by proxy_pass,
only wasm functions configured to execute in content phase will be invoked.
--- SKIP: This test is intermitently passing on CI.
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: ngx_rust_tests
--- http_config eval
qq{
Expand Down Expand Up @@ -239,10 +238,50 @@ qr/\[debug\] .* wasm ops calling "ngx_rust_tests.log_notice_hello" in "content"
=== TEST 7: upstream connection drop - dispatch_http_call()
--- SKIP
=== TEST 7: upstream connection drop - proxy_wasm & proxy_pass, chained filters
client receives a 502 response
all response phases are invoked
--- wasm_modules: on_phases
--- tcp_listen: $TEST_NGINX_UNIX_SOCKET
--- tcp_shutdown: 2
--- tcp_reply eval
sub {
return ["HTTP/1.1 100 OK\r\n",
"Connection: close\r\n",
"Content-Length: 0\r\n",
"\r\n"];
}
--- config
location /t {
proxy_wasm on_phases;
proxy_wasm on_phases;
proxy_pass http://unix:$TEST_NGINX_UNIX_SOCKET:/;
}
--- error_code: 502
--- grep_error_log eval: qr/\[info\] .*? on_(response|log|done).*/
--- grep_error_log_out eval
qr/\A.*?\["on_phases" #1\].*? on_response_headers.*
.*?\["on_phases" #2\].*? on_response_headers.*
.*?\["on_phases" #1\].*? on_response_body.*
.*?\["on_phases" #2\].*? on_response_body.*
.*?\["on_phases" #1\].*? on_done.*
.*?\["on_phases" #1\].*? on_log.*
.*?\["on_phases" #2\].*? on_done.*
.*?\["on_phases" #2\].*? on_log.*\Z/
--- no_error_log
[crit]
[emerg]
=== TEST 8: upstream connection drop - proxy_wasm - dispatch_http_call()
on_http_call_response is invoked
all response phases are invoked
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- tcp_listen: $TEST_NGINX_UNIX_SOCKET
--- tcp_shutdown: 2
--- tcp_reply eval
sub {
return ["HTTP/1.1 100 OK\r\n",
Expand All @@ -253,28 +292,23 @@ sub {
--- config
location /t {
proxy_wasm hostcalls 'test=/t/dispatch_http_call \
host=unix:$TEST_NGINX_UNIX_SOCKET \
on_http_call_response=echo_response_headers';
return 204;
host=unix:$TEST_NGINX_UNIX_SOCKET';
proxy_wasm hostcalls;
echo ok;
}
--- ignore_response
--- grep_error_log eval: qr/(wasm tcp socket|recv:).*/
--- grep_error_log eval: qr/\[info\] .*? on_(http_call_response|response|log|done).*/
--- grep_error_log_out eval
qr/wasm tcp socket connected to "unix:$ENV{TEST_NGINX_UNIX_SOCKET}:0"
wasm tcp socket sent all the data
wasm tcp socket handler.*
wasm tcp socket resuming
wasm tcp socket handler.*
wasm tcp socket receive handler for "unix:$ENV{TEST_NGINX_UNIX_SOCKET}:0"
wasm tcp socket resuming
wasm tcp socket trying to receive data.*
recv: eof:1, avail:-1
recv: fd:\d+ 0 of 1024
wasm tcp socket eof
wasm tcp socket no bytes to parse
wasm tcp socket reading done
wasm tcp socket closing/
qr/\A.* on_http_call_response \(id: 0, status: , headers: 0, body_bytes: 0, trailers: 0, op: \).*
.* on_response_headers.*
.* on_response_headers.*
.* on_response_body.*
.* on_response_body.*
.* on_response_body.*
.* on_response_body.*
.* on_done.*
.* on_log.*
.* on_done.*
.* on_log.*\Z/
--- no_error_log
[error]
[crit]
[stub]
[emerg]

0 comments on commit 5cff5c7

Please sign in to comment.