Skip to content

Commit f02da03

Browse files
committed
tests: avoided using a local listening port to avoid running out of addresses in the "check leak" test mode.
1 parent 572bf4c commit f02da03

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

t/023-preread/tcp-socket.t

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ our $HtmlDir = html_dir;
99

1010
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1111
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
12+
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
1213

1314
#log_level 'warn';
1415

@@ -21,33 +22,32 @@ __DATA__
2122
=== TEST 1: sanity
2223
--- stream_config
2324
server {
24-
listen 127.0.0.1:9988;
25+
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
2526
2627
return testing\npreread\n;
2728
}
2829
2930
--- stream_server_config
3031
preread_by_lua_block {
3132
local sock = ngx.socket.tcp()
32-
local port = 9988
33-
local ok, err = sock:connect("127.0.0.1", port)
33+
local ok, err = sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
3434
if not ok then
3535
ngx.say("failed to connect: ", err)
3636
return
3737
end
3838
3939
ngx.say("connected: ", ok)
4040
41-
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
42-
-- req = "OK"
41+
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
42+
-- req = "OK"
4343
44-
local bytes, err = sock:send(req)
45-
if not bytes then
46-
ngx.say("failed to send request: ", err)
47-
return
48-
end
44+
local bytes, err = sock:send(req)
45+
if not bytes then
46+
ngx.say("failed to send request: ", err)
47+
return
48+
end
4949
50-
ngx.say("request sent: ", bytes)
50+
ngx.say("request sent: ", bytes)
5151
5252
while true do
5353
local line, err, part = sock:receive()

0 commit comments

Comments
 (0)