Skip to content

Commit

Permalink
Increase timeout on indexer status wait (#12146)
Browse files Browse the repository at this point in the history
Also adds error handling so we don't wait the maximum timeout in case the indexing failed.
  • Loading branch information
heaths authored May 18, 2020
1 parent adf5f81 commit 915ca9c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
Expand Down Expand Up @@ -396,7 +397,7 @@ private async Task WaitForIndexingAsync(
TimeSpan? timeout = null)
{
TimeSpan delay = TimeSpan.FromSeconds(10);
timeout ??= TimeSpan.FromMinutes(1);
timeout ??= TimeSpan.FromMinutes(5);

using CancellationTokenSource cts = new CancellationTokenSource(timeout.Value);

Expand All @@ -414,6 +415,21 @@ private async Task WaitForIndexingAsync(
{
return;
}
else if (status.Status == IndexerStatus.Error && status.LastResult is IndexerExecutionResult lastResult)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Error: {lastResult.ErrorMessage}");

if (lastResult.Errors?.Count > 0)
{
foreach (SearchIndexerError error in lastResult.Errors)
{
sb.AppendLine($" ---> {error.ErrorMessage}");
}
}

Assert.Fail(sb.ToString());
}
}
}
}
Expand Down

0 comments on commit 915ca9c

Please sign in to comment.