-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring tests to support both external and loopback servers #74579
Refactoring tests to support both external and loopback servers #74579
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #73849 I did an example on one test how I can run an existing scenarios on both external and loopback servers with different versions, security settings and attributes (like running on browser or outerloop). Please share your thoughts about the implementation because I would like to make changes before I apply it for the remaining scenarios.
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #73849 I did an example on one test how I can run an existing scenarios on both external and loopback servers with different versions, security settings and attributes (like running on browser or outerloop). Please share your thoughts about the implementation because I would like to make changes before I apply it for the remaining scenarios.
|
@MihaZupan @CarnaViire could you please have a look on the proposed changes? I would like to apply feedback earlier because after I add changes to other tests it will require a lot of copy paste. |
I think the pattern we use in Http tests is cleaner. We could add something like the following to protected virtual Version UseVersion => HttpVersion.Version11;
protected virtual bool UseRemoteServer => false;
protected Task CreateEchoServerAsync(Func<Uri, Task> clientFunc)
{
using var server = CreateServer(UseVersion, UseRemoteServer, ...);
await clientFunc(server.Uri);
}
protected Task<ClientWebSocket> GetConnectedWebSocket(Uri serverUri) =>
GetConnectedWebSocket(serverUri, TimeOutMilliseconds, _output, UseVersion)); This can then be used in tests like public async Task MyTest()
{
await CreateEchoServerAsync(async uri =>
{
using ClientWebSocket cws = await GetConnectedWebSocket(uri);
await cws.DoStuffAsync();
});
} This has a few benefits:
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs
Outdated
Show resolved
Hide resolved
9615aaf
to
0953346
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this looks much more familiar to the Http tests
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketOptionsTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs
Outdated
Show resolved
Hide resolved
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be WebSocket test failures, could you please check them?
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
Link="CommonTest\System\Security\Cryptography\PlatformSupport.cs" /> | ||
<Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs" | ||
Link="Common\System\Threading\Tasks\TaskTimeoutExtensions.cs" /> | ||
<Compile Include="$(CommonTestPath)System\Net\Capability.Security.cs" Link="Common\System\Net\Capability.Security.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the changes in this file needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were files added and others are auto-formatted
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs
Outdated
Show resolved
Hide resolved
@@ -419,6 +636,37 @@ public async Task SendReceive_Concurrent_Success(Uri server) | |||
} | |||
} | |||
|
|||
[ConditionalFact(nameof(WebSocketsSupported))] | |||
public async Task SendReceive_Concurrent_Success_Base() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you don't plan to update all the WebSocket tests to new format in this PR, is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Co-authored-by: Natalia Kondratyeva <[email protected]>
For now there failed one unrelated build and local http2 web socket tests on Libraries Test Run release coreclr windows x86 Release. I see the intermittent failures indicating that web socket is in closed state. |
749974e
to
18f1b1f
Compare
I will take over this PR, approximately in a month. Marking as draft for now. |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Fixes #73849
I did an example on one test
SendReceive_Concurrent_Success_Base
how I can run an existing scenarios on both external and loopback servers with different versions, security settings and attributes (like running on browser or outerloop).Please share your thoughts about the implementation because I would like to make changes before I apply it for the remaining scenarios.