fix: remove contradictory timing in health handler test - #263
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestHttp_healthHandlerhas two pieces of timing that contradict each other. The server gets a 500ms context at line 67, and line 110 then waits up to a full second for that same server to answer. On a machine slow enough to take more than about 450ms to bind and serve, the context cancels the server whilerequire.Eventuallyis still retrying, and the test reports "server failed to start" having actually started it. Separately, a fixed 50ms sleep stood in for discovery loading five static rules at a 10ms interval; when that is short the health check sees fewer than four services and the count assertion fails instead.The server now gets a context that outlives the assertions, and the sleep is replaced by waiting on
svc.Mappers()reaching five.I could not reproduce the original failure red on my machine, and neither could a 40-run pass at
-cpu=1under load. Forcing the server context to expire during the wait does produce the exact observed failure, which is what the first change removes: