Skip to content

Commit

Permalink
tests(integration/proxy/balancer/consistent-hashing) fix some flaky t…
Browse files Browse the repository at this point in the history
…ests (#9322)
  • Loading branch information
ADD-SP authored Aug 26, 2022
1 parent d430985 commit ea7cc57
Showing 1 changed file with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ for _, strategy in helpers.each_strategy() do
local api_host = bu.add_api(bp, upstream_name)
bu.end_testcase_setup(strategy, bp)

if strategy ~= "off" then
helpers.wait_for_all_config_update()
end

-- setup target servers
local server1 = https_server.new(port1, localhost)
local server2 = https_server.new(port2, localhost)
Expand Down Expand Up @@ -83,6 +87,10 @@ for _, strategy in helpers.each_strategy() do
local api_host = bu.add_api(bp, upstream_name)
bu.end_testcase_setup(strategy, bp)

if strategy ~= "off" then
helpers.wait_for_all_config_update()
end

-- setup target servers
local server1 = https_server.new(port1, localhost)
local server2 = https_server.new(port2, localhost)
Expand Down Expand Up @@ -118,6 +126,10 @@ for _, strategy in helpers.each_strategy() do
local api_host = bu.add_api(bp, upstream_name)
bu.end_testcase_setup(strategy, bp)

if strategy ~= "off" then
helpers.wait_for_all_config_update()
end

-- setup target server
local server = https_server.new(port, localhost)
server:start()
Expand Down Expand Up @@ -154,6 +166,10 @@ for _, strategy in helpers.each_strategy() do
local api_host = bu.add_api(bp, upstream_name)
bu.end_testcase_setup(strategy, bp)

if strategy ~= "off" then
helpers.wait_for_all_config_update()
end

-- setup target servers
local server1 = https_server.new(port1, localhost)
local server2 = https_server.new(port2, localhost)
Expand Down Expand Up @@ -206,28 +222,27 @@ for _, strategy in helpers.each_strategy() do
local port2 = bu.add_target(bp, upstream_id, localhost)
local api_host = bu.add_api(bp, upstream_name)

bu.end_testcase_setup(strategy, bp)

if strategy ~= "off" then
helpers.wait_for_all_config_update()
end

-- setup target servers
local server1 = https_server.new(port1, localhost)
local server2 = https_server.new(port2, localhost)
server1:start()
server2:start()

bu.end_testcase_setup(strategy, bp)

local client = helpers.proxy_client()

local res
helpers.wait_until(function()
res = assert(client:request({
method = "GET",
path = uri,
headers = { host = api_host },
}))

return pcall(function()
assert.res_status(200, res)
end)
end, 5)
local res = assert(client:request({
method = "GET",
path = uri,
headers = { host = api_host },
}))

assert.res_status(200, res)

-- Go hit them with our test requests
local oks = bu.client_requests(requests, api_host, nil, nil, nil, uri)
Expand Down

0 comments on commit ea7cc57

Please sign in to comment.