Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search] Avoid storm of error events being logged when running test #21988

Merged
merged 10 commits into from
Jul 2, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

namespace Azure.Search.Documents.Tests
{
// Avoid running these tests in parallel with anything else that's sharing the event source
[NonParallelizable]
public class BatchingTests : SearchTestBase
{
private TestEventListener _listener;
Expand Down Expand Up @@ -452,11 +454,12 @@ public async Task KeyFieldAccessor_FieldBuilder()
{
await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync<SimpleDocument>(this);
SearchClient client = resources.GetSearchClient();

LessSimpleDocument[] data = LessSimpleDocument.GetDocuments(10);

await using SearchIndexingBufferedSender<LessSimpleDocument> indexer =
new SearchIndexingBufferedSender<LessSimpleDocument>(client);
await using SearchIndexingBufferedSender<LessSimpleDocument> indexer = new(GetOriginal(client));
AssertNoFailures(indexer);

await indexer.UploadDocumentsAsync(data);
await indexer.FlushAsync();
await WaitForDocumentCountAsync(resources.GetSearchClient(), data.Length);
Expand Down Expand Up @@ -1009,7 +1012,7 @@ public async Task Notifications_ExceptionsGetSwallowed()
{
await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync<SimpleDocument>(this);
BatchingSearchClient client = GetBatchingSearchClient(resources);
SimpleDocument[] data = SimpleDocument.GetDocuments(BatchSize);
SimpleDocument[] data = SimpleDocument.GetDocuments(2);

await using SearchIndexingBufferedSender<SimpleDocument> indexer =
client.CreateIndexingBufferedSender(
Expand Down Expand Up @@ -1149,7 +1152,6 @@ public async Task Behavior_SplitBatchByDocumentKey()
InitialBatchActionCount = numberOfDocuments + 1,
});

// Throw from every handler
int sent = 0, completed = 0;
indexer.ActionSent += e =>
{
Expand All @@ -1159,7 +1161,7 @@ public async Task Behavior_SplitBatchByDocumentKey()
// So, 3 documents will be sent before any are submitted, but 3 submissions will be made before the last 2 are sent
Assert.AreEqual((sent <= 3) ? 0 : 3, completed);

throw new InvalidOperationException("ActionSentAsync: Should not be seen!");
return Task.CompletedTask;
};

indexer.ActionCompleted += e =>
Expand All @@ -1170,7 +1172,7 @@ public async Task Behavior_SplitBatchByDocumentKey()
// So, 3 documents will be submitted after 3 are sent, and the last 2 submissions will be made after all 5 are sent
Assert.AreEqual((completed <= 3) ? 3 : 5, sent);

throw new InvalidOperationException("ActionCompletedAsync: Should not be seen!");
return Task.CompletedTask;
};

AssertNoFailures(indexer);
Expand Down Expand Up @@ -1209,7 +1211,6 @@ public async Task Behavior_SplitBatchByDocumentKeyIgnoreCaseDifferences()
InitialBatchActionCount = numberOfDocuments + 1,
});

// Throw from every handler
int sent = 0, completed = 0;
indexer.ActionSent += e =>
{
Expand All @@ -1218,7 +1219,7 @@ public async Task Behavior_SplitBatchByDocumentKeyIgnoreCaseDifferences()
// Batch will not be split. So, no document will be submitted before all are sent.
Assert.AreEqual(0, completed);

throw new InvalidOperationException("ActionSentAsync: Should not be seen!");
return Task.CompletedTask;
};

indexer.ActionCompleted += e =>
Expand All @@ -1228,7 +1229,7 @@ public async Task Behavior_SplitBatchByDocumentKeyIgnoreCaseDifferences()
// Batch will not be split. So, all documents will be sent before any are submitted.
Assert.AreEqual(5, sent);

throw new InvalidOperationException("ActionCompletedAsync: Should not be seen!");
return Task.CompletedTask;
};

AssertNoFailures(indexer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public async Task BufferedSender()

// Simple
{
searchClient = GetOriginal(searchClient);

#region Snippet:Azure_Search_Documents_Tests_Samples_Sample05_IndexingDocuments_BufferedSender1
await using SearchIndexingBufferedSender<Product> indexer =
new SearchIndexingBufferedSender<Product>(searchClient);
Expand Down
Loading