Skip to content

[Fixes #19666] [Components] Improve reliability of component quarantined tests (take 2) #21499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Components/Ignitor/src/BlazorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,19 @@ public async Task<bool> ConnectAsync(Uri uri, bool connectAutomatically = true,
HubConnection.On<string>("JS.Error", OnError);
HubConnection.Closed += OnClosedAsync;

await HubConnection.StartAsync(CancellationToken);
for (var i = 0; i < 10; i++)
{
try
{
await HubConnection.StartAsync(CancellationToken);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrennanConroy will this leave the hubconnection in an invalid state if the call fails?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will leave it in a disconnected state

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm explictly asking if re-using the same hubconnection for the retries is OK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Although I'd love to know why you think this is needed. SignalR has 100's of tests that use the HubConnection to connect to a server and doesn't need to use retries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just being cautious here. Based on the error I have not much idea of what can be going wrong. Other than the server is taking longer to start?

break;
}
catch
{
await Task.Delay(500);
// Retry 10 times
}
}

if (!connectAutomatically)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
Expand All @@ -22,6 +24,32 @@ public ComponentHubReliabilityTest(BasicTestAppServerSiteFixture<ServerStartup>
{
}

protected override async Task InitializeAsync()
{
await base.InitializeAsync();

var rootUri = ServerFixture.RootUri;
var baseUri = new Uri(rootUri, "/subdir");
var client = new HttpClient();
for (var i = 0; i < 10; i++)
{
try
{
var response = await client.GetAsync(baseUri + "/_negotiate");
if (response.StatusCode == HttpStatusCode.OK)
{
break;
}
}
catch
{
await Task.Delay(500);
throw;
}
}

}

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/19414")]
public async Task CannotStartMultipleCircuits()
Expand Down