1
1
# vim:set ft= ts=4 sw=4 et fdm=marker:
2
2
3
3
use Test::Nginx::Socket::Lua;
4
+ use Test::Nginx::Util ' is_tcp_port_used' ;
4
5
5
6
# master_on();
6
7
# workers(1);
@@ -16,6 +17,16 @@ plan tests => repeat_each() * (blocks() * 3 + 23);
16
17
$ENV {TEST_NGINX_MEMCACHED_PORT } ||= 11211;
17
18
$ENV {TEST_NGINX_HTML_DIR } ||= html_dir();
18
19
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
+
19
30
# no_diff();
20
31
no_long_string();
21
32
# no_shuffle();
@@ -1383,7 +1394,7 @@ upstream timed out
1383
1394
1384
1395
#proxy_read_timeout 100ms;
1385
1396
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 ;
1387
1398
}
1388
1399
1389
1400
location /main {
@@ -1396,7 +1407,7 @@ upstream timed out
1396
1407
}
1397
1408
--- request
1398
1409
GET /main
1399
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1410
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1400
1411
--- tcp_query_len: 65
1401
1412
--- tcp_reply eval
1402
1413
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
@@ -1443,7 +1454,7 @@ upstream prematurely closed connection
1443
1454
1444
1455
proxy_read_timeout 100ms;
1445
1456
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 ;
1447
1458
}
1448
1459
1449
1460
location /main {
@@ -1456,7 +1467,7 @@ upstream prematurely closed connection
1456
1467
}
1457
1468
--- request
1458
1469
GET /main
1459
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1470
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1460
1471
--- tcp_no_close
1461
1472
--- tcp_reply eval
1462
1473
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
@@ -1505,7 +1516,7 @@ upstream timed out
1505
1516
1506
1517
#proxy_read_timeout 100ms;
1507
1518
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 ;
1509
1520
}
1510
1521
1511
1522
location /main {
@@ -1518,7 +1529,7 @@ upstream timed out
1518
1529
}
1519
1530
--- request
1520
1531
GET /main
1521
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1532
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1522
1533
--- tcp_query_len: 65
1523
1534
--- tcp_reply eval
1524
1535
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1565,7 +1576,7 @@ truncated: false
1565
1576
1566
1577
proxy_read_timeout 100ms;
1567
1578
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 ;
1569
1580
}
1570
1581
1571
1582
location /main {
@@ -1578,7 +1589,7 @@ truncated: false
1578
1589
}
1579
1590
--- request
1580
1591
GET /main
1581
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1592
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1582
1593
--- tcp_no_close
1583
1594
--- tcp_reply eval
1584
1595
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1628,7 +1639,7 @@ upstream timed out
1628
1639
1629
1640
#proxy_read_timeout 100ms;
1630
1641
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 ;
1632
1643
}
1633
1644
1634
1645
location /main {
@@ -1641,7 +1652,7 @@ upstream timed out
1641
1652
}
1642
1653
--- request
1643
1654
GET /main
1644
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1655
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1645
1656
--- tcp_query_len: 65
1646
1657
--- tcp_reply eval
1647
1658
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1688,7 +1699,7 @@ truncated: false
1688
1699
1689
1700
proxy_read_timeout 500ms;
1690
1701
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 ;
1692
1703
}
1693
1704
1694
1705
location /main {
@@ -1701,7 +1712,7 @@ truncated: false
1701
1712
}
1702
1713
--- request
1703
1714
GET /main
1704
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1715
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1705
1716
--- tcp_no_close
1706
1717
--- tcp_reply eval
1707
1718
"HTTP/1.0 200 OK\r\n\r\nhello world"
@@ -1914,7 +1925,7 @@ a client request body is buffered to a temporary file
1914
1925
#proxy_read_timeout 100ms;
1915
1926
proxy_http_version 1.1;
1916
1927
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 ;
1918
1929
}
1919
1930
1920
1931
location /main {
@@ -1927,7 +1938,7 @@ a client request body is buffered to a temporary file
1927
1938
}
1928
1939
--- request
1929
1940
GET /main
1930
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
1941
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1931
1942
--- tcp_query_len: 65
1932
1943
--- tcp_reply eval
1933
1944
"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
1977
1988
#proxy_read_timeout 100ms;
1978
1989
proxy_http_version 1.1;
1979
1990
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 ;
1981
1992
}
1982
1993
1983
1994
location /main {
@@ -1990,7 +2001,7 @@ upstream prematurely closed connection
1990
2001
}
1991
2002
--- request
1992
2003
GET /main
1993
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
2004
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
1994
2005
--- tcp_query_len: 65
1995
2006
--- tcp_reply eval
1996
2007
"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
2038
2049
proxy_read_timeout 100ms;
2039
2050
proxy_buffering on;
2040
2051
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 ;
2042
2053
}
2043
2054
2044
2055
location /main {
@@ -2051,7 +2062,7 @@ upstream prematurely closed connection
2051
2062
}
2052
2063
--- request
2053
2064
GET /main
2054
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
2065
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
2055
2066
--- tcp_no_close
2056
2067
--- tcp_reply eval
2057
2068
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
@@ -2100,7 +2111,7 @@ upstream timed out
2100
2111
#proxy_read_timeout 100ms;
2101
2112
proxy_buffering on;
2102
2113
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 ;
2104
2115
}
2105
2116
2106
2117
location /main {
@@ -2113,7 +2124,7 @@ upstream timed out
2113
2124
}
2114
2125
--- request
2115
2126
GET /main
2116
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
2127
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
2117
2128
--- tcp_no_close
2118
2129
--- tcp_reply eval
2119
2130
"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
2158
2169
#proxy_read_timeout 100ms;
2159
2170
proxy_buffering off;
2160
2171
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 ;
2162
2173
}
2163
2174
2164
2175
location /main {
@@ -2171,7 +2182,7 @@ truncated: false
2171
2182
}
2172
2183
--- request
2173
2184
GET /main
2174
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
2185
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
2175
2186
--- tcp_no_close
2176
2187
--- tcp_reply eval
2177
2188
"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
2217
2228
2218
2229
#proxy_read_timeout 100ms;
2219
2230
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 ;
2221
2232
}
2222
2233
2223
2234
location /main {
@@ -2230,7 +2241,7 @@ truncated: false
2230
2241
}
2231
2242
--- request
2232
2243
GET /main
2233
- --- tcp_listen: $TEST_NGINX_RAND_PORT_2
2244
+ --- tcp_listen: $TEST_NGINX_TCP_LISTEN_PORT
2234
2245
--- tcp_query_len: 65
2235
2246
--- tcp_reply eval
2236
2247
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
0 commit comments