-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mt] Add signalR WBT on WASM browser app (#100723)
* WIP, fixing net::ERR_CONNECTION_REFUSED. * Change of setup - aspnet project serving WASM static files. * Enable SharedArrayBuffer. * WIP, investigating `JsonSerializerIsReflectionDisabled` * Fix serialization issue. * Fixed * Cleanup. * Trying to fix integrity check issue. * Async interop + more logging. * Move test preparation code to a method. * Remove buttons, match other TestAppScenarios style. * Moved the test out of TestAppScenarios. Standalone version works. * Working version of test. * Cleanup. * Cleanup. * @maraf's feedback - simplify the prebuild steps. * WIP - merging blazor and wasmapp into one proj. * Missing change in a non-related test. * Do not pack blazor into a subfolder. * Remove old app. * Connect test logic, simplify. * Not intentional. * AspServer serves only "standard content types" * Prevent loosing `InnerException` on exceptions thrown during `TaskCompletionSource` completion. * Revert. * Cleanup. * @maraf's cleanup * SignalR hub is located in a url with path. * Fix "GET http://localhost:5000/wasmclient, Response status code: 404"
- Loading branch information
1 parent
7a5542d
commit 66ce263
Showing
37 changed files
with
528 additions
and
371 deletions.
There are no files selected for viewing
This file contains 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
27 changes: 27 additions & 0 deletions
27
src/mono/wasm/Wasm.Build.Tests/AspNetCore/SignalRClientTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
|
||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests.AspNetCore; | ||
|
||
public class SignalRClientTests : SignalRTestsBase | ||
{ | ||
public SignalRClientTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
[ConditionalTheory(typeof(BuildTestBase), nameof(IsWorkloadWithMultiThreadingForDefaultFramework))] | ||
[InlineData("Debug", "LongPolling")] | ||
[InlineData("Release", "LongPolling")] | ||
[InlineData("Debug", "WebSockets")] | ||
[InlineData("Release", "WebSockets")] | ||
public async Task SignalRPassMessageWasmBrowser(string config, string transport) => | ||
await SignalRPassMessage("wasmclient", config, transport); | ||
} |
This file contains 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
30 changes: 30 additions & 0 deletions
30
src/mono/wasm/Wasm.Build.Tests/Blazor/SignalRClientTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
using System.Threading.Tasks; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
|
||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests.Blazor; | ||
|
||
public class SignalRClientTests : SignalRTestsBase | ||
{ | ||
public SignalRClientTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
[ConditionalTheory(typeof(BuildTestBase), nameof(IsWorkloadWithMultiThreadingForDefaultFramework))] | ||
[ActiveIssue("https://github.com/dotnet/runtime/issues/100445")] // to be fixed by: "https://github.com/dotnet/aspnetcore/issues/54365" | ||
[InlineData("Debug", "LongPolling")] | ||
[InlineData("Release", "LongPolling")] | ||
[InlineData("Debug", "WebSockets")] | ||
[InlineData("Release", "WebSockets")] | ||
public async Task SignalRPassMessageBlazor(string config, string transport) => | ||
await SignalRPassMessage("blazorclient", config, transport); | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using Wasm.Build.Tests.TestAppScenarios; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests; | ||
|
||
public class SignalRTestsBase : AppTestBase | ||
{ | ||
public SignalRTestsBase(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
protected async Task SignalRPassMessage(string staticWebAssetBasePath, string config, string transport) | ||
{ | ||
CopyTestAsset("WasmOnAspNetCore", "SignalRClientTests", "AspNetCoreServer"); | ||
PublishProject(config, runtimeType: RuntimeVariant.MultiThreaded, assertAppBundle: false); | ||
|
||
var result = await RunSdkStyleAppForBuild(new( | ||
Configuration: config, | ||
ServerEnvironment: new Dictionary<string, string> { ["ASPNETCORE_ENVIRONMENT"] = "Development" }, | ||
BrowserPath: staticWebAssetBasePath, | ||
BrowserQueryString: new Dictionary<string, string> { ["transport"] = transport, ["message"] = "ping" } )); | ||
|
||
string testOutput = string.Join("\n", result.TestOutput) ?? ""; | ||
Assert.NotEmpty(testOutput); | ||
// check sending and receiving threadId | ||
string threadIdUsedForSending = GetThreadOfAction(testOutput, @"SignalRPassMessages was sent by CurrentManagedThreadId=(\d+)", "signalR message was sent"); | ||
string threadIdUsedForReceiving = GetThreadOfAction(testOutput, @"ReceiveMessage from server on CurrentManagedThreadId=(\d+)", "signalR message was received"); | ||
string consoleOutput = string.Join("\n", result.ConsoleOutput); | ||
Assert.True("1" != threadIdUsedForSending || "1" != threadIdUsedForReceiving, | ||
$"Expected to send/receive with signalR in non-UI threads, instead only CurrentManagedThreadId=1 was used. ConsoleOutput: {consoleOutput}."); | ||
} | ||
|
||
private string GetThreadOfAction(string testOutput, string pattern, string actionDescription) | ||
{ | ||
Match match = Regex.Match(testOutput, pattern); | ||
Assert.True(match.Success, $"Expected to find a log that {actionDescription}. TestOutput: {testOutput}."); | ||
return match.Groups[1].Value ?? ""; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.