Skip to content

Conversation

CarnaViire
Copy link
Member

@CarnaViire CarnaViire commented Jul 3, 2025

UPD: all related CI passed (innerloop+outerloop+wasm)

Fixes #73849
Fixes #28957

[WIP until CI validation on all platforms]

Expanding test coverage by bringing all of the OuterLoop external server tests to also run in inner loop against the Loopback server.

  • reusing same echo handler code from the external server
  • adding HTTP/2 to test matrix
  • unifying hierarchical test structure to ensure full matrix coverage
  • enabled some previously disabled tests
  • fixed test loopback infra bugs for HTTP/2 websockets

Innerloop tests before:

Test Run Successful.
Total tests: 181
     Passed: 181
 Total time: 3.2344 Seconds

Innerloop tests after (181->661, +265%):

Test Run Successful.
Total tests: 682
     Passed: 661
    Skipped: 21
 Total time: 16.4301 Seconds

Known gaps:

  • hierarchical structure downsides (e.g. having to "duplicate" subclass definitions).
  • xUnit trait categorization limitations (same test cannot be both outerloop and non-outerloop on the same platform)
  • 2 tests are temporarily disabled (only on HTTP/2) due to timeouts, requires further investigation
  • Tried to keep reshuffling to a minimum, but some was necessary for logical grouping (e.g. external vs loopback separation)

@CarnaViire
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only poking my nose a bit in stuff I know 😄

@CarnaViire
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@CarnaViire CarnaViire marked this pull request as ready for review July 8, 2025 13:55
@CarnaViire CarnaViire changed the title [WIP] ClientWebSocket Loopback Server tests ClientWebSocket Loopback Server tests Jul 8, 2025
@CarnaViire CarnaViire requested a review from Copilot July 9, 2025 15:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR expands WebSocket test coverage by running external “OuterLoop” tests in the inner loop against a loopback server, adds HTTP/2 support, and unifies the test class hierarchy.

  • Refactored test data sources (EchoServers, EchoServersAndBoolean) to use Uri[] and streamlined MemberData generation.
  • Consolidated WebSocket setup into WebSocketHelper (added ConnectAsync, TestEcho, and UTF-8 helpers) and removed WebSocketData.
  • Updated .csproj files to include new loopback test files and removed obsolete ones.

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Net.WebSockets/tests/WebSocketCreateTest.cs Refactored echo server MemberData to use Uri[] and boolean combinations
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs Added ConnectAsync, TestEcho, and ToUtf8/FromUtf8; removed WebSocketData
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs Unified MemberData generation, added HTTP/2 query-header handling
Comments suppressed due to low confidence (3)

src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs:18

  • [nitpick] Consider renaming EchoServers_Values to something like EchoServerUris for clearer intent and to follow C# naming conventions without underscores.
        public static readonly Uri[] EchoServers_Values = System.Net.Test.Common.Configuration.WebSockets.GetEchoServers();

src/libraries/System.Net.WebSockets.Client/tests/LoopbackServer/LoopbackWebSocketServer.cs:135

  • [nitpick] The Options record has grown to many properties; consider splitting HTTP/1.1 vs HTTP/2 options into separate types or using nested builders to improve clarity and reduce complexity.
        public record class Options()

src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs:189

  • [nitpick] Calling Encoding.UTF8.GetBytes allocates a new byte array on each call; consider reusing a shared Encoding instance or using a pooled buffer for high-volume or large-message scenarios.
        public static ArraySegment<byte> ToUtf8(string text)

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just starting 😄
Publishing what I have so far, so it won't get lost.

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More feedback. Most is opinionated so don't take it as some directive.

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not poking into this more. :shipit:

@CarnaViire
Copy link
Member Author

/ba-g (unrelated) wasm timeout is already tracked by dotnet/dnceng#3008

@CarnaViire CarnaViire merged commit 292df8e into dotnet:main Jul 23, 2025
89 of 96 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests with LoopbackServer for web sockets Renable WebSocket Client tests with ServerInitiatedClose semantics
2 participants