WaitSiteIsOperational should only wait full sync

This commit is contained in:
nicolas.dorier
2020-03-10 17:24:38 +09:00
parent e6acc19bcc
commit 2e630ac5d8

View File

@@ -231,23 +231,13 @@ namespace BTCPayServer.Tests
private async Task WaitSiteIsOperational() private async Task WaitSiteIsOperational()
{ {
_ = HttpClient.GetAsync("/").ConfigureAwait(false);
using (var cts = new CancellationTokenSource(20_000)) using (var cts = new CancellationTokenSource(20_000))
{ {
var synching = WaitIsFullySynched(cts.Token); var synching = WaitIsFullySynched(cts.Token);
var accessingHomepage = WaitCanAccessHomepage(cts.Token); await Task.WhenAll(synching).ConfigureAwait(false);
await Task.WhenAll(synching, accessingHomepage).ConfigureAwait(false);
}
}
private async Task WaitCanAccessHomepage(CancellationToken cancellationToken)
{
while (true)
{
var resp = await HttpClient.GetAsync("/", cancellationToken).ConfigureAwait(false);
if (resp.StatusCode == HttpStatusCode.OK)
break;
await Task.Delay(10, cancellationToken).ConfigureAwait(false);
} }
// Opportunistic call to wake up view compilation in debug mode, we don't need to await.
} }
private async Task WaitIsFullySynched(CancellationToken cancellationToken) private async Task WaitIsFullySynched(CancellationToken cancellationToken)