Skip to content

Commit 4c404a8

Browse files
committed
Tweak timeouts for tests
1 parent 86fd2ea commit 4c404a8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/OutputWatcherTestProject/Tests/OutputWatcherIntegrationTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
using Microsoft.Extensions.Configuration;
12
using Microsoft.Extensions.Logging;
23
using System.Runtime.CompilerServices;
4+
using System.Threading;
35
using Xunit.Abstractions;
46

57
namespace OutputWatcherTestProject.Tests;
68

79
public class OutputWatcherIntegrationTests(ITestOutputHelper outputHelper)
810
{
911
private void WriteFunctionName([CallerMemberName] string? caller = null) => outputHelper.WriteLine(caller);
12+
private const int WaitForHealthyTimeoutSeconds = 90;
1013
private static readonly TimeSpan WaitForHealthyTimeout = TimeSpan.FromSeconds(90);
1114

1215
private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
@@ -18,6 +21,7 @@ private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
1821
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AspireAppHostWaitForConsole>([], (dab, host) =>
1922
{
2023
dab.EnableResourceLogging = true;
24+
host.Configuration!.AddUserSecrets<OutputWatcherIntegrationTests>();
2125
});
2226
appHost
2327
.Services
@@ -30,12 +34,12 @@ private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
3034

3135
appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
3236
{
33-
37+
var timeout = TimeSpan.FromSeconds(appHost.Configuration.GetValue<double>("HttpClientTimeout", 30));
3438
clientBuilder
3539
.AddStandardResilienceHandler(res => {
36-
res.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(120);
37-
res.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(60);
38-
res.AttemptTimeout.Timeout = TimeSpan.FromSeconds(30);
40+
res.TotalRequestTimeout.Timeout = timeout * 4;
41+
res.CircuitBreaker.SamplingDuration = timeout * 2;
42+
res.AttemptTimeout.Timeout = timeout;
3943
});
4044
clientBuilder
4145
.ConfigurePrimaryHttpMessageHandler(() =>

0 commit comments

Comments
 (0)