Skip to content

Commit

Permalink
tests(prometheus): reduce test flakiness (#10013)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki authored Dec 29, 2022
1 parent 81be86d commit 626a41f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions spec/03-plugins/26-prometheus/07-optional_fields_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ for _, strategy in helpers.each_strategy() do

-- restart the kong every time or the test would be flaky
before_each(function()
-- remember to truncate the tables so it won't be flaky!
local bp = assert(helpers.get_db_utils(strategy, {
"upstreams",
"targets",
"services",
"routes",
"plugins",
}))

Expand All @@ -50,7 +55,7 @@ for _, strategy in helpers.each_strategy() do

bp.targets:insert({
upstream = upstream,
target = helpers.mock_upstream_host .. ":" .. helpers.mock_upstream_stream_port,
target = helpers.mock_upstream_host .. ":" .. helpers.mock_upstream_port,
weight = 100,
})

Expand All @@ -76,7 +81,7 @@ for _, strategy in helpers.each_strategy() do
}).id

assert(helpers.start_kong {
-- nginx_conf = "spec/fixtures/custom_nginx.template",
nginx_conf = "spec/fixtures/custom_nginx.template",
plugins = "bundled",
database = strategy,
cluster_cert = "spec/fixtures/ocsp_certs/kong_clustering.crt",
Expand All @@ -89,15 +94,17 @@ for _, strategy in helpers.each_strategy() do
http_client = helpers.http_client("127.0.0.1", 8000, 20000)
status_client = helpers.http_client("127.0.0.1", tcp_status_port, 20000)

http_client:send {
method = "GET",
path = "/",
headers = {
["Host"] = "mock"
}
}
-- C* is so slow we need to wait
helpers.pwait_until(function()
assert.res_status(200, http_client:send {
method = "GET",
path = "/",
headers = {
["Host"] = "mock"
}
})
end)
end)

after_each(function()
helpers.stop_kong()

Expand Down

1 comment on commit 626a41f

@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:626a41ff9bdb8d493f036f8e16e098ca4cb7feec
Artifacts available https://github.com/Kong/kong/actions/runs/3799384454

Please sign in to comment.