From 620a140bf82af37148cc172f468a26a2eb29de3f Mon Sep 17 00:00:00 2001 From: Jesse Squire Date: Fri, 20 Nov 2020 20:10:03 -0500 Subject: [PATCH] [Event Hubs Client] Fix Live Test Hangs (#17132) The focus of these changes is to triage the test hangs in the live suite that seem to be related to the snippet smoke tests. This should unblock test runs while I continue to troubleshoot and locate the root cause. --- .../tests/Snippets/ReadMeSnippetsLiveTests.cs | 1 + .../tests/Snippets/Sample01_HelloWorldLiveTests.cs | 1 + .../Sample02_EventProcessorConfigurationLiveTests.cs | 1 + .../Snippets/Sample03_EventProcessorHandlersLiveTests.cs | 1 + .../tests/Snippets/Sample04_ProcessingEventsLiveTests.cs | 1 + ...ample05_IdentityAndSharedAccessCredentialsLiveTests.cs | 1 + .../Sample06_RequestingStorageServiceVersionsLiveTests.cs | 1 + .../tests/Consumer/EventHubConsumerClientLiveTests.cs | 8 ++++---- .../tests/Primitives/PartitionReceiverLiveTests.cs | 6 ++++-- .../tests/Snippets/ReadMeSnippetsLiveTests.cs | 1 + .../tests/Snippets/Sample01_HelloWorldLiveTests.cs | 1 + .../tests/Snippets/Sample02_EventHubsClientsLiveTests.cs | 1 + .../tests/Snippets/Sample03_EventHubMetadataLiveTests.cs | 1 + .../tests/Snippets/Sample04_PublishingEventsLiveTests.cs | 1 + .../tests/Snippets/Sample05_ReadingEventsLiveTests.cs | 1 + ...ample06_IdentityAndSharedAccessCredentialsLiveTests.cs | 1 + .../Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs | 1 + sdk/eventhub/tests.yml | 2 +- 18 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs index 455f40448094..d6161cba7862 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs @@ -22,6 +22,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample01_HelloWorldLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample01_HelloWorldLiveTests.cs index 588610a40810..d95fe02b8081 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample01_HelloWorldLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample01_HelloWorldLiveTests.cs @@ -22,6 +22,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample02_EventProcessorConfigurationLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample02_EventProcessorConfigurationLiveTests.cs index e8ba8409abaa..f661811b031a 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample02_EventProcessorConfigurationLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample02_EventProcessorConfigurationLiveTests.cs @@ -18,6 +18,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample03_EventProcessorHandlersLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample03_EventProcessorHandlersLiveTests.cs index 253ebd5ccf0c..33c691c594d4 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample03_EventProcessorHandlersLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample03_EventProcessorHandlersLiveTests.cs @@ -21,6 +21,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample04_ProcessingEventsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample04_ProcessingEventsLiveTests.cs index 5284073b8cc0..d6557dffa03d 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample04_ProcessingEventsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample04_ProcessingEventsLiveTests.cs @@ -24,6 +24,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample05_IdentityAndSharedAccessCredentialsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample05_IdentityAndSharedAccessCredentialsLiveTests.cs index ae90fe62e076..d946fa2761f7 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample05_IdentityAndSharedAccessCredentialsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample05_IdentityAndSharedAccessCredentialsLiveTests.cs @@ -21,6 +21,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample06_RequestingStorageServiceVersionsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample06_RequestingStorageServiceVersionsLiveTests.cs index 2fcd818c2146..9fe26e65df1f 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample06_RequestingStorageServiceVersionsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/Sample06_RequestingStorageServiceVersionsLiveTests.cs @@ -21,6 +21,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs index 86a436452860..88cc518d89ac 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs @@ -895,16 +895,16 @@ public async Task ConsumerCannotReadWhenClosed() var partition = (await consumer.GetPartitionIdsAsync(cancellationSource.Token)).First(); await SendEventsAsync(connectionString, sourceEvents, new CreateBatchOptions { PartitionId = partition }, cancellationSource.Token); - // Read the events and validate the resulting state. - // Create a local function that will close the consumer after five events have - // been read. + // been read. Because the close happens in the middle of iteration, allow for a short + // delay to ensure that the state transition has been fully captured. async Task closeAfterRead(ReadState state) { if (state.Events.Count >= 2) { - await consumer.CloseAsync(cancellationSource.Token).ConfigureAwait(false); + await consumer.CloseAsync(cancellationSource.Token); + await Task.Delay(250); } return true; diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs index faeec6a5cd49..38a2eb021660 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs @@ -874,13 +874,15 @@ public async Task ReceiverCannotReadWhenClosed() await using (var receiver = new PartitionReceiver(EventHubConsumerClient.DefaultConsumerGroupName, partition, EventPosition.Earliest, connectionString)) { // Create a local function that will close the receiver after five events have - // been read. + // been read. Because the close happens during the read loop, allow for a short + // delay to ensure that the state transition has been fully captured. async Task closeAfterFiveRead(ReadState state) { if (state.Events.Count >= 2) { - await receiver.CloseAsync(cancellationSource.Token).ConfigureAwait(false); + await receiver.CloseAsync(cancellationSource.Token); + await Task.Delay(250); } return true; diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs index a4fe12edbc35..97f1486f0226 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs @@ -20,6 +20,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs index 66ef7a2266c3..f7f8e3fa31ec 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs @@ -18,6 +18,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs index 93fde5fd7b5c..09b4456d56b4 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs @@ -18,6 +18,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs index 1f37d1d8ea1a..5a3f748267d2 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs @@ -17,6 +17,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs index cbbbf585d5b4..fd5957763476 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs @@ -17,6 +17,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs index ecf3ff2c02f2..d8d3a8c7a411 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs @@ -22,6 +22,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs index 99177d50d70e..5b7cb75d17a3 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs @@ -17,6 +17,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs index 178126114c77..3f36f741d062 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs @@ -19,6 +19,7 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets /// /// [TestFixture] + [Ignore("Debugging Potential Hang")] [Category(TestCategory.Live)] [Category(TestCategory.DisallowVisualStudioLiveUnitTesting)] [SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Example assignments needed for snippet output content.")] diff --git a/sdk/eventhub/tests.yml b/sdk/eventhub/tests.yml index e8c283f38182..20ce943c0d2a 100644 --- a/sdk/eventhub/tests.yml +++ b/sdk/eventhub/tests.yml @@ -3,7 +3,7 @@ trigger: none extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: - MaxParallel: 1 + MaxParallel: 6 ServiceDirectory: eventhub TimeoutInMinutes: 130 Clouds: 'Public,Canary'