Centralize test timeout constants to fix CI flakiness (#1224)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
This commit is contained in:
Copilot 2026-01-30 13:47:11 -08:00 • committed by GitHub
commit a83d6198a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,6 +33,7 @@ public sealed class Program
private readonly ILoggerProvider? _loggerProvider;
private readonly IConnectionListenerFactory? _kestrelTransport;
private readonly TaskCompletionSource _serverStarted = new(TaskCreationOptions.RunContinuationsAsynchronously);
/// <summary>
/// Initializes a new instance of the <see cref="Program"/> class with logging and transport parameters.
@ -47,6 +48,11 @@ public sealed class Program
_kestrelTransport = kestrelTransport;
}
/// <summary>
/// Gets a task that completes when the server has started and is ready to accept connections.
/// </summary>
public Task ServerStarted => _serverStarted.Task;
// Track if we've already issued an already-expired token for the CanAuthenticate_WithTokenRefresh test which uses the test-refresh-client registration.
public bool HasRefreshedToken { get; set; }
@ -541,7 +547,20 @@ public sealed class Program
Console.WriteLine($"Demo Client ID: {clientId}");
Console.WriteLine($"Demo Client Secret: {clientSecret}");
await app.RunAsync(cancellationToken);
await app.StartAsync(cancellationToken);
_serverStarted.TrySetResult();
// Wait until cancellation is requested
try
{
await Task.Delay(Timeout.Infinite, cancellationToken);
}
catch (OperationCanceledException)
{
// Expected when cancellation is requested
}
await app.StopAsync();
}
/// <summary>