Skip to content

Commit 4b30542

Browse files
authored
[Blazor] Reliability improvements for the E2E tests (#15320)
1 parent 60cb700 commit 4b30542

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

src/Components/Ignitor/src/BlazorClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ public async Task<bool> ConnectAsync(Uri uri, bool connectAutomatically = true)
348348
});
349349

350350
_hubConnection = builder.Build();
351-
await HubConnection.StartAsync(CancellationToken);
352351

353352
HubConnection.On<int, string>("JS.AttachComponent", OnAttachComponent);
354353
HubConnection.On<int, string, string>("JS.BeginInvokeJS", OnBeginInvokeJS);
@@ -357,6 +356,8 @@ public async Task<bool> ConnectAsync(Uri uri, bool connectAutomatically = true)
357356
HubConnection.On<string>("JS.Error", OnError);
358357
HubConnection.Closed += OnClosedAsync;
359358

359+
await HubConnection.StartAsync(CancellationToken);
360+
360361
if (!connectAutomatically)
361362
{
362363
return true;

src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@
5757
<Compile Include="$(RepoRoot)src\Shared\Components\ServerComponentMarker.cs" />
5858
</ItemGroup>
5959

60+
<ItemGroup>
61+
<None Update="xunit.runner.json">
62+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
63+
</None>
64+
</ItemGroup>
65+
6066
</Project>

src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.AspNetCore.Components.RenderTree;
1212
using Microsoft.AspNetCore.Components.Web;
1313
using Microsoft.AspNetCore.SignalR.Client;
14+
using Microsoft.AspNetCore.Testing;
1415
using Microsoft.Extensions.Logging;
1516
using TestServer;
1617
using Xunit;

src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ protected virtual Task InitializeAsync()
8383
return Task.CompletedTask;
8484
}
8585

86-
protected virtual Task DisposeAsync()
86+
protected async virtual Task DisposeAsync()
8787
{
8888
if (TestSink != null)
8989
{
9090
TestSink.MessageLogged -= TestSink_MessageLogged;
9191
}
9292

93-
return Task.CompletedTask;
93+
await Client.DisposeAsync();
9494
}
9595

9696
private void TestSink_MessageLogged(WriteContext context)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// This is set to -1 to allow the usage of an
3+
// unlimited ammount of threads.
4+
"maxParallelThreads": -1,
5+
"diagnosticMessages": true,
6+
"longRunningTestSeconds": 30
7+
}

0 commit comments

Comments
 (0)