Avoid slow parallel connect failures in SocketAsyncEventArgs test - #132931
Open
MihaZupan wants to merge 1 commit into
Open
Avoid slow parallel connect failures in SocketAsyncEventArgs test#132931MihaZupan wants to merge 1 commit into
MihaZupan wants to merge 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Pull request overview
This PR updates a flaky/slow System.Net.Sockets functional test that exercises Socket.ConnectAsync(..., ConnectAlgorithm.Parallel) failure behavior, by switching the target endpoint from a bound-but-not-listening port (which can hang on macOS) to the test suite’s reserved unused port to force prompt connection refusal.
Changes:
- Replace the per-test bound sockets/
PortBlockersetup withDualModeBase.UnusedPortfor a predictable “connection refused” failure. - Simplify the
Socket.ConnectAsyncinvocation by usingSocketType.Stream/ProtocolType.Tcpconstants directly.
File summaries
| File | Description |
|---|---|
| src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs | Reworks Connect_Parallel_Fails to use the reserved unused port to avoid OS-dependent connect latency/timeouts (notably on macOS). |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Comment on lines
+1134
to
1136
| // A bound but non-listening port can time out instead of refusing connections on macOS. | ||
| saea.RemoteEndPoint = new DnsEndPoint("localhost", DualModeBase.UnusedPort); | ||
| saea.Completed += (_, _) => mres.Set(); |
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.
Fixes #132059
Summary
SocketAsyncEventArgsTest.Connect_Parallel_Failsused IPv4 and IPv6 sockets that were bound but not listening. On macOS, connecting to such sockets can remain pending rather than fail promptly, causing the test to exceed its 30-second timeout.Use the test suite's reserved unused port instead. This still exercises parallel IPv4 and IPv6 connection failures while avoiding OS-dependent behavior for bound, non-listening ports.
Validation
clr+libsbaseline build passed.Connect_Parallel_Failspassed 50 consecutive local runs.System.Net.Socketsfunctional tests passed locally.osx.26.arm64.openHelix using the same macOS runtime payload:Across two macOS ARM64 machines per version, the original setup varied from approximately 8 to 19 seconds per completed test, while the updated test consistently completed in under 101 milliseconds. This confirms that the original setup has substantial OS-dependent latency and that using the reserved unused port removes it.
Note
This description was drafted with GitHub Copilot.