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

chore(tests): add a test case for /metrics endpoint #12695

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

liverpool8056
Copy link
Contributor

Summary

A test case is added for testing /metrics endpoint when database is down.
And a db_proxy is added to spec/helpers for imitating database outage or performance decrease.
A related PR: https://github.com/Kong/kong-ee/pull/8321

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix #[issue number]

Add a test case for `/metrics` endpoint. We expect the metrics endpoint
can work weel even when database is down.

And a db_proxy is added to spec/helpers for imitating database outage
or performance decrease.
@AndyZhang0707 AndyZhang0707 force-pushed the database-outage-testcase branch from b5fbe3b to 798a869 Compare March 19, 2024 09:37
@github-actions github-actions bot added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Mar 19, 2024
Comment on lines 11 to 14
for _, strategy in helpers.all_strategies() do
describe("Metrics API - with strategy #" .. strategy, function()

if strategy == "postgres" then
Copy link
Contributor

Choose a reason for hiding this comment

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

We use helper.each_strategies() to avoid the `if strategy == "postgres".

spec/helpers.lua Outdated
Comment on lines 4193 to 4194
stream_listen = "0.0.0.0:5555",
proxy_listen = "0.0.0.0:16666",
Copy link
Member

Choose a reason for hiding this comment

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

If this is unused, will it be better just get_available_port?

Comment on lines +4177 to +4180
db_port = opts.db_port,
db_proxy_port = get_available_port(),
api_port = get_available_port(),
tcp_port = get_available_port(),
Copy link
Member

Choose a reason for hiding this comment

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

These ports should have documentation describing their purposes

}
end

function db_proxy:delay(delay)
Copy link
Member

Choose a reason for hiding this comment

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

A documentation describing how to use these functions would also be better

@liverpool8056 liverpool8056 force-pushed the database-outage-testcase branch from 123eb83 to ff7c582 Compare March 25, 2024 07:39
@@ -4156,6 +4156,243 @@ do
end
end

--------------
-- A kong based database proxy class for the simulation of database abnormal behavior.
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to move this to a separate file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants