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

Fully shutdown healthchecker on t.Cleanup() #6968

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iain-macdonald
Copy link
Contributor

Related issues: N/A

@@ -137,6 +137,7 @@ func GetTestEnv(t testing.TB) *real_environment.RealEnv {
}

healthChecker := healthcheck.NewHealthChecker("test")
t.Cleanup(healthChecker.Shutdown)
Copy link
Member

@bduffany bduffany Jul 9, 2024

Choose a reason for hiding this comment

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

I think as written, the shutdown functions will run asynchronously, while new tests are allowed to start executing, which doesn't seem ideal 🤔

I'd say we might want to call WaitForGracefulShutdown here but it looks like that has the side effect of starting the health checker loop, which might not be desired in tests? and it might increase test duration a bunch depending on how long the graceful shutdown takes

Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to have a testonly healthchecker that does something different here?

Copy link
Member

@bduffany bduffany Sep 26, 2024

Choose a reason for hiding this comment

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

hmm actually it looks like NewHealthChecker() is already starting the health checker loop. So the only concern would be increasing test duration. Maybe worth a try though and seeing whether tests get significantly slower or not. I would guess that graceful shutdown should be quick as long as we don't have any tests that are accidentally keeping RPC streams open at the end, preventing shutdown.

Speaking of testonly healthchecker though, one thing that we shouldn't do in tests is register the SIGINT / SIGTERM handlers - those are preventing Ctrl+C from working when running the test locally. But that's probably a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants