Skip to content

Tests: hold the refused port in the 502 proxy test - #2

Merged
Kernel-Hunter merged 1 commit into
mainfrom
fix/refused-port-test
Oct 10, 2026
Merged

Kernel-Hunter merged 1 commit into
mainfrom
fix/refused-port-test

Conversation

@Kernel-Hunter

Copy link
Copy Markdown
Owner

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 NetworkTests locally on macOS: all 17 pass.

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.
@Kernel-Hunter
Kernel-Hunter merged commit d724cdf into main Oct 10, 2026
3 checks passed
@Kernel-Hunter
Kernel-Hunter deleted the fix/refused-port-test branch October 10, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant