Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Event Hubs Client] Live Test Fixes #17261

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,12 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets
/// </summary>
///
[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

{
/// <summary>The active Event Hub resource scope for the test fixture.</summary>
private EventHubScope _eventHubScope;

/// <summary>The active Blob storage resource scope for the test fixture.</summary>
private StorageScope _storageScope;

/// <summary>
/// Performs the tasks needed to initialize the test fixture. This
/// method runs once for the entire fixture, prior to running any tests.
/// </summary>
///
[OneTimeSetUp]
public async Task FixtureSetUp()
{
_eventHubScope = await EventHubScope.CreateAsync(2);
_storageScope = await StorageScope.CreateAsync();
}

/// <summary>
/// Performs the tasks needed to cleanup the test fixture after all
/// tests have run. This method runs once for the entire fixture.
/// </summary>
///
[OneTimeTearDown]
public async Task FixtureTearDown()
{
await Task.WhenAll
(
_eventHubScope.DisposeAsync().AsTask(),
_storageScope.DisposeAsync().AsTask()
);
}

/// <summary>
/// Performs basic smoke test validation of the contained snippet.
/// </summary>
Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets
/// </summary>
///
[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.")]
Expand All @@ -31,9 +30,6 @@ public class Sample01_HelloWorldLiveTests
/// <summary>The active Event Hub resource scope for the test fixture.</summary>
private EventHubScope _eventHubScope;

/// <summary>The active Blob storage resource scope for the test fixture.</summary>
private StorageScope _storageScope;

/// <summary>
/// Performs the tasks needed to initialize the test fixture. This
/// method runs once for the entire fixture, prior to running any tests.
Expand All @@ -43,7 +39,6 @@ public class Sample01_HelloWorldLiveTests
public async Task FixtureSetUp()
{
_eventHubScope = await EventHubScope.CreateAsync(2);
_storageScope = await StorageScope.CreateAsync();
}

/// <summary>
Expand All @@ -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();
}

/// <summary>
Expand Down Expand Up @@ -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 >>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,11 @@ namespace Azure.Messaging.EventHubs.Tests.Snippets
/// </summary>
///
[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
{
/// <summary>The active Event Hub resource scope for the test fixture.</summary>
private EventHubScope _eventHubScope;

/// <summary>The active Blob storage resource scope for the test fixture.</summary>
private StorageScope _storageScope;

/// <summary>
/// Performs the tasks needed to initialize the test fixture. This
/// method runs once for the entire fixture, prior to running any tests.
/// </summary>
///
[OneTimeSetUp]
public async Task FixtureSetUp()
{
_eventHubScope = await EventHubScope.CreateAsync(2);
_storageScope = await StorageScope.CreateAsync();
}

/// <summary>
/// Performs the tasks needed to cleanup the test fixture after all
/// tests have run. This method runs once for the entire fixture.
/// </summary>
///
[OneTimeTearDown]
public async Task FixtureTearDown()
{
await Task.WhenAll
(
_eventHubScope.DisposeAsync().AsTask(),
_storageScope.DisposeAsync().AsTask()
);
}

/// <summary>
/// Performs basic smoke test validation of the contained snippet.
/// </summary>
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -234,23 +200,23 @@ public void ConfigureProxyByProperty()
/// </summary>
///
[Test]
public void onfigureRetryWithFullOptions()
public void ConfigureRetryWithFullOptions()
{
#region Snippet:EventHubs_Processor_Sample02_RetryWithFullOptions

var storageConnectionString = "<< CONNECTION STRING FOR THE STORAGE ACCOUNT >>";
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
{
Expand Down Expand Up @@ -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;
Expand Down
Loading