From 4b3054265eb634071336c6e2883a2dfb1bc341f3 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 24 Oct 2019 18:59:07 +0200 Subject: [PATCH] [Blazor] Reliability improvements for the E2E tests (#15320) --- src/Components/Ignitor/src/BlazorClient.cs | 3 ++- .../Microsoft.AspNetCore.Components.E2ETests.csproj | 6 ++++++ .../ServerExecutionTests/ComponentHubReliabilityTest.cs | 1 + .../test/E2ETest/ServerExecutionTests/IgnitorTest.cs | 4 ++-- src/Components/test/E2ETest/xunit.runner.json | 7 +++++++ 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/Components/test/E2ETest/xunit.runner.json diff --git a/src/Components/Ignitor/src/BlazorClient.cs b/src/Components/Ignitor/src/BlazorClient.cs index cddc48e094..46637eb3bb 100644 --- a/src/Components/Ignitor/src/BlazorClient.cs +++ b/src/Components/Ignitor/src/BlazorClient.cs @@ -348,7 +348,6 @@ namespace Ignitor }); _hubConnection = builder.Build(); - await HubConnection.StartAsync(CancellationToken); HubConnection.On("JS.AttachComponent", OnAttachComponent); HubConnection.On("JS.BeginInvokeJS", OnBeginInvokeJS); @@ -357,6 +356,8 @@ namespace Ignitor HubConnection.On("JS.Error", OnError); HubConnection.Closed += OnClosedAsync; + await HubConnection.StartAsync(CancellationToken); + if (!connectAutomatically) { return true; diff --git a/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj b/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj index 5ddf7c9790..78fc48dc82 100644 --- a/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj +++ b/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj @@ -57,4 +57,10 @@ + + + PreserveNewest + + + diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs index 707aad52b9..52546042fb 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; using Microsoft.AspNetCore.Components.RenderTree; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Logging; using TestServer; using Xunit; diff --git a/src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs index 60ec73621a..c72eac1ff6 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs @@ -83,14 +83,14 @@ namespace Microsoft.AspNetCore.Components return Task.CompletedTask; } - protected virtual Task DisposeAsync() + protected async virtual Task DisposeAsync() { if (TestSink != null) { TestSink.MessageLogged -= TestSink_MessageLogged; } - return Task.CompletedTask; + await Client.DisposeAsync(); } private void TestSink_MessageLogged(WriteContext context) diff --git a/src/Components/test/E2ETest/xunit.runner.json b/src/Components/test/E2ETest/xunit.runner.json new file mode 100644 index 0000000000..baa05fb93d --- /dev/null +++ b/src/Components/test/E2ETest/xunit.runner.json @@ -0,0 +1,7 @@ +{ + // This is set to -1 to allow the usage of an + // unlimited ammount of threads. + "maxParallelThreads": -1, + "diagnosticMessages": true, + "longRunningTestSeconds": 30 +}