Repository navigation
Add System.Net.WebSockets.Client tests - #4478
Conversation
|
@CIPop @pgavlin @stephentoub PTAL |
There was a problem hiding this comment.
This could be placed in Test\Common: we may want to use it in other tests.
There was a problem hiding this comment.
Fixed. Moved to src/Common/tests/System/AssertExtensions.cs
|
LGTM You may need to change the author to dotnet-bot since you are porting code from the internal repository. |
There was a problem hiding this comment.
Nit: formatting should be:
if (WebSocketHelper.ShouldSkipTestOSNotSupported(_output))
{
return;
}
There was a problem hiding this comment.
To be honest, I usually would have formatted like that (since I tell others to do so).
But it just seemed so wasteful in white space. What I really want is an Xunit attribute that can be added via some [Skip] attribute with PlatformID.Windows7. Or even better something more dynamic that does the same check for 'PlatformNotSupportedException'.
So, I can change the formatting to conform to our own rules, but I view it as temporary until we getting "skipping" capability in our tests.
|
LGTM aside from one nit regarding formatting. Thanks for porting these! |
|
I will change author to dotnet-bot during final squash of commits. |
* Port some of the ToF ClientWebSocket tests that talk to a real websocket server * Cleanup naming of existing tests to conform to System.Net test method naming * Skip tests if not supported on platform. Specifically, these tests were failing on Win7 since Win7 does not support WinHttp WebSockets. We haven't really noticed this failing since the CI doesn't yet run Win7 tests (issue #4468) I plan to port the remainder of the ToF websocket related tests in a subsequent PR.
There was a problem hiding this comment.
As with Sockets: these tests use bad dev patterns to ensure that in certain cases the objects get GCed with no issues.
We don't expect FunctionalTests to be deterministic.
There was a problem hiding this comment.
I think we're slightly inconsistent on this point because the Http tests, for the most part, show proper dev pattern and have Dispose or using patterns. The exception is when we are explicitly testing for certain behavior with various patterns of using/not-using Dispose.
With regard to these tests, some of the tests are explicitly testing against different Dispose semantics, i.e. call methods after Dispose, etc.
I'll make a note to be more explicit about this. I think we should be more consistent.
|
I tried running these tests locally. About half of the time they pass, and about half of the time I get errors like this: |
What OS and version are you using? |
OS Name: Microsoft Windows 10 Enterprise |
There was a problem hiding this comment.
I've never actually looked into this until now, but seeing each of these tests begin with this boilerplate made me want to see if xunit extensibility could be employed here. Instead of using this boilerplate in each test, I just tried adding this code to the project:
[XunitTestCaseDiscoverer("System.Net.WebSockets.Client.Tests.RequiresWebSocketsFactDiscoverer", "System.Net.WebSockets.Client.Tests")]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class RequiresWebSocketsFact : FactAttribute { }
public class RequiresWebSocketsFactDiscoverer : IXunitTestCaseDiscoverer
{
private readonly IMessageSink _diagnosticMessageSink;
public RequiresWebSocketsFactDiscoverer(IMessageSink diagnosticMessageSink)
{
_diagnosticMessageSink = diagnosticMessageSink;
}
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
return WebSocketsHelper.WebSocketsIsSupported ?
new IXunitTestCase[] { new XunitTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, null) } :
Array.Empty<IXunitTestCase>();
}
}and then instead of this boilerplate at the beginning of each method, I was able to attribute each test with:
[RequiresWebSocketsFact]instead of:
[Fact]Something to consider.
There was a problem hiding this comment.
@stephentoub Thx. I like this. But how would it work for Theory instead of Fact ?
There was a problem hiding this comment.
I think you'd need to add a RequiresWebSocketsTheoryAttribute and associated discoverer as well.
There was a problem hiding this comment.
I will work on this extensions attributes as part of the next WebSockets PR I'll be doing.
There was a problem hiding this comment.
Cool. We should also be able to generalize it to some sort of [ConditionalFact("MethodThatReturnsBoolean")] and the same for theory, which we could put in our xunit extensions and then use elsewhere.
There was a problem hiding this comment.
I had been looking at this also. Doesn't work on CoreCLR yet.
There was a problem hiding this comment.
I'm working on adding something to buildtools. Don't block on it, though.
|
@dotnet-bot test this please |
|
System.Net.Security.Tests.ClientAsyncAuthenticateTest.ClientAsyncAuthenticate_EachProtocol_Success |
|
@dotnet-bot test this please |
Looks like the same three that failed here: https://github.com/dotnet/corefx/issues/4467 |
Add System.Net.WebSockets.Client tests
Add System.Net.WebSockets.Client tests Commit migrated from dotnet/corefx@e17dd58
on Win7 since Win7 does not support WinHttp WebSockets. We haven't really noticed this
failing since the CI doesn't yet run Win7 tests (issue #4468)
I plan to port the remainder of the ToF websocket related tests in a subsequent PR.