|
| 1 | +# vim:set ft= ts=4 sts=4 sw=4 et fdm=marker: |
| 2 | + |
| 3 | +use strict; |
| 4 | +use lib '.'; |
| 5 | +use t::TestWasm; |
| 6 | + |
| 7 | +if ($ENV{TEST_NGINX_USE_HUP}) { |
| 8 | + plan(skip_all => "unavailable in HUP mode"); |
| 9 | + |
| 10 | +} else { |
| 11 | + plan tests => repeat_each() * (blocks() * 4); |
| 12 | +} |
| 13 | + |
| 14 | +run_tests(); |
| 15 | + |
| 16 | +__DATA__ |
| 17 | +
|
| 18 | +=== TEST 1: client connection abort - wasm_call |
| 19 | +Nginx response filters are not invoked on the produced HTTP 499 response. |
| 20 | +--- skip_no_debug: 4 |
| 21 | +--- wasm_modules: ngx_rust_tests |
| 22 | +--- tcp_listen: $TEST_NGINX_UNIX_SOCKET |
| 23 | +--- tcp_reply eval |
| 24 | +sub { |
| 25 | + return ["HTTP/1.1 200 OK\r\n", |
| 26 | + "Connection: close\r\n", |
| 27 | + "Content-Length: 0\r\n", |
| 28 | + "\r\n"]; |
| 29 | +} |
| 30 | +--- config |
| 31 | + location /t { |
| 32 | + wasm_call content ngx_rust_tests log_notice_hello; |
| 33 | + wasm_call header_filter ngx_rust_tests log_notice_hello; |
| 34 | + wasm_call body_filter ngx_rust_tests log_notice_hello; |
| 35 | + proxy_pass http://unix:$TEST_NGINX_UNIX_SOCKET:/; |
| 36 | + } |
| 37 | +--- shutdown |
| 38 | +--- ignore_response |
| 39 | +--- grep_error_log eval: qr/(client prematurely closed|(wasm ops calling .*? in .*? phase))/ |
| 40 | +--- grep_error_log_out eval |
| 41 | +qr/wasm ops calling "ngx_rust_tests\.log_notice_hello" in "content" phase |
| 42 | +client prematurely closed\Z/ |
| 43 | +--- no_error_log |
| 44 | +header_filter |
| 45 | +body_filter |
| 46 | +[error] |
| 47 | +
|
| 48 | +
|
| 49 | +
|
| 50 | +=== TEST 2: client connection abort - chained filters |
| 51 | +Filters on aborted client connections do not execute response phases. |
| 52 | +--- wasm_modules: on_phases |
| 53 | +--- tcp_listen: $TEST_NGINX_UNIX_SOCKET |
| 54 | +--- tcp_reply eval |
| 55 | +sub { |
| 56 | + return ["HTTP/1.1 200 OK\r\n", |
| 57 | + "Connection: close\r\n", |
| 58 | + "Content-Length: 0\r\n", |
| 59 | + "\r\n"]; |
| 60 | +} |
| 61 | +--- config |
| 62 | + location /t { |
| 63 | + proxy_wasm on_phases; |
| 64 | + proxy_wasm on_phases; |
| 65 | + proxy_pass http://unix:$TEST_NGINX_UNIX_SOCKET:/; |
| 66 | + } |
| 67 | +--- shutdown |
| 68 | +--- ignore_response |
| 69 | +--- grep_error_log eval: qr/\[info\] .*? ((client prematurely closed)|on_request_headers|on_response_headers|on_log|on_done|on_http_call_response.*)/ |
| 70 | +--- grep_error_log_out eval |
| 71 | +qr/\A\[info\] .*? on_request_headers |
| 72 | +\[info\] .*? on_request_headers |
| 73 | +\[info\] .*? reported that client prematurely closed |
| 74 | +\[info\] .*? on_done |
| 75 | +\[info\] .*? on_log |
| 76 | +\[info\] .*? on_done |
| 77 | +\[info\] .*? on_log\Z/ |
| 78 | +--- no_error_log |
| 79 | +on_response |
| 80 | +[error] |
| 81 | +[crit] |
| 82 | +
|
| 83 | +
|
| 84 | +
|
| 85 | +=== TEST 3: client connection abort - chained filters with HTTP dispatch |
| 86 | +Filters with pending dispatch calls on aborted client connections await for |
| 87 | +response. |
| 88 | +--- load_nginx_modules: ngx_http_echo_module |
| 89 | +--- wasm_modules: hostcalls |
| 90 | +--- http_config eval |
| 91 | +qq{ |
| 92 | + server { |
| 93 | + listen unix:$ENV{TEST_NGINX_UNIX_SOCKET}; |
| 94 | +
|
| 95 | + location / { |
| 96 | + return 200; |
| 97 | + } |
| 98 | +
|
| 99 | + location /sleep { |
| 100 | + echo_sleep 0.3; |
| 101 | + echo_status 201; |
| 102 | + } |
| 103 | + } |
| 104 | +} |
| 105 | +--- config |
| 106 | + location /t { |
| 107 | + proxy_wasm hostcalls 'test=/t/dispatch_http_call \ |
| 108 | + host=unix:$TEST_NGINX_UNIX_SOCKET \ |
| 109 | + path=/'; |
| 110 | + proxy_wasm hostcalls 'test=/t/dispatch_http_call \ |
| 111 | + host=unix:$TEST_NGINX_UNIX_SOCKET \ |
| 112 | + path=/sleep'; |
| 113 | + proxy_pass http://unix:$TEST_NGINX_UNIX_SOCKET:/; |
| 114 | + } |
| 115 | +--- shutdown |
| 116 | +--- ignore_response |
| 117 | +--- grep_error_log eval: qr/\[info\] .*? ((client prematurely closed)|on_request_headers|on_response_headers|on_log|on_done|on_http_call_response.*)/ |
| 118 | +--- grep_error_log_out eval |
| 119 | +qr/\A\[info\] .*? on_request_headers |
| 120 | +\[info\] .*? on_http_call_response \(id: \d+, status: 200[^*].* |
| 121 | +\[info\] .*? on_request_headers |
| 122 | +\[info\] .*? on_http_call_response \(id: \d+, status: 201[^*].* |
| 123 | +\[info\] .*? reported that client prematurely closed |
| 124 | +\[info\] .*? on_done |
| 125 | +\[info\] .*? on_log |
| 126 | +\[info\] .*? on_done |
| 127 | +\[info\] .*? on_log\Z/ |
| 128 | +--- no_error_log |
| 129 | +[error] |
| 130 | +[crit] |
| 131 | +[emerg] |
0 commit comments