From 8b740b2502b0e5e04b9be0ad5616c8296100b93c Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Mon, 31 Aug 2020 16:34:27 -0700 Subject: [PATCH] Mark tests inconclusive if indexer status times out --- .../tests/Samples/Sample01_HelloWorld.cs | 10 +--------- .../tests/Utilities/SearchTestBase.cs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs b/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs index d5393f93f6f01..f003498fafe8b 100644 --- a/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs +++ b/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs @@ -348,15 +348,7 @@ public async Task CreateIndexerAsync() cleanUpTasks.Push(() => indexerClient.DeleteIndexerAsync(indexerName)); // Wait till the indexer is done. - try - { - await WaitForIndexingAsync(indexerClient, indexerName); - } - catch (TaskCanceledException) - { - // TODO: Remove this when we figure out a more correlative way of checking status. - Assert.Inconclusive("Timed out while waiting for the indexer to complete"); - } + await WaitForIndexingAsync(indexerClient, indexerName); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Query // Get a SearchClient from the SearchIndexClient to share its pipeline. diff --git a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchTestBase.cs b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchTestBase.cs index 0985a3d984474..a00f57979686f 100644 --- a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchTestBase.cs +++ b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchTestBase.cs @@ -199,11 +199,20 @@ protected async Task WaitForIndexingAsync( while (true) { - await DelayAsync(delay, cancellationToken: cts.Token); + SearchIndexerStatus status = null; + try + { + await DelayAsync(delay, cancellationToken: cts.Token); - SearchIndexerStatus status = await client.GetIndexerStatusAsync( - indexerName, - cancellationToken: cts.Token); + status = await client.GetIndexerStatusAsync( + indexerName, + cancellationToken: cts.Token); + } + catch (TaskCanceledException) + { + // TODO: Remove this when we figure out a more correlative way of checking status. + Assert.Inconclusive("Timed out while waiting for the indexer to complete"); + } if (status.Status == IndexerStatus.Running) {