Deflake Kestrel low response rate tests #13532
Merged
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.
After the netcoreapp3.0 to netcoreapp5.0 dependency update yesterday. Kestrel's ConnectionNotClosedWhenClientSatisfiesMinimumDataRateGivenLargeResponseChunks/Headers tests have become very, very flaky on Linux.
I'm not exactly sure what in the dependency update induced this flakiness (I assume it's some change to System.Net.Sockets), but my guess is that doing a "Connection: close" response where Kestrel disposes the socket immediately after writing the final response body while the client is reading the response at a very low rate is part of the problem leading the connection resets reported by the client.
To fix this, we might want to consider addressing #13219 which would mean waiting for a FIN from the client (with some timeout) before fully closing the socket.
Since the now-flaky tests were intended to verify that Kestrel didn't abort the request because of MinOutputDataRate timeout, I rewrote the tests to use a keep-alive connection instead.
I then added a new test which I pre-marked as flaky on Linux and Helix which verifies that "Connection: close" responses can be read at a low rate.