We have a bunch of test assemblies that don't make sense on some platforms, e.g. Browser.
Right now we're skipping them via `[SkipOnMono("reason", TestPlatforms.Browser)]` but there's nothing that inherently ties this to Mono other than the current implementation.
The more generic `SkipOnPlatform` attribute can be used instead.
We can also use it in places where we do `[PlatformSpecific(~TestPlatforms....)]` to avoid the double inversion.
This isn't a big deal as it's once per websocket connection, but it annoys me every time I see the unnecessary waste in a trace. Previously this would allocate:
1. A byte[] for the bytes from the guid
2. A base64-encoded string for (1)
3. A string concatenating (2) and the known server guid
4. A byte[] containing the bytes from (3)
5. A byte[] containing the SHA1-hashed bytes of (4)
6. A base64-encoded string of (5)
Now, it only allocates (2) and (6).
* Set the WebSocketException to Faulted to fix tests
* Fix the exceptions that are being thrown to coincide with test expectations
* Fix Dispose we are not processing it multiple times.
* Fix Abort code so the messages align correctly with the tests.
example from tests:
```
Assert.Equal() Failure
info: Expected: Aborted
info: Actual: Closed
```
* Set the WebSocketException to Faulted to fix test expectations
* Close the connections correctly.
* Fix Abort test Abort_CloseAndAbort_Success
- This was causing a never ending Task when aborted after a Close already executed.
- Never ended which was a cause of memory errors after left running.
- See also https://github.com/dotnet/runtime/issues/45586
* - Fixes for ReceiveAsyncTest
- Exception text not sent correctly. This test was expecting 'Aborted'.
- Mismatched expected exception messages
- Make sure the connection is torn down.
- Multiple GC calls that end in running out of memory fixed. https://github.com/dotnet/runtime/issues/45586
```
// [FAIL] System.Net.WebSockets.Client.Tests.CancelTest.ReceiveAsync_AfterCancellationDoReceiveAsync_ThrowsWebSocketException(server: ws://corefx-net-http11.azurewebsites.net/WebSocket/EchoWebSocket.ashx)
// info: Assert.Equal() Failure
// info: ↓ (pos 39)
// info: Expected: ··· an invalid state ('Aborted') for this operation. Valid state···
// info: Actual: ··· an invalid state ('Open') for this operation. Valid states a···
// info: ↑ (pos 39)
```
* Remove ActiveIssue attributes that should be fixed
* Add back code after merge conflict
- Update tests that are resolved.
* Fix tests that were failing when expecting CloseSent as a valid state.
```
// fail: [FAIL] System.Net.WebSockets.Client.Tests(server: ws://corefx-net-http11.azurewebsites.net/WebSocket/EchoWebSocket.ashx)
// info: Assert.Throws() Failure
// info: Expected: typeof(System.OperationCanceledException)
// info: Actual: typeof(System.Net.WebSockets.WebSocketException): The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseSent'
```
* Fix the Abort and Cancel never ending tests.
- Fix the clean up of the task and set or cancel the task cleanly.
* Add ActiveIssue to websocket client SendRecieve tests
* Add ActiveIssue to websocket client SendRecieve tests
- intermittently failing with System.OperationCanceledException : The operation was canceled.
* Add extra time to timeout for a couple of tests that were intermittently failing with System.OperationCanceledException : The operation was canceled.
- This was an ActiveIssue https://github.com/dotnet/runtime/issues/46909 but extending the time seems to do the job.
* Add ActiveIssue to websocket client SendRecieve tests
- [browser][websocket] Hang with responses without ever signaling "end of message"
- [ActiveIssue("https://github.com/dotnet/runtime/issues/46983", TestPlatforms.Browser)] // JS Fetch does not support see issue
* Remove `Interlocked` code as per review comment.
* Fix comment
* Fix Abort tests on non chrome browsers.
- Fix for those browsers that do not set Close and send an onClose event in certain instances i.e. firefox and safari.
- Chrome will send an onClose event and we tear down the websocket there. Other browsers need to be handled differently.
* We should not throw here.
- Closing an already-closed ClientWebSocket should be a no-op.
* Add `CloseOutputAsync` implementation
- The browser websocket implementation does not support this so we fake it the best we can.
* Remove `ActiveIssue` and add more tests
- Remove `[ActiveIssue("https://github.com/dotnet/runtime/issues/45468", TestPlatforms.Browser)]`
- Add more tests
* Address timeout implementation review
* Add code as per SignalR comments to prevent long wait times in some cases
As per comments
- We clear all events on the websocket (including onClose),
- call websocket.close()
- then call the user provided onClose method manually.
* Update src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs
Co-authored-by: Larry Ewing <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Address review comments for using `TrySet*` variants
* Address review about using PascalCasing
* Change test to be a platform check and not an ActiveIssue as per review
Co-authored-by: Larry Ewing <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
Somehow when it was ported to .NET Core, the transition from connecting to connected was switched to being done before the connect rather than after. As a result, if the connection fails and the websocket is never initialized, subsequent use (misuse) ends up null ref'ing. This restores the .NET Framework behavior, which was to dispose of the instance if the connect fails; subsequent operations then throw ObjectDisposedException.
Get rid of StreamWriter usage in HTTP loopback server and fix HTTP/1.1 loopback implementation of SendResponseBodyAsync
Co-authored-by: Geoffrey Kizer <[email protected]>
* [browser][websocket] Fix for Close Description validation
- Issue https://github.com/dotnet/runtime/issues/45531
- The description validation exception was not being percolated through to the unit test
* Remove test code
* Address review comments. Wrap in a try/catch that will catch that exception and store it into a task to be returned.
* Fix merge conflict
* Remove active issue
Co-authored-by: Larry Ewing <[email protected]>
* [browser][tests][outerloop] Standup OuterLoop tests
* Reference issue not PR
* Add active issue for CloseDescription failing tests
* Add active issue for failures for invalid close codes failing tests
* Add active issue for failures when specifying subprotocol by URI Query
* Add active issue for Uncaught RuntimeError: memory access out of bounds
* Remove ActiveIssue and initialize with specific platform detection code
- Removes the necessity of setting up a new test.
- May want to go back to ActiveIssue for tracking purposes.
* Add ActiveIssue for CloseOutputAsync
* Add ActiveIssue for AbortTests
* Remove ActiveIssue and initialize with specific platform detection code
- Removes the necessity of setting up a new test.
- May want to go back to ActiveIssue for tracking purposes.
* Remove Active issue as it was fixed.
* Add ActiveIssue for CancelTests that is part of the Abort tests changes
* Update src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketOptionsTests.cs
Point to WebProxy support issue
Co-authored-by: Larry Ewing <[email protected]>
* [browser][websocket] Throw OperationCanceledException on connect if cancel was requested before.
* try to handle cancellation in connect stage
* Add new test for inflight connect
- Add new supported property for skipping particular tests when Browser is detected and DOM is detected.
* first pass at throwing pnse when websocket is missing
* Address review comment
* Make the platform check explicit
* Revert CreateDefaultOptions change
* Address review comment
Co-authored-by: Larry Ewing <[email protected]>
* [browser][tests] Standup System.Net.WebSockets.Client.Tests in CI
* Just a small test to see if tests are actually kicked off and failing.
* Remove comment from ActiveIssue to pass tests
* Address review comments
- mark the loopback issues as activeIssue - [ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Browser)]
* Address review comments
* Correct confusion I caused
* Remove extra extra exclusion that snuck in
* Make browser specific failure browser specific
Co-authored-by: Larry Ewing <[email protected]>
* Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser
* Add the attributes to non-browser version of ClientWebSocketOptions class to avoid build error
* Add using
* Include platform attributes
- Remove depprojs which currently binplace external references into the RefPath folders in favor of PackageReference and PackageDownload items.
- Build all configurations by default when building an individual project (either on the CLI or inside VS) same as with the official SDK. This enables .NETFramework Test Explorer support.
- Centrally define libraries that compose the shared framework instead of in each Directory.Build.props file to be able to build the targeting pack first and consume it in the OOB libraries.
- Use ProjectReferences to reference OOB projects. Compile against the reference assembly but use the implementation assembly app-local during runtime.
- Remove OOBs from the testhost and remove the testhost folder for .NETFramework as it isn't required anymore.
- Only binplace for $(NetCoreAppCurrent) to compose a) the targeting pack, b) the runtime pack, c) the testhost, d) a full closure for the shims.
- Use Targeting Packs for OOB projects (with their implicit assembly references) but still explicitly define granular references for .NETCoreApp configurations (DisableImplicitAssemblyReferences switch). Use the implicit targeting pack references in some Microsoft.Extensions.* cases.
- Remove placeholder configurations as they aren't needed anymore with explicit P2Ps vs Targeting Pack references.
- Remove implicit assembly references (ie for .NETFramework, mscorlib)
- Remove AssemblySearchPath hacks that were introduced with b7c4cb7 as the targeting pack is now used by default.
- Reduce unnecessary .NETFramework configurations that were added to run tests in favor of the already existing ref&src configurations.
- Stop hardcoding the paths for wasm assemblies and use the returned TargetPath of the ProjectReferences.
- Addressed formatting (ItemGroups, References at the bottom of the project file, ordering of references, use LibrariesProjectRoot instead of a relative path, unnecessary AssemblyName and RootNamespace properties which are identical to the project name, ordering of tfms)
- Revert "fix clean (#33758)"
It's raising a single event for failed connects, and actual networking-related failures for failed connects will already be logged by the underlying API used.
By getting rid of the catch and rethrow, we can also avoid an extra layer of async state machine on connect.
* [browser][wasm] Initial addition of WebSockets support
* Clean up usings
* Create and use a WebSocketHandle.Browser.cs module
* Add conditional TARGETS_BROWSER so as not to throw Proxy PNSE during ClientWebSocket creation.
* Update WebSockets code
* Removing debug line
* Remove `ThrowIfReadOnly` method to address review comments
* Address review comments
- change accessor of _requestedSubProtocols to private
- condition more code in WebSocketHandle.Managed.cs to not access _requestedSubProtocols
* Address review comments
* Address review comments
* Change to be PlatformNotSupportedException
* Add ConnectAsync implementation to create a new instance of the BrowserWebSocket implementation.
* Address review comments
* Address subprotocols comments
* Remove internal custom class ActionQueue class in favor of using a Channel.
* Fix object leak.
- Lambdas are not being released automatically.
* Add doc for the constant that is being used.
- Address review comment
* Clean up SendAsync method.
- Validate the message type.
- Validate the array segment that is passed as the message.
* Add validation to ReceiveAsync for invalid buffer.
- remove unnecessary null checks from message buffering.
* Address review comments
* Address review comments about TCS
* Address camel case by using enum
* Address abort request
* Handle nullable
* Address review comment for removing cancellationtoken registration to the connect source.
* Use non-generic TaskCompletionSource
* Cleanup var usage
* Add string to .resx
* Inline dispose
* Fix WebSocket opening exception
* Remove the asynchronous completion from SendAsync.
* Fix object leak, exception on close and address review comments
* Handle race condition
* Address TaskCompletionSource on connect review comments
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: campersau <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: campersau <[email protected]>
* Fix Connect not completing task on error.
* Cleanup reference
* Remove redundant error check of memorystream buffer.
* cleanup
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Fix typo
* clean up buffer code
* Modify callbacks to use lambda function.
- These are now released properly after reference counting went in.
* Fix object leak of delegate and clean up deprecated code.
* extract lambda into method
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Review comments addressed
Co-authored-by: campersau <[email protected]>
Co-authored-by: Maxim Lipnin <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
For the non-generic IEnumerator, we don't have any idea whether the type contains nulls or not. If we're forced to annotate it, `?` is correct, because it says "it's possible this is null" and we can't prove it's not. But that ends up leading to lots of spurious warnings, in particular when enumerating over supplied collections that won't ever contain null, e.g. enumerating a CookieCollection. Since the non-generic IEnumerator is effectively legacy, our best path forward while maintaining correctness and avoiding causing unnecessary warnings is to simply not annotate `IEnumerator.Current` at all, leaving it "oblivious"; in that way, we don't make any claims about its state, and leave it up to tooling how to best convey that.
- Adds the type, almost an exact copy of `TaskCompletionSource<TResult>`, but creating a `Task` instead of a `Task<TResult>`. Primary benefits here are symmetry, smaller `Task` object, and not forcing a developer to specify an unnecessary type name.
- Adds tests for both TCS and TCS<TResult>.
- Switches a bunch of usage of the generic type over to the non-generic, both in src and tests.
We allow at most one pending receive operation on a web socket, and CloseAsync needs to both send and receive, so if there's a pending receive already, it just reuses / waits for that existing one, which records if it sees a close frame. However, if the close operation is initiated with a cancellation token that's different from the cancellation token the receive operation was initiated with, the close won't respect the supplied cancellation token because it's just waiting on the existing receive. The fix is simply to register with this new cancellation token as well when there's an existing receive that we wait on.
CloseOutputAsync_Cancel_Success tests are failing due to 2 reasons:
1. `Assert` expecting the state to be `Aborted`, finds it's `Open` - most frequent
2. Connection gets forcibly terminated on a connect attempt
However, the second failure type is not specific to this test because it affects many tests in different types during the same time. Thus, it seems to be an infra issue.
This PR fixes only the first failure type by increasing Close operation timeout.
Fixes#1725
Changes:
- enabled `runtime (Libraries Test Run release mono Windows_NT x64 Debug)` CI lane (Windows Nano Server CI leg is disabled);
- enabled the tests that pass;
- marked failing test assemblies/classes/methods with `ActiveIssue` attribute using respective GH issues;
- removed CoreFX.issues_windows.rsp file and related mono rsp arguments.
Fixes#1980
* libraries -restore for vertical build without test restore
* Automatic test change and regex to remove the addition of an extra line at eof
* manual test restore fixed (restore completely done for vertical build)
* build native done
* Automatic ref change and regex to remove the last line
* manual reference assebly change and generated shims build
* automatic src change and regex
* native bin place and src build manual change
* apicompat and pretest.csproj done
* fixing the package build
* fixing all config
* packaging and feedback
* adding back placeholder configuration
* fixing the shims
* delete configuration.props
* making the build work in master
* Test Change
* fixing the packageing, test restore replacing TargetFramework -> OriginalTargetFramework
* delete test configuraiton.props, trailing semicolon and use targetFramework
* reverting the package change
* enable apicompat and fixing configurationGroup for individual projects
* fixing the api compat
* making ilproj work
* adding the outerBuildTest
* adding the arcade package version
* fixing the merge conflicts
* minor changes
* adding additional configs and setting the runtimeOS
* making the vs stuff work
* removing the target Group to fix the apicompat
* fixing the linux build and some minor changes
* making additionalBuildTargetFramework LOcalProperty
* fixing the allConfigurations build
* fixing the netfx build
* fixing package Testing and restore
* Missing TargetFrameworks tag
* making the VSdesgin stuff work
* Remove OriginalFramework Entirely
* some minor pr feedback
* RemoveExtraSemicolon
* use boolean exclude flag
* fixing yml scripts to pass tests
* adding comments and some minor feedback
* moving packaging property to correct plave
* fixing the build for web assembly
* Fixing the live ci build
* Fixing the live build for shims
* fixing the tests
* fixing the packaging and enterprise linux
* fixing package sizes
* Fix the targetFramework
* updating the targetFramework sdl
* removing the buildOS and be able to use OSGroup as done in the old system
* Fixing the osgroup stuff for send to helix task
* Fix OSX failures
* Fixing the osx build
* uploading tmp folder to artifacts
* running restore for runtime.deproj correctly
- In some cases, I deleted ActiveIssues associated with issues where the problem was supposedly fixed. We'll see.
- In some cases, I deleted test cases entirely, e.g. where the corresponding issue said effectively "we'll live with the behavior" or "another repo is responsible for this now" (paraphrasing), or where the tests were initially added to the repo years ago already disabled and against bug numbers from some old bug database.
- In some cases, I replaced the link with the correct one.
- In some cases, I re-opened closed issues.
* Address more issue numbers in the code
Replaced a bunch of unadorned issue numbers with links, so we know which repo the issue is for. In some cases the repo was named, but for consistency I still replaced it with a link.
In some cases, in particular where the issue had been closed saying effectively "we're not going to do anything here", I removed TODOs and the associated issue numbers.
In a few cases, the TODO and issue number was to say "we should do X when Y is fixed", so I did X since Y was fixed.
* Apply suggestions from code review
Co-Authored-By: Jan Kotas <[email protected]>
* Address PR feedback
* Fix OrderedEnumerable by using MemoryExtensions.Sort
Co-authored-by: Jan Kotas <[email protected]>
Disables `ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage`
as it's consistently failing in the outerloop jobs. Specifically the
libraries linux outerloop job.
Tracking Issue is #1895