Skip to content

Commit 7af3fc0

Browse files
jiahaozhuizhuhaomeng
jiahao
authored andcommitted
tests: t/020-subrequest.t: replace the random port with an unused five-digit port.
1 parent b44f14a commit 7af3fc0

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

t/020-subrequest.t

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# vim:set ft= ts=4 sw=4 et fdm=marker:
22

33
use Test::Nginx::Socket::Lua;
4+
use Test::Nginx::Util 'is_tcp_port_used';
45

56
#master_on();
67
#workers(1);
@@ -16,6 +17,16 @@ plan tests => repeat_each() * (blocks() * 3 + 23);
1617
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1718
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
1819

20+
# NB: tcp_listen_port needs to be greater than 10000,
21+
# because the test cases expect it to be a 5-digit number
22+
my $tcp_listen_port = 19113;
23+
while (++$tcp_listen_port < 65535) {
24+
if (!is_tcp_port_used $tcp_listen_port) {
25+
last;
26+
}
27+
}
28+
$ENV{TEST_NGINX_TCP_LISTEN_PORT} = $tcp_listen_port;
29+
1930
#no_diff();
2031
no_long_string();
2132
#no_shuffle();
@@ -1383,7 +1394,7 @@ upstream timed out
13831394
13841395
#proxy_read_timeout 100ms;
13851396
proxy_buffering on;
1386-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1397+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
13871398
}
13881399
13891400
location /main {
@@ -1396,7 +1407,7 @@ upstream timed out
13961407
}
13971408
--- request
13981409
GET /main
1399-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1410+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
14001411
--- tcp_query_len: 65
14011412
--- tcp_reply eval
14021413
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
@@ -1443,7 +1454,7 @@ upstream prematurely closed connection
14431454
14441455
proxy_read_timeout 100ms;
14451456
proxy_buffering on;
1446-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1457+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
14471458
}
14481459
14491460
location /main {
@@ -1456,7 +1467,7 @@ upstream prematurely closed connection
14561467
}
14571468
--- request
14581469
GET /main
1459-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1470+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
14601471
--- tcp_no_close
14611472
--- tcp_reply eval
14621473
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
@@ -1505,7 +1516,7 @@ upstream timed out
15051516
15061517
#proxy_read_timeout 100ms;
15071518
proxy_buffering on;
1508-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1519+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
15091520
}
15101521
15111522
location /main {
@@ -1518,7 +1529,7 @@ upstream timed out
15181529
}
15191530
--- request
15201531
GET /main
1521-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1532+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
15221533
--- tcp_query_len: 65
15231534
--- tcp_reply eval
15241535
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1565,7 +1576,7 @@ truncated: false
15651576
15661577
proxy_read_timeout 100ms;
15671578
proxy_buffering on;
1568-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1579+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
15691580
}
15701581
15711582
location /main {
@@ -1578,7 +1589,7 @@ truncated: false
15781589
}
15791590
--- request
15801591
GET /main
1581-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1592+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
15821593
--- tcp_no_close
15831594
--- tcp_reply eval
15841595
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1628,7 +1639,7 @@ upstream timed out
16281639
16291640
#proxy_read_timeout 100ms;
16301641
proxy_buffering off;
1631-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1642+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
16321643
}
16331644
16341645
location /main {
@@ -1641,7 +1652,7 @@ upstream timed out
16411652
}
16421653
--- request
16431654
GET /main
1644-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1655+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
16451656
--- tcp_query_len: 65
16461657
--- tcp_reply eval
16471658
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1688,7 +1699,7 @@ truncated: false
16881699
16891700
proxy_read_timeout 500ms;
16901701
proxy_buffering off;
1691-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1702+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
16921703
}
16931704
16941705
location /main {
@@ -1701,7 +1712,7 @@ truncated: false
17011712
}
17021713
--- request
17031714
GET /main
1704-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1715+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
17051716
--- tcp_no_close
17061717
--- tcp_reply eval
17071718
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1914,7 +1925,7 @@ a client request body is buffered to a temporary file
19141925
#proxy_read_timeout 100ms;
19151926
proxy_http_version 1.1;
19161927
proxy_buffering on;
1917-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1928+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
19181929
}
19191930
19201931
location /main {
@@ -1927,7 +1938,7 @@ a client request body is buffered to a temporary file
19271938
}
19281939
--- request
19291940
GET /main
1930-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
1941+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
19311942
--- tcp_query_len: 65
19321943
--- tcp_reply eval
19331944
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
@@ -1977,7 +1988,7 @@ upstream prematurely closed connection
19771988
#proxy_read_timeout 100ms;
19781989
proxy_http_version 1.1;
19791990
proxy_buffering off;
1980-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
1991+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
19811992
}
19821993
19831994
location /main {
@@ -1990,7 +2001,7 @@ upstream prematurely closed connection
19902001
}
19912002
--- request
19922003
GET /main
1993-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
2004+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
19942005
--- tcp_query_len: 65
19952006
--- tcp_reply eval
19962007
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
@@ -2038,7 +2049,7 @@ upstream prematurely closed connection
20382049
proxy_read_timeout 100ms;
20392050
proxy_buffering on;
20402051
proxy_http_version 1.1;
2041-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
2052+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
20422053
}
20432054
20442055
location /main {
@@ -2051,7 +2062,7 @@ upstream prematurely closed connection
20512062
}
20522063
--- request
20532064
GET /main
2054-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
2065+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
20552066
--- tcp_no_close
20562067
--- tcp_reply eval
20572068
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
@@ -2100,7 +2111,7 @@ upstream timed out
21002111
#proxy_read_timeout 100ms;
21012112
proxy_buffering on;
21022113
proxy_http_version 1.1;
2103-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
2114+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
21042115
}
21052116
21062117
location /main {
@@ -2113,7 +2124,7 @@ upstream timed out
21132124
}
21142125
--- request
21152126
GET /main
2116-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
2127+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
21172128
--- tcp_no_close
21182129
--- tcp_reply eval
21192130
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n0\r\n\r\n"
@@ -2158,7 +2169,7 @@ truncated: false
21582169
#proxy_read_timeout 100ms;
21592170
proxy_buffering off;
21602171
proxy_http_version 1.1;
2161-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
2172+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
21622173
}
21632174
21642175
location /main {
@@ -2171,7 +2182,7 @@ truncated: false
21712182
}
21722183
--- request
21732184
GET /main
2174-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
2185+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
21752186
--- tcp_no_close
21762187
--- tcp_reply eval
21772188
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n0\r\n\r\n"
@@ -2217,7 +2228,7 @@ truncated: false
22172228
22182229
#proxy_read_timeout 100ms;
22192230
proxy_buffering off;
2220-
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
2231+
proxy_pass http://127.0.0.1:$TEST_NGINX_TCP_LISTEN_PORT;
22212232
}
22222233
22232234
location /main {
@@ -2230,7 +2241,7 @@ truncated: false
22302241
}
22312242
--- request
22322243
GET /main
2233-
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
2244+
--- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
22342245
--- tcp_query_len: 65
22352246
--- tcp_reply eval
22362247
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"

0 commit comments

Comments
 (0)