From 052e34146fce62173001c3a9c4aff20030c8bfa6 Mon Sep 17 00:00:00 2001 From: kurt tu Date: Mon, 7 Sep 2026 00:09:34 +0800 Subject: [PATCH 1/3] tests: fix flaky socket tests by resolving sslip.io instead of localhost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Public recursive resolvers (8.8.8.8 et al) no longer answer A queries for "localhost." — RFC 6761 special-use handling pushes that resolution back to stub resolvers (/etc/hosts), so nginx's `resolver` directive, which queries the recursive server directly, now fails with "localhost could not be resolved (3: Host not found)". --- t/014-bugs.t | 2 +- t/058-tcp-socket.t | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/014-bugs.t b/t/014-bugs.t index f0f9b91841..764f7ceb41 100644 --- a/t/014-bugs.t +++ b/t/014-bugs.t @@ -884,7 +884,7 @@ ok --- config location /t { resolver $TEST_NGINX_RESOLVER ipv6=off; - set $myhost 'localhost.'; + set $myhost '127.0.0.1.sslip.io.'; proxy_pass http://$myhost:$TEST_NGINX_RAND_PORT_1/t; } --- request diff --git a/t/058-tcp-socket.t b/t/058-tcp-socket.t index d2200a4343..efb403490f 100644 --- a/t/058-tcp-socket.t +++ b/t/058-tcp-socket.t @@ -210,7 +210,7 @@ attempt to send data on a closed socket: content_by_lua ' local sock = ngx.socket.tcp() local port = $TEST_NGINX_SERVER_PORT - local ok, err = sock:connect("localhost", port) + local ok, err = sock:connect("127.0.0.1.sslip.io", port) if not ok then ngx.say("failed to connect: ", err) return @@ -218,7 +218,7 @@ attempt to send data on a closed socket: ngx.say("connected: ", ok) - local req = "GET /foo HTTP/1.0\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n" + local req = "GET /foo HTTP/1.0\\r\\nHost: 127.0.0.1.sslip.io\\r\\nConnection: close\\r\\n\\r\\n" -- req = "OK" local bytes, err = sock:send(req) @@ -256,7 +256,7 @@ attempt to send data on a closed socket: GET /t --- response_body_like connected: 1 -request sent: 57 +request sent: 66 first line received: HTTP\/1\.1 200 OK second line received: (?:Date|Server): .*? --- no_error_log From 7bd03b48bc1ae91a138ffe9f7f0ea72d670155ed Mon Sep 17 00:00:00 2001 From: kurt tu Date: Tue, 8 Sep 2026 21:49:54 +0800 Subject: [PATCH 2/3] tests: fix flaky t/189-http2-subreq-error-wakeup.t and t/024-access/on-abort.t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit t/189 died mid-file with "IPC::Run: timeout on timer" and exit status 29: test-nginx arms IPC::Run::timeout() with the same value as curl's --max-time, and the IPC::Run timer checks integer-second time() with a 1s fudge, so when curl's launch phase crosses a second boundary the harness kills curl before its own --max-time fires and croaks, aborting the whole file and leaving shutdown_error_log checks to fail spuriously. Since the harness timer cannot be widened from the test side, make curl self-expire strictly earlier instead: append "--- curl_options: --max-time=0.9" (curl_options is appended after the scaffold's own --max-time, so curl honors the later, smaller value), leaving the IPC::Run timer more than a second of slack. t/024-access/on-abort.t TEST 7 reads the error.log exactly once after --- wait: 0.2 — the whole budget for abort detection plus the cosocket roundtrip to redis; on loaded runners this window is regularly blown. Bump the wait to 1s. Flaky CI evidence: https://github.com/openresty/lua-nginx-module/actions/runs/34126708814/job/101756976592?pr=2523 https://github.com/openresty/lua-nginx-module/actions/runs/34126708814/job/101756976782?pr=2523 Signed-off-by: tzssangglass --- t/024-access/on-abort.t | 2 +- t/189-http2-subreq-error-wakeup.t | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/t/024-access/on-abort.t b/t/024-access/on-abort.t index 70637ba862..a013d90998 100644 --- a/t/024-access/on-abort.t +++ b/t/024-access/on-abort.t @@ -372,7 +372,7 @@ delete thread 1 $ --- timeout: 0.2 --- abort ---- wait: 0.2 +--- wait: 1 --- ignore_response --- no_error_log [error] diff --git a/t/189-http2-subreq-error-wakeup.t b/t/189-http2-subreq-error-wakeup.t index 2b6adb6e19..553b806b74 100644 --- a/t/189-http2-subreq-error-wakeup.t +++ b/t/189-http2-subreq-error-wakeup.t @@ -46,6 +46,7 @@ __DATA__ --- http2 --- request GET /delay +--- curl_options: --max-time=0.9 --- timeout: 1 --- abort --- ignore_response @@ -100,6 +101,7 @@ Parent request finished, got response from subrequest --- http2 --- request GET /outer +--- curl_options: --max-time=0.9 --- timeout: 1 --- abort --- ignore_response @@ -160,6 +162,7 @@ Outer request completed --- http2 --- request GET /parallel +--- curl_options: --max-time=0.9 --- timeout: 1 --- abort --- ignore_response From e137fce90263711a51c926191d381d04fb0bbe12 Mon Sep 17 00:00:00 2001 From: kurt tu Date: Wed, 9 Sep 2026 00:35:08 +0800 Subject: [PATCH 3/3] tests: fix flaky t/128-duplex-tcp-socket.t TEST 4 in CI The mock TCP server flushes the received query to tcp_query_file after every recv (Util.pm atomic-rename trick) and the test side reads the file exactly once after --- wait: 0.05. TEST 4 sends "flush_all\r\n" one byte at a time with 1ms sleeps, so on a loaded runner the forked mock server gets starved between recvs and the check samples the file while it still holds a 7- or 10-byte prefix (got 'flush_a', expected 11 bytes). Give the mock server 0.5s to drain the kernel buffer. Flaky CI evidence: https://github.com/openresty/lua-nginx-module/actions/runs/34238302357/job/102101640297?pr=2523 https://github.com/openresty/lua-nginx-module/actions/runs/34238302357/job/102101640217?pr=2523 Signed-off-by: tzssangglass --- t/128-duplex-tcp-socket.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/128-duplex-tcp-socket.t b/t/128-duplex-tcp-socket.t index 511cc20bfc..268ec79cda 100644 --- a/t/128-duplex-tcp-socket.t +++ b/t/128-duplex-tcp-socket.t @@ -355,7 +355,7 @@ F(ngx_http_lua_socket_tcp_finalize_write_part) { --- tcp_query_len: 11 --- no_error_log [error] ---- wait: 0.05 +--- wait: 0.5