Skip to content

Commit

Permalink
Fix for unit tests failing. (#2029)
Browse files Browse the repository at this point in the history
Co-authored-by: Mitch Denny <midenn@microsoft.com>
  • Loading branch information
github-actions[bot] and mitchdenny authored Feb 1, 2024
1 parent bd64561 commit a181d33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/DistributedApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public ValueTask DisposeAsync()
/// <inheritdoc cref="IHost.StartAsync" />
public async Task StartAsync(CancellationToken cancellationToken = default)
{
await _host.StartAsync(cancellationToken).ConfigureAwait(false);
await ExecuteBeforeStartHooksAsync(cancellationToken).ConfigureAwait(false);
await _host.StartAsync(cancellationToken).ConfigureAwait(false);
}

/// <inheritdoc cref="IHost.StopAsync" />
Expand Down
8 changes: 6 additions & 2 deletions tests/Aspire.Hosting.Tests/TestProgramFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task InitializeAsync()

_httpClient = _app.Services.GetRequiredService<IHttpClientFactory>().CreateClient();

using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));

await _app.StartAsync(cts.Token);

Expand Down Expand Up @@ -105,7 +105,11 @@ public override TestProgram CreateTestProgram()
.AddHttpClient()
.ConfigureHttpClientDefaults(b =>
{
b.UseSocketsHttpHandler((handler, sp) => handler.PooledConnectionLifetime = TimeSpan.FromSeconds(5));
b.UseSocketsHttpHandler((handler, sp) =>
{
handler.PooledConnectionLifetime = TimeSpan.FromSeconds(5);
handler.ConnectTimeout = TimeSpan.FromSeconds(5);
});

// Ensure transient errors are retried.
b.AddStandardResilienceHandler();
Expand Down
6 changes: 6 additions & 0 deletions tests/Aspire.Hosting.Tests/XunitAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = true)]

0 comments on commit a181d33

Please sign in to comment.