Skip to content

Commit

Permalink
tests(plugins): refactor tests to address flakiness
Browse files Browse the repository at this point in the history
(cherry picked from commit 2adad05)
  • Loading branch information
gszr authored and locao committed Dec 12, 2023
1 parent 33c791f commit cc21cb2
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions spec/03-plugins/17-ip-restriction/02-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -581,19 +581,17 @@ for _, strategy in helpers.each_strategy() do
})
assert.res_status(200, res)

local cache_key = db.plugins:cache_key(plugin)

helpers.wait_for_invalidation(cache_key)

local res = assert(proxy_client:send {
method = "GET",
path = "/request",
headers = {
["Host"] = "ip-restriction2.com"
}
})
local body = assert.res_status(403, res)
assert.matches("IP address not allowed", body)
helpers.pwait_until(function()
res = assert(proxy_client:send {
method = "GET",
path = "/request",
headers = {
["Host"] = "ip-restriction2.com"
}
})
local body = assert.res_status(403, res)
assert.matches("IP address not allowed", body)
end)

res = assert(admin_client:send {
method = "PATCH",
Expand All @@ -607,18 +605,16 @@ for _, strategy in helpers.each_strategy() do
})
assert.res_status(200, res)

local cache_key = db.plugins:cache_key(plugin)

helpers.wait_for_invalidation(cache_key)

local res = assert(proxy_client:send {
method = "GET",
path = "/request",
headers = {
["Host"] = "ip-restriction2.com"
}
})
assert.res_status(200, res)
helpers.pwait_until(function()
res = assert(proxy_client:send {
method = "GET",
path = "/request",
headers = {
["Host"] = "ip-restriction2.com"
}
})
assert.res_status(200, res)
end)
end)

describe("#regression", function()
Expand Down

0 comments on commit cc21cb2

Please sign in to comment.