Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: use random port numbers instead of fixed port number to preven… #2025

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions t/109-timer-hup.t
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ lua found 100 pending timers
lua_shared_dict test_dict 1m;

server {
listen 12355;
listen $TEST_NGINX_RAND_PORT_1;
location = /foo {
echo 'foo';
}
Expand All @@ -350,7 +350,7 @@ lua found 100 pending timers

-- Connect the socket
local sock = ngx.socket.tcp()
local ok,err = sock:connect("127.0.0.1", 12355)
local ok,err = sock:connect("127.0.0.1", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.log(ngx.ERR, err)
end
Expand Down
6 changes: 3 additions & 3 deletions t/138-balancer.t
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,16 @@ failed to set more tries: reduced tries due to limit
lua_package_path "../lua-resty-core/lib/?.lua;;";

server {
listen 127.0.0.1:8888;
listen 127.0.0.1:$TEST_NGINX_RAND_PORT_1;

location / {
return 200 "it works";
}
}

upstream foo {
server 127.0.0.1:8888 max_fails=0;
server 127.0.0.1:8889 max_fails=0 weight=9999;
server 127.0.0.1:$TEST_NGINX_RAND_PORT_1 max_fails=0;
server 127.0.0.1:$TEST_NGINX_RAND_PORT_2 max_fails=0 weight=9999;

balancer_by_lua_block {
local bal = require "ngx.balancer"
Expand Down
24 changes: 12 additions & 12 deletions t/139-ssl-cert-by.t
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ received memc reply: OK
=== TEST 5: ngx.exit(0) - no yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
ngx.exit(0)
Expand Down Expand Up @@ -484,7 +484,7 @@ received memc reply: OK

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down Expand Up @@ -523,7 +523,7 @@ should never reached here
=== TEST 6: ngx.exit(ngx.ERROR) - no yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
ngx.exit(ngx.ERROR)
Expand Down Expand Up @@ -551,7 +551,7 @@ should never reached here

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down Expand Up @@ -593,7 +593,7 @@ should never reached here
=== TEST 7: ngx.exit(0) - yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
ngx.sleep(0.001)
Expand Down Expand Up @@ -623,7 +623,7 @@ should never reached here

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down Expand Up @@ -662,7 +662,7 @@ should never reached here
=== TEST 8: ngx.exit(ngx.ERROR) - yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
ngx.sleep(0.001)
Expand Down Expand Up @@ -692,7 +692,7 @@ should never reached here

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down Expand Up @@ -734,7 +734,7 @@ should never reached here
=== TEST 9: lua exception - no yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
error("bad bad bad")
Expand Down Expand Up @@ -762,7 +762,7 @@ should never reached here

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down Expand Up @@ -805,7 +805,7 @@ should never reached here
=== TEST 10: lua exception - yield
--- http_config
server {
listen 127.0.0.2:8080 ssl;
listen 127.0.0.2:$TEST_NGINX_RAND_PORT_1 ssl;
server_name test.com;
ssl_certificate_by_lua_block {
ngx.sleep(0.001)
Expand Down Expand Up @@ -834,7 +834,7 @@ should never reached here

sock:settimeout(2000)

local ok, err = sock:connect("127.0.0.2", 8080)
local ok, err = sock:connect("127.0.0.2", $TEST_NGINX_RAND_PORT_1)
if not ok then
ngx.say("failed to connect: ", err)
return
Expand Down