-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Start health checks early. #1319
Conversation
9cb5d9a
to
7c78105
Compare
@dtomcej feel free to continue where you left off. :-) |
7c78105
to
24ed5ed
Compare
I would prefer to not modify the code for testing purpose only. |
We need some kind of synchronization point to make sure all health check goroutines have completed by the time the test asserts the results. Without modifying the code, the only alternative I see is to wait a constant amount of time and hope that all requests have finished. However, that leads to both longer-than-necessary test runtimes and a potential source of flakiness, both of which I consider worse that the addition of a wait group. I tried to use the injected Thus, a handful of extra prod code to simplify testing seems justified. I've made sure the wait group is commented and unexported so code outside of the healthcheck package won't be able to access it. WDYT? |
Ouch, not sure on this, sorry. |
24ed5ed
to
cb54814
Compare
@emilevauge I think I found a way: Did a bit of refactoring so that I can start the health-checking goroutine concurrently from the test; that way, I can also define the wait group in the test. The downside of this is that I'm not strictly testing the public API anymore but an unexported function (i.e., we start testing further down the stack). But that's not the worst either. Let me know what you think. (PS: Rebased too.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @timoreimann !
I love the way your refactored this.
LGTM :)
Could you rebase again ? |
cb54814
to
60ea919
Compare
Do not wait a full tick cycle to execute the first health check. Additional changes: - Make request timeout configurable (for testing purposes). - Support synchronizing on health check goroutine termination through an internal wait group (for testing purposes). - Stop leaking by closing the HTTP response body. - Extend health check logging and use WARNING level for (continuously) failing health checks.
@emilevauge squashed and rebased. |
Do not wait a full tick cycle to execute the first health check.
Additional changes: