Skip to content

Commit

Permalink
Fix some sporadically failing Search tests (#15942)
Browse files Browse the repository at this point in the history
* Increase timeout for Cancels_OnlySlow test

Fixes #15936

* Add delay before checking doc count again

Timing of replicas can impact document counts in a cluster. This delay on a free SKU should help according to @brjohnstmsft. We could also upgrade to a basic SKU, but there'll be additional costs, availability, and provisioning time associated.
  • Loading branch information
heaths authored Oct 13, 2020
1 parent 52d17f8 commit 14a2fc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ await Task.WhenAll(
public async Task Cancels_OnlySlow()
{
TestHandler first = new TestHandler() { Delay = TimeSpan.FromMilliseconds(20) };
TestHandler second = new TestHandler() { Delay = TimeSpan.FromMilliseconds(200) };
TestHandler third = new TestHandler() { Delay = TimeSpan.FromMilliseconds(200) };
TestHandler second = new TestHandler() { Delay = TimeSpan.FromMilliseconds(500) };
TestHandler third = new TestHandler() { Delay = TimeSpan.FromMilliseconds(500) };
CancellationTokenSource cancellation = new CancellationTokenSource();

Func<EventArgs, CancellationToken, Task> handler = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ public async Task SimpleIndexing()

await WaitForDocumentCountAsync(searchClient, 1000);

// When using the free SKU, there may be enough load to prevent
// immediately replication to all replicas and we get back the
// wrong count. Wait another second before checking again. We
// may also upgrade to a basic SKU, but that will take longer
// to provision.
await DelayAsync(TimeSpan.FromSeconds(1));

// Check
#region Snippet:Azure_Search_Documents_Tests_Samples_Sample05_IndexingDocuments_SimpleIndexing2
Assert.AreEqual(1000, (int)await searchClient.GetDocumentCountAsync());
Expand Down

0 comments on commit 14a2fc9

Please sign in to comment.