Repository navigation
Test the idle transfer guard on a simulated clock - #420
Merged
Merged
Conversation
The guard test had a handler write a byte every three quarters of the timeout, leaving 50ms of slack per gap before a transfer that was in fact progressing got cancelled. That is thinner than a loaded VM can promise, and it failed intermittently on the OpenBSD runner. Drive the guard through a stub transport inside a synctest bubble, where the gaps are exact and the seconds they simulate cost no wall time. That buys a longer timeout and more of them than the real clock allowed. A stand-in body can't show that cancelling the context aborts a read blocked on a socket, so a smaller test over a real connection still covers that. Both stalled cases now read in a goroutine and fail on a deadline rather than hanging when the guard never fires.
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.
The guard test had a handler write a byte every three quarters of the timeout, leaving 50ms of slack per gap before a transfer that was in fact progressing got cancelled. That is thinner than a loaded VM can promise, and it failed intermittently on the OpenBSD runner with
context canceled.The guard is now driven through a stub transport inside a
testing/synctestbubble, where the gaps are exact and the seconds they simulate cost no wall time. That affords a one-second timeout and twenty gaps where the real clock only allowed 200ms and three. A realhttptestserver does not work inside a bubble, since a goroutine blocked on a socket is not durably blocked and the clock never advances.A stand-in body cannot show that cancelling the request context aborts a read blocked on a socket, so a smaller test over a real connection still covers that.
Both stalled cases read in a goroutine and fail on a deadline instead of hanging, so a guard that stops firing is reported in milliseconds rather than running the job into its timeout.