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 d6161cba7862..a648e01c9681 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Snippets/ReadMeSnippetsLiveTests.cs @@ -22,46 +22,12 @@ 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.")] public class ReadMeSnippetsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -75,15 +41,15 @@ public void Create() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; BlobContainerClient storageClient = new BlobContainerClient(storageConnectionString, blobContainerName); @@ -111,15 +77,15 @@ public void ConfigureHandlers() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; async Task processEventHandler(ProcessEventArgs eventArgs) { @@ -168,6 +134,9 @@ async Task processErrorHandler(ProcessErrorEventArgs eventArgs) [Test] public async Task ProcessUntilCanceled() { + await using var eventHubScope = await EventHubScope.CreateAsync(2); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_ReadMe_ProcessUntilCanceled var cancellationSource = new CancellationTokenSource(); @@ -177,15 +146,15 @@ public async Task ProcessUntilCanceled() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); Task processEventHandler(ProcessEventArgs eventArgs) => Task.CompletedTask; Task processErrorHandler(ProcessErrorEventArgs eventArgs) => Task.CompletedTask; @@ -236,7 +205,7 @@ public void CreateWithIdentity() /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; string blobStorageUrl ="<< FULLY-QUALIFIED CONTAINER URL (like https://myaccount.blob.core.windows.net/mycontainer) >>"; - /*@@*/ blobStorageUrl = $"https://{ StorageTestEnvironment.Instance.StorageAccountName }.{ StorageTestEnvironment.Instance.StorageEndpointSuffix }/{ _storageScope.ContainerName }"; + /*@@*/ blobStorageUrl = $"https://{ StorageTestEnvironment.Instance.StorageAccountName }.{ StorageTestEnvironment.Instance.StorageEndpointSuffix }/{ "fake-container" }"; /*@@*/ BlobContainerClient storageClient = new BlobContainerClient(new Uri(blobStorageUrl), credential); @@ -245,8 +214,8 @@ public void CreateWithIdentity() var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; EventProcessorClient processor = new EventProcessorClient ( 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 d95fe02b8081..208698d01d1e 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,7 +22,6 @@ 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.")] @@ -31,9 +30,6 @@ public class Sample01_HelloWorldLiveTests /// The active Event Hub resource scope for the test fixture. private EventHubScope _eventHubScope; - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - /// /// Performs the tasks needed to initialize the test fixture. This /// method runs once for the entire fixture, prior to running any tests. @@ -43,7 +39,6 @@ public class Sample01_HelloWorldLiveTests public async Task FixtureSetUp() { _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); } /// @@ -54,11 +49,7 @@ public async Task FixtureSetUp() [OneTimeTearDown] public async Task FixtureTearDown() { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); + await _eventHubScope.DisposeAsync(); } /// @@ -129,13 +120,15 @@ public async Task PublishEvents() [Test] public async Task ProcessEvents() { + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample01_ProcessEvents var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; 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 f661811b031a..f0c357f1958d 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,45 +18,11 @@ 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.")] public class Sample02_EventProcessorConfigurationLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -70,15 +36,15 @@ public void ConfigureTransportWithFullOptions() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions { @@ -115,15 +81,15 @@ public void ConfigureTransportByProperty() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions(); processorOptions.ConnectionOptions.TransportType = EventHubsTransportType.AmqpWebSockets; @@ -155,15 +121,15 @@ public void ConfigureProxyWithFullOptions() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions { @@ -201,15 +167,15 @@ public void ConfigureProxyByProperty() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions(); processorOptions.ConnectionOptions.TransportType = EventHubsTransportType.AmqpWebSockets; @@ -234,7 +200,7 @@ public void ConfigureProxyByProperty() /// /// [Test] - public void onfigureRetryWithFullOptions() + public void ConfigureRetryWithFullOptions() { #region Snippet:EventHubs_Processor_Sample02_RetryWithFullOptions @@ -242,15 +208,15 @@ public void onfigureRetryWithFullOptions() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions { @@ -290,15 +256,15 @@ public void ConfigureRetryByProperty() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var processorOptions = new EventProcessorClientOptions(); processorOptions.RetryOptions.Mode = EventHubsRetryMode.Fixed; 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 33c691c594d4..d54080763619 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,45 +21,11 @@ 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.")] public class Sample03_EventProcessorHandlersLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -73,15 +39,15 @@ public void EventHandlerExceptionHandling() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, @@ -137,15 +103,15 @@ public void EventHandlerCancellation() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, @@ -200,21 +166,24 @@ Task processEventHandler(ProcessEventArgs args) [Test] public async Task EventHandlerStopOnException() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample03_EventHandlerStopOnException var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -312,15 +281,15 @@ public void ErrorHandlerExceptionHandling() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, @@ -377,15 +346,15 @@ public void ErrorHandlerArgs() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, @@ -444,21 +413,24 @@ Task processErrorHandler(ProcessErrorEventArgs args) [Test] public async Task ErrorHandlerCancellationRecovery() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample03_ErrorHandlerCancellationRecovery var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -590,15 +562,15 @@ public void InitializeHandlerArgs() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, @@ -667,15 +639,15 @@ public void CloseHandlerArgs() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = "not-real"; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = "fakeHub"; + /*@@*/ consumerGroup = "fakeConsumer"; var storageClient = new BlobContainerClient( storageConnectionString, 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 d6557dffa03d..35364bb1f97f 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 @@ -2,19 +2,18 @@ // Licensed under the MIT License. using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Azure.Messaging.EventHubs.Consumer; using Azure.Messaging.EventHubs.Processor; using Azure.Messaging.EventHubs.Processor.Tests; using Azure.Storage.Blobs; using NUnit.Framework; -using System.Diagnostics; -using Azure.Messaging.EventHubs.Consumer; -using Azure.Messaging.EventHubs.Primitives; -using System.Collections.Concurrent; -using System.Collections.Generic; namespace Azure.Messaging.EventHubs.Tests.Snippets { @@ -24,45 +23,11 @@ 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.")] public class Sample04_ProcessingEventsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -70,21 +35,24 @@ await Task.WhenAll [Test] public async Task BasicEventProcessing() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample04_BasicEventProcessing var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -206,21 +174,24 @@ Task processErrorHandler(ProcessErrorEventArgs args) [Test] public async Task CheckpointByEventCount() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample04_CheckpointByEventCount var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -323,21 +294,24 @@ await Application.ProcessEventAsync( [Test] public async Task InitializePartition() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample04_InitializePartition var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -431,21 +405,24 @@ Task initializeEventHandler(PartitionInitializingEventArgs args) [Test] public async Task ProcessByBatch() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample04_ProcessByBatch var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, @@ -552,21 +529,24 @@ await Application.ProcessEventBatchAsync( [Test] public async Task ProcessWithHeartbeat() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample04_ProcessWithHeartbeat var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClient = new BlobContainerClient( storageConnectionString, 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 d946fa2761f7..8d77d951b887 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,45 +21,11 @@ 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.")] public class Sample05_IdentityAndSharedAccessCredentialsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -67,6 +33,9 @@ await Task.WhenAll [Test] public async Task DefaultAzureCredential() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample05_DefaultAzureCredential TokenCredential credential = new DefaultAzureCredential(); @@ -75,15 +44,15 @@ public async Task DefaultAzureCredential() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageEndpoint = new BlobServiceClient(StorageTestEnvironment.Instance.StorageConnectionString).Uri.ToString(); - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var fullyQualifiedNamespace = "<< NAMESPACE (likely similar to {your-namespace}.servicebus.windows.net) >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; var blobUriBuilder = new BlobUriBuilder(new Uri(storageEndpoint)); @@ -155,6 +124,9 @@ public async Task DefaultAzureCredential() [Test] public async Task ConnectionStringParse() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample05_ConnectionStringParse TokenCredential credential = new DefaultAzureCredential(); @@ -163,15 +135,15 @@ public async Task ConnectionStringParse() var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; var storageEndpoint = new BlobServiceClient(storageConnectionString).Uri; 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 9fe26e65df1f..3b89d7c763e6 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,45 +21,11 @@ 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.")] public class Sample06_RequestingStorageServiceVersionsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _eventHubScope; - - /// The active Blob storage resource scope for the test fixture. - private StorageScope _storageScope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _eventHubScope = await EventHubScope.CreateAsync(2); - _storageScope = await StorageScope.CreateAsync(); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await Task.WhenAll - ( - _eventHubScope.DisposeAsync().AsTask(), - _storageScope.DisposeAsync().AsTask() - ); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -67,21 +33,24 @@ await Task.WhenAll [Test] public async Task ProcessEvents() { + await using var eventHubScope = await EventHubScope.CreateAsync(1); + await using var storageScope = await StorageScope.CreateAsync(); + #region Snippet:EventHubs_Processor_Sample06_ChooseStorageVersion var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>"; var blobContainerName = "<< NAME OF THE BLOB CONTAINER >>"; /*@@*/ /*@@*/ storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; - /*@@*/ blobContainerName = _storageScope.ContainerName; + /*@@*/ blobContainerName = storageScope.ContainerName; var eventHubsConnectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; var consumerGroup = "<< NAME OF THE EVENT HUB CONSUMER GROUP >>"; /*@@*/ /*@@*/ eventHubsConnectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _eventHubScope.EventHubName; - /*@@*/ consumerGroup = _eventHubScope.ConsumerGroups.First(); + /*@@*/ eventHubName = eventHubScope.EventHubName; + /*@@*/ consumerGroup = eventHubScope.ConsumerGroups.First(); var storageClientOptions = new BlobClientOptions(); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs index 88cc518d89ac..edaac5b12bd8 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Consumer/EventHubConsumerClientLiveTests.cs @@ -396,7 +396,6 @@ public async Task ConsumerCanReadEventsWithPrefetchDisabled() } } - /// /// Verifies that the is able to /// connect to the Event Hubs service and perform operations. @@ -801,7 +800,7 @@ public async Task ConsumerCanReadFromMultipleConsumerGroups() cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - var sourceEvents = EventGenerator.CreateEvents(50).ToList(); + var sourceEvents = EventGenerator.CreateEvents(100).ToList(); await using (var customConsumer = new EventHubConsumerClient(customConsumerGroup, connectionString)) await using (var defaultConsumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString)) @@ -848,7 +847,7 @@ public async Task ConsumerCannotReadAcrossPartitions() cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); var credential = EventHubsTestEnvironment.Instance.Credential; - var sourceEvents = EventGenerator.CreateEvents(50).ToList(); + var sourceEvents = EventGenerator.CreateEvents(100).ToList(); await using (var consumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, EventHubsTestEnvironment.Instance.FullyQualifiedNamespace, scope.EventHubName, credential)) { @@ -888,7 +887,7 @@ public async Task ConsumerCannotReadWhenClosed() cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - var sourceEvents = EventGenerator.CreateEvents(25).ToList(); + var sourceEvents = EventGenerator.CreateEvents(250).ToList(); await using (var consumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString)) { @@ -904,7 +903,7 @@ async Task closeAfterRead(ReadState state) if (state.Events.Count >= 2) { await consumer.CloseAsync(cancellationSource.Token); - await Task.Delay(250); + await Task.Yield(); } 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 38a2eb021660..1c1cb7d37181 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/PartitionReceiverLiveTests.cs @@ -826,7 +826,7 @@ public async Task ReceiverCannotReadAcrossPartitions() var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); var credential = EventHubsTestEnvironment.Instance.Credential; - var sourceEvents = EventGenerator.CreateEvents(50).ToList(); + var sourceEvents = EventGenerator.CreateEvents(100).ToList(); // Send events to the second partition, which should not be visible to the receiver. @@ -866,7 +866,7 @@ public async Task ReceiverCannotReadWhenClosed() cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - var sourceEvents = EventGenerator.CreateEvents(25).ToList(); + var sourceEvents = EventGenerator.CreateEvents(250).ToList(); var partition = (await QueryPartitionsAsync(connectionString, cancellationSource.Token)).First(); await SendEventsAsync(connectionString, sourceEvents, new CreateBatchOptions { PartitionId = partition }, cancellationSource.Token); @@ -882,7 +882,7 @@ async Task closeAfterFiveRead(ReadState state) if (state.Events.Count >= 2) { await receiver.CloseAsync(cancellationSource.Token); - await Task.Delay(250); + await Task.Yield(); } 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 97f1486f0226..86241b9db647 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/ReadMeSnippetsLiveTests.cs @@ -20,38 +20,12 @@ 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.")] public class ReadMeSnippetsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -59,13 +33,15 @@ public async Task FixtureTearDown() [Test] public async Task Inspect() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_ReadMe_Inspect var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; await using (var producer = new EventHubProducerClient(connectionString, eventHubName)) { @@ -82,13 +58,15 @@ public async Task Inspect() [Test] public async Task Publish() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_ReadMe_Publish var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; await using (var producer = new EventHubProducerClient(connectionString, eventHubName)) { @@ -109,6 +87,8 @@ public async Task Publish() [Test] public async Task Read() { + await using var scope = await EventHubScope.CreateAsync(1); + try { #region Snippet:EventHubs_ReadMe_Read @@ -117,7 +97,7 @@ public async Task Read() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; string consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; @@ -150,6 +130,8 @@ public async Task Read() [Test] public async Task ReadPartition() { + await using var scope = await EventHubScope.CreateAsync(1); + try { #region Snippet:EventHubs_ReadMe_ReadPartition @@ -158,7 +140,7 @@ public async Task ReadPartition() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; string consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; @@ -194,6 +176,8 @@ public async Task ReadPartition() [Test] public async Task PublishIdentity() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_ReadMe_PublishIdentity TokenCredential credential = new DefaultAzureCredential(); @@ -203,7 +187,7 @@ public async Task PublishIdentity() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; await using (var producer = new EventHubProducerClient(fullyQualifiedNamespace, eventHubName, credential)) { 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 f7f8e3fa31ec..ea566074b427 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample01_HelloWorldLiveTests.cs @@ -18,37 +18,11 @@ 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.")] public class Sample01_HelloWorldLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -56,8 +30,10 @@ public async Task FixtureTearDown() [Test] public async Task CreateClients() { + await using var scope = await EventHubScope.CreateAsync(1); + var connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - var eventHubName = _scope.EventHubName; + var eventHubName = scope.EventHubName; var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; #region Snippet:EventHubs_Sample01_CreateClients @@ -81,9 +57,10 @@ public async Task CreateClients() [Test] public async Task PublishEvents() { - var connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - var eventHubName = _scope.EventHubName; + await using var scope = await EventHubScope.CreateAsync(1); + var connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; + var eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); #region Snippet:EventHubs_Sample01_PublishEvents @@ -139,9 +116,10 @@ public async Task PublishEvents() [Test] public async Task ReadEvents() { - var connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - var eventHubName = _scope.EventHubName; + await using var scope = await EventHubScope.CreateAsync(1); + var connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; + var eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString, eventHubName); #region Snippet:EventHubs_Sample01_ReadEvents 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 09b4456d56b4..f15c1b35ee1e 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample02_EventHubsClientsLiveTests.cs @@ -18,37 +18,11 @@ 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.")] public class Sample02_EventHubsClientsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -56,13 +30,15 @@ public async Task FixtureTearDown() [Test] public async Task ConfigureProducerTransportWithFullOptions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ProducerTransportFullConnectionOptions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producerOptions = new EventHubProducerClientOptions { @@ -92,13 +68,15 @@ public async Task ConfigureProducerTransportWithFullOptions() [Test] public async Task ConfigureProducerTransportByProperty() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ProducerTransportProperty var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producerOptions = new EventHubProducerClientOptions(); producerOptions.ConnectionOptions.TransportType = EventHubsTransportType.AmqpWebSockets; @@ -123,13 +101,15 @@ public async Task ConfigureProducerTransportByProperty() [Test] public async Task ConfigureProducerProxyWithFullOptions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ProducerProxyFullConnectionOptions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producerOptions = new EventHubProducerClientOptions { @@ -160,13 +140,15 @@ public async Task ConfigureProducerProxyWithFullOptions() [Test] public async Task ConfigureProducerProxyByProperty() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ProducerProxyProperty var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producerOptions = new EventHubProducerClientOptions(); producerOptions.ConnectionOptions.TransportType = EventHubsTransportType.AmqpWebSockets; @@ -192,6 +174,8 @@ public async Task ConfigureProducerProxyByProperty() [Test] public async Task ConfigureConsumerRetryWithFullOptions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ConsumerRetryWithFullOptions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -199,7 +183,7 @@ public async Task ConfigureConsumerRetryWithFullOptions() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var consumerOptions = new EventHubConsumerClientOptions { @@ -233,6 +217,8 @@ public async Task ConfigureConsumerRetryWithFullOptions() [Test] public async Task ConfigureConsumerRetryByProperty() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample02_ConsumerRetryByProperty var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -240,7 +226,7 @@ public async Task ConfigureConsumerRetryByProperty() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var consumerOptions = new EventHubConsumerClientOptions(); consumerOptions.RetryOptions.Mode = EventHubsRetryMode.Fixed; 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 5a3f748267d2..84ec316e3896 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample03_EventHubMetadataLiveTests.cs @@ -17,37 +17,11 @@ 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.")] public class Sample03_EventHubMetadataLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -55,13 +29,15 @@ public async Task FixtureTearDown() [Test] public async Task InspectHub() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample03_InspectHub var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -89,13 +65,15 @@ public async Task InspectHub() [Test] public async Task QueryPartitions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample03_QueryPartitions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -119,6 +97,8 @@ public async Task QueryPartitions() [Test] public async Task InspectPartition() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample03_InspectPartition var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -126,7 +106,7 @@ public async Task InspectPartition() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName); 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 fd5957763476..f41c6ca023ec 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample04_PublishingEventsLiveTests.cs @@ -17,37 +17,11 @@ 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.")] public class Sample04_PublishingEventsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -55,13 +29,15 @@ public async Task FixtureTearDown() [Test] public async Task EventBatch() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_EventBatch var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -92,13 +68,15 @@ public async Task EventBatch() [Test] public async Task AutomaticRouting() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_AutomaticRouting var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -134,13 +112,15 @@ public async Task AutomaticRouting() [Test] public async Task PartitionKey() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_PartitionKey var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -181,13 +161,15 @@ public async Task PartitionKey() [Test] public async Task PartitionId() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_PartitionId var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -230,13 +212,15 @@ public async Task PartitionId() [Test] public async Task CustomMetadata() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_CustomMetadata var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -283,13 +267,15 @@ public async Task CustomMetadata() [Test] public async Task NoBatch() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_NoBatch var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -322,13 +308,15 @@ public async Task NoBatch() [Test] public async Task MultipleBatches() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_MultipleBatches var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; /*@@*/ /*@@*/ var sentEventCount = 0; /*@@*/ var batchEventCount = 0; @@ -375,13 +363,15 @@ public async Task MultipleBatches() [Test] public async Task CustomBatchSize() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample04_CustomBatchSize var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); 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 d8d3a8c7a411..0629d7530bcf 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample05_ReadingEventsLiveTests.cs @@ -22,77 +22,11 @@ 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.")] public class Sample05_ReadingEventsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// The set of available consumer groups for tests to use. - private Queue _availableConsumerGroups = new Queue(); - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - // Create a set of consumer groups to ensure that there aren't too - // many concurrent readers when tests are executed concurrently. - - var testCount = GetType() - .GetMethods(BindingFlags.Public | BindingFlags.Instance) - .Where(method => method.GetCustomAttribute(typeof(TestAttribute)) != null) - .Count(); - - var readersPerGroup = 5; - var consumerGroupCount = Math.Ceiling((double)testCount / readersPerGroup); - var consumerGroups = Enumerable.Range(0, (int)consumerGroupCount).Select(index => $"group{ index }"); - - foreach (var group in consumerGroups) - { - for (var index = 0; index < readersPerGroup; ++index) - { - _availableConsumerGroups.Enqueue(group); - } - } - - _scope = await EventHubScope.CreateAsync(2, consumerGroups); - - // Because some snippets assume events are present in the first partition, publish - // a small set to satisfy the assumption. - - using var cancellationSource = new CancellationTokenSource(); - cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit); - - await using var producer = new EventHubProducerClient(EventHubsTestEnvironment.Instance.EventHubsConnectionString, _scope.EventHubName); - - var toPublish = Enumerable - .Range(0, 5) - .Select(index => new EventData(new BinaryData($"Event: { index }"))); - - var partition = (await producer.GetPartitionIdsAsync(cancellationSource.Token)).First(); - var options = new SendEventOptions { PartitionId = partition }; - - await producer.SendAsync(toPublish, options); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -100,6 +34,8 @@ public async Task FixtureTearDown() [Test] public async Task ReadAllPartitions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadAllPartitions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -107,8 +43,7 @@ public async Task ReadAllPartitions() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -157,6 +92,8 @@ public async Task ReadAllPartitions() [Test] public async Task ReadAllPartitionsWaitTime() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadAllPartitionsWaitTime var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -164,8 +101,7 @@ public async Task ReadAllPartitionsWaitTime() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -219,6 +155,8 @@ public async Task ReadAllPartitionsWaitTime() [Test] public async Task ReadAllPartitionsFromLatest() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadAllPartitionsFromLatest var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -226,8 +164,7 @@ public async Task ReadAllPartitionsFromLatest() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -269,6 +206,8 @@ public async Task ReadAllPartitionsFromLatest() [Test] public async Task ReadPartition() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartition var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -276,8 +215,7 @@ public async Task ReadPartition() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -323,6 +261,8 @@ public async Task ReadPartition() [Test] public async Task ReadPartitionWaitTime() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionWaitTime var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -330,8 +270,7 @@ public async Task ReadPartitionWaitTime() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -399,6 +338,8 @@ public async Task ReadPartitionWaitTime() [Test] public async Task ReadPartitionFromDate() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionFromDate var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -406,8 +347,7 @@ public async Task ReadPartitionFromDate() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -455,6 +395,8 @@ public async Task ReadPartitionFromDate() [Test] public async Task ReadPartitionFromOffset() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionFromOffset var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -462,8 +404,7 @@ public async Task ReadPartitionFromOffset() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -510,6 +451,8 @@ public async Task ReadPartitionFromOffset() [Test] public async Task ReadPartitionFromSequence() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionFromSequence var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -517,8 +460,7 @@ public async Task ReadPartitionFromSequence() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -565,6 +507,8 @@ public async Task ReadPartitionFromSequence() [Test] public async Task ReadPartitionTrackLastEnqueued() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionTrackLastEnqueued var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -572,8 +516,7 @@ public async Task ReadPartitionTrackLastEnqueued() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, @@ -629,6 +572,8 @@ public async Task ReadPartitionTrackLastEnqueued() [Test] public async Task ReadPartitionWithReceiver() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample05_ReadPartitionWithReceiver var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -636,8 +581,7 @@ public async Task ReadPartitionWithReceiver() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; - /*@@*/ consumerGroup = _availableConsumerGroups.Dequeue(); + /*@@*/ eventHubName = scope.EventHubName; using CancellationTokenSource cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(TimeSpan.FromSeconds(30)); 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 5b7cb75d17a3..7708642f8c8e 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample06_IdentityAndSharedAccessCredentialsLiveTests.cs @@ -17,37 +17,11 @@ 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.")] public class Sample06_IdentityAndSharedAccessCredentialsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -55,6 +29,8 @@ public async Task FixtureTearDown() [Test] public async Task DefaultAzureCredential() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample06_DefaultAzureCredential TokenCredential credential = new DefaultAzureCredential(); @@ -63,7 +39,7 @@ public async Task DefaultAzureCredential() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; var producer = new EventHubProducerClient(fullyQualifiedNamespace, eventHubName, credential); @@ -100,6 +76,8 @@ public async Task DefaultAzureCredential() [Test] public async Task SharedAccessSignature() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample06_SharedAccessSignature TokenCredential credential = new DefaultAzureCredential(); @@ -108,7 +86,7 @@ public async Task SharedAccessSignature() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; var producer = new EventHubProducerClient(fullyQualifiedNamespace, eventHubName, credential); @@ -145,6 +123,8 @@ public async Task SharedAccessSignature() [Test] public async Task SharedAccessKey() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample06_SharedAccessKey TokenCredential credential = new DefaultAzureCredential(); @@ -153,7 +133,7 @@ public async Task SharedAccessKey() var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ fullyQualifiedNamespace = EventHubsTestEnvironment.Instance.FullyQualifiedNamespace; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; /*@@*/ credential = EventHubsTestEnvironment.Instance.Credential; var producer = new EventHubProducerClient(fullyQualifiedNamespace, eventHubName, credential); @@ -190,13 +170,15 @@ public async Task SharedAccessKey() [Test] public async Task ConnectionStringParse() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample06_ConnectionStringParse var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; EventHubsConnectionStringProperties properties = EventHubsConnectionStringProperties.Parse(connectionString); 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 3f36f741d062..418670fb1dc4 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Snippets/Sample07_EarlierLanguageVersionsLiveTests.cs @@ -19,37 +19,11 @@ 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.")] public class Sample07_EarlierLanguageVersionsLiveTests { - /// The active Event Hub resource scope for the test fixture. - private EventHubScope _scope; - - /// - /// Performs the tasks needed to initialize the test fixture. This - /// method runs once for the entire fixture, prior to running any tests. - /// - /// - [OneTimeSetUp] - public async Task FixtureSetUp() - { - _scope = await EventHubScope.CreateAsync(2); - } - - /// - /// Performs the tasks needed to cleanup the test fixture after all - /// tests have run. This method runs once for the entire fixture. - /// - /// - [OneTimeTearDown] - public async Task FixtureTearDown() - { - await _scope.DisposeAsync(); - } - /// /// Performs basic smoke test validation of the contained snippet. /// @@ -57,13 +31,15 @@ public async Task FixtureTearDown() [Test] public async Task Publish() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample07_Publish var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; var eventHubName = "<< NAME OF THE EVENT HUB >>"; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var producer = new EventHubProducerClient(connectionString, eventHubName); @@ -95,6 +71,8 @@ public async Task Publish() [Test] public async Task ReadAllPartitions() { + await using var scope = await EventHubScope.CreateAsync(1); + #region Snippet:EventHubs_Sample07_ReadAllPartitions var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>"; @@ -102,7 +80,7 @@ public async Task ReadAllPartitions() var consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; /*@@*/ /*@@*/ connectionString = EventHubsTestEnvironment.Instance.EventHubsConnectionString; - /*@@*/ eventHubName = _scope.EventHubName; + /*@@*/ eventHubName = scope.EventHubName; var consumer = new EventHubConsumerClient( consumerGroup, diff --git a/sdk/eventhub/tests.yml b/sdk/eventhub/tests.yml index 20ce943c0d2a..bf1846592406 100644 --- a/sdk/eventhub/tests.yml +++ b/sdk/eventhub/tests.yml @@ -5,5 +5,5 @@ extends: parameters: MaxParallel: 6 ServiceDirectory: eventhub - TimeoutInMinutes: 130 + TimeoutInMinutes: 190 Clouds: 'Public,Canary'