Skip to content

Commit

Permalink
tests(dbless): fix flaky test (#11292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP authored Jul 27, 2023
1 parent 85b3809 commit 91dcd61
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions spec/02-integration/11-dbless/03-config_persistence_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,40 @@ describe("dbless persistence with a declarative config #off", function()
database = "off",
declarative_config = yaml_file,
}))
local proxy_client = assert(helpers.proxy_client())
local res = assert(proxy_client:get("/test", { headers = { host = "example1.dev" } }))
assert.res_status(401, res)

res = assert(proxy_client:get("/500", { headers = { host = "example1.dev" } }))
assert.res_status(404, res) -- 404, only the declarative config is loaded
proxy_client:close()
assert
.with_timeout(15)
.eventually(function ()
local proxy_client = helpers.proxy_client()
local res = proxy_client:get("/test", { headers = { host = "example1.dev" } })
assert.res_status(401, res) -- 401, should load the declarative config

res = proxy_client:get("/500", { headers = { host = "example1.dev" } })
assert.res_status(404, res) -- 404, should not load the persisted lmdb config

proxy_client:close()
end)
.has_no_error()
end)

it("doesn't load the persisted lmdb config if a declarative config is set on reload", function()
assert(helpers.reload_kong("off", "reload --prefix " .. helpers.test_conf.prefix, {
database = "off",
declarative_config = yaml_file,
}))
local res
helpers.wait_until(function()
local proxy_client = assert(helpers.proxy_client())
res = assert(proxy_client:get("/test", { headers = { host = "example1.dev" } }))
proxy_client:close()
return res.status == 401
end)

local proxy_client = assert(helpers.proxy_client())
res = assert(proxy_client:get("/500", { headers = { host = "example1.dev" } }))
assert.res_status(404, res) -- 404, only the declarative config is loaded
proxy_client:close()
assert
.with_timeout(15)
.eventually(function ()
local proxy_client = helpers.proxy_client()
local res = proxy_client:get("/test", { headers = { host = "example1.dev" } })
assert.res_status(401, res) -- 401, should load the declarative config

res = proxy_client:get("/500", { headers = { host = "example1.dev" } })
assert.res_status(404, res) -- 404, should not load the persisted lmdb config

proxy_client:close()
end)
.has_no_error()
end)
end)

1 comment on commit 91dcd61

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:91dcd61432cf4907ff511bab27546793fb15f57a
Artifacts available https://github.com/Kong/kong/actions/runs/5683392538

Please sign in to comment.