@@ -15,13 +15,17 @@ use File::Basename;
15
15
16
16
repeat_each(2 );
17
17
18
+ sub resolve ($$);
19
+
18
20
plan tests => repeat_each() * (blocks() * 7 - 3 );
19
21
20
22
$ ENV {TEST_NGINX_HTML_DIR} ||= html_dir();
21
23
$ ENV {TEST_NGINX_MEMCACHED_PORT} ||= 11211 ;
22
24
$ ENV {TEST_NGINX_RESOLVER} ||= ' 8.8.8.8' ;
23
25
$ ENV {TEST_NGINX_SERVER_SSL_PORT} ||= 12345 ;
24
26
$ ENV {TEST_NGINX_CERT_DIR} ||= dirname(realpath(abs_path(__FILE__)));
27
+ $ ENV {TEST_NGINX_OPENRESTY_ORG_IP} ||= resolve($ ENV {TEST_NGINX_RESOLVER},
28
+ " openresty.org" );
25
29
26
30
my $ NginxBinary = $ ENV {' TEST_NGINX_BINARY' } || ' nginx' ;
27
31
my $ openssl_version = eval { `$ NginxBinary -V 2 > &1` };
@@ -44,6 +48,19 @@ sub read_file {
44
48
$ cert ;
45
49
}
46
50
51
+ sub resolve ($$) {
52
+ my ($ resolver , $ domain ) = @ _ ;
53
+ my $ ips = qx / dig \@$resolver +short $domain/ ;
54
+
55
+ my $ exit_code = $? >> 8 ;
56
+ if (! $ ips || $ exit_code != 0 ) {
57
+ die " failed to resolve '$ domain ' using '$ resolver ' as resolver" ;
58
+ }
59
+
60
+ my ($ ip ) = split / \n/ , $ ips ;
61
+ return $ ip ;
62
+ }
63
+
47
64
our $ DSTRootCertificate = read_file(" t/cert/dst-ca.crt" );
48
65
our $ EquifaxRootCertificate = read_file(" t/cert/equifax.crt" );
49
66
our $ TestCertificate = read_file(" t/cert/test.crt" );
@@ -1397,6 +1414,7 @@ SSL reused session
1397
1414
location /t {
1398
1415
# set $port 5000;
1399
1416
set $ port $ TEST_NGINX_MEMCACHED_PORT ;
1417
+ set $ openresty_org_ip $ TEST_NGINX_OPENRESTY_ORG_IP ;
1400
1418
1401
1419
content_by_lua '
1402
1420
local sock = ngx.socket.tcp()
@@ -1406,7 +1424,8 @@ SSL reused session
1406
1424
1407
1425
local session
1408
1426
for i = 1, 3 do
1409
- local ok, err = sock:connect("openresty.org", 443)
1427
+ -- Use the same IP to ensure that the connection can be reused
1428
+ local ok, err = sock:connect(ngx.var.openresty_org_ip, 443)
1410
1429
if not ok then
1411
1430
ngx.say("failed to connect: ", err)
1412
1431
return
@@ -1473,6 +1492,7 @@ SSL reused session
1473
1492
lua_ssl_verify_depth 2;
1474
1493
location /t {
1475
1494
# set $port 5000;
1495
+ set $ openresty_org_ip $ TEST_NGINX_OPENRESTY_ORG_IP ;
1476
1496
set $ port $ TEST_NGINX_MEMCACHED_PORT ;
1477
1497
1478
1498
content_by_lua '
@@ -1482,7 +1502,8 @@ SSL reused session
1482
1502
do
1483
1503
1484
1504
for i = 1, 3 do
1485
- local ok, err = sock:connect("openresty.org", 443)
1505
+ -- Use the same IP to ensure that the connection can be reused
1506
+ local ok, err = sock:connect(ngx.var.openresty_org_ip, 443)
1486
1507
if not ok then
1487
1508
ngx.say("failed to connect: ", err)
1488
1509
return
0 commit comments