Repository navigation
Tests: hold the refused port in the 502 proxy test - #2
Merged
Merged
Conversation
The test closed a server to get a free port and assumed nothing else would listen there. With tests running in parallel another test server could take the port, so CONNECT succeeded and the test saw 200 instead of 502 (seen on the macOS runner in PR #1). Bind a socket without listening and keep it open for the whole test instead.
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 "allowed host that can't be reached gets 502" test freed a port by closing a test server and assumed nothing else would listen on it. Tests run in parallel, so another test server could grab that port in between. CONNECT then succeeded and the test got 200 instead of 502. That's what failed on the macOS job in #1, which doesn't touch the proxy.
Now the test binds a socket to an ephemeral port without listening and keeps it open until the end, so the port refuses connections and nobody else can take it.
Ran
swift test --filter NetworkTestslocally on macOS: all 17 pass.