Skip to content

Commit 8a338eb

Browse files
authored
[Event Hubs Client] Misc. Formatting and Test Tweaks (#11648)
The focus of these changes is to make a miscellaneous set of small tweaks and fixes, largely focused on formatting and tests.
1 parent da8f4d0 commit 8a338eb

26 files changed

+194
-168
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/CheckpointStore/BlobsCheckpointStoreLiveTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Azure.Messaging.EventHubs.Primitives;
1111
using Azure.Messaging.EventHubs.Tests;
1212
using Azure.Storage.Blobs;
13-
using Moq;
1413
using NUnit.Framework;
1514

1615
namespace Azure.Messaging.EventHubs.Processor.Tests

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/CheckpointStore/BlobsCheckpointStoreTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Azure.Messaging.EventHubs.Core;
1212
using Azure.Messaging.EventHubs.Primitives;
1313
using Azure.Messaging.EventHubs.Processor.Diagnostics;
14+
using Azure.Messaging.EventHubs.Tests;
1415
using Azure.Storage;
1516
using Azure.Storage.Blobs;
1617
using Azure.Storage.Blobs.Models;
@@ -119,7 +120,6 @@ public void ListOwnershipLogsErrorOnException()
119120
target.Logger = mockLog.Object;
120121

121122
Assert.That(async () => await target.ListOwnershipAsync(FullyQualifiedNamespace, EventHubName, ConsumerGroup, new CancellationToken()), Throws.InstanceOf<RequestFailedException>());
122-
123123
mockLog.Verify(m => m.ListOwnershipError(FullyQualifiedNamespace, EventHubName, ConsumerGroup, ex.Message));
124124
}
125125

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Diagnostics/DiagnosticsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class DiagnosticsTests
4444
public async Task UpdateCheckpointAsyncCreatesScope()
4545
{
4646
using var cancellationSource = new CancellationTokenSource();
47-
cancellationSource.CancelAfter(TimeSpan.FromSeconds(15));
47+
cancellationSource.CancelAfter(TimeSpan.FromSeconds(30));
4848

4949
var completionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
5050
var mockContext = new Mock<PartitionContext>("65");

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Infrastructure/StorageTestEnvironment.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@ namespace Azure.Messaging.EventHubs.Processor.Tests
1515
///
1616
public class StorageTestEnvironment: TestEnvironment
1717
{
18-
public StorageTestEnvironment() : base("eventhubs")
19-
{
20-
ActiveStorageAccount = new Lazy<StorageProperties>(EnsureStorageAccount, LazyThreadSafetyMode.ExecutionAndPublication);
21-
}
18+
/// <summary>The singleton instance of the <see cref="StorageTestEnvironment" />, lazily created.</summary>
19+
private static readonly Lazy<StorageTestEnvironment> Singleton = new Lazy<StorageTestEnvironment>(() => new StorageTestEnvironment(), LazyThreadSafetyMode.ExecutionAndPublication);
20+
21+
/// <summary>The active Azure storage connection for this test run, lazily created.</summary>
22+
private readonly Lazy<StorageProperties> ActiveStorageAccount;
2223

2324
/// <summary>
24-
/// A shared instance of <see cref="StorageTestEnvironment"/>.
25+
/// The shared instance of the <see cref="StorageTestEnvironment"/> to be used during test runs.
2526
/// </summary>
26-
public static StorageTestEnvironment Instance { get; } = new StorageTestEnvironment();
27+
///
28+
public static StorageTestEnvironment Instance => Singleton.Value;
2729

2830
/// <summary>The environment variable value for the storage account connection string, lazily evaluated.</summary>
2931
private string StorageAccountConnectionString => GetOptionalVariable("EVENT_PROCESSOR_STORAGE_CONNECTION_STRING");
3032

31-
/// <summary>The active Azure storage connection for this test run, lazily created.</summary>
32-
private readonly Lazy<StorageProperties> ActiveStorageAccount;
33-
3433
/// <summary>
3534
/// Indicates whether or not an ephemeral storage account was created for the current test execution.
3635
/// </summary>
@@ -55,6 +54,15 @@ public StorageTestEnvironment() : base("eventhubs")
5554
///
5655
public string StorageConnectionString => ActiveStorageAccount.Value.ConnectionString;
5756

57+
/// <summary>
58+
/// Initializes a new instance of the <see cref="StorageTestEnvironment"/> class.
59+
/// </summary>
60+
///
61+
public StorageTestEnvironment() : base("eventhubs")
62+
{
63+
ActiveStorageAccount = new Lazy<StorageProperties>(EnsureStorageAccount, LazyThreadSafetyMode.ExecutionAndPublication);
64+
}
65+
5866
/// <summary>
5967
/// It tries to read the <see cref="StorageAccountConnectionString" />.
6068
/// If not found, it creates a new storage account on Azure.

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientLiveTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;
77
using System.Linq;
8-
using System.Text;
98
using System.Threading;
109
using System.Threading.Tasks;
1110
using Azure.Core;
12-
using Azure.Identity;
1311
using Azure.Messaging.EventHubs.Consumer;
1412
using Azure.Messaging.EventHubs.Primitives;
1513
using Azure.Messaging.EventHubs.Processor;
16-
using Azure.Messaging.EventHubs.Processor.Tests;
1714
using Azure.Messaging.EventHubs.Producer;
18-
using Azure.Storage.Blobs;
1915
using Moq;
20-
using Moq.Protected;
2116
using NUnit.Framework;
2217

2318
namespace Azure.Messaging.EventHubs.Tests
@@ -150,7 +145,7 @@ public async Task EventsCanBeReadByMultipleProcessorClients()
150145
var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName);
151146

152147
using var cancellationSource = new CancellationTokenSource();
153-
cancellationSource.CancelAfter(TimeSpan.FromMinutes(6));
148+
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
154149

155150
// Send a set of events.
156151

@@ -217,7 +212,7 @@ public async Task ProcessorClientCreatesOwnership()
217212
var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName);
218213

219214
using var cancellationSource = new CancellationTokenSource();
220-
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
215+
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
221216

222217
// Discover the partitions.
223218

@@ -282,7 +277,7 @@ public async Task ProcessorClientCanStartFromAnInitialPosition()
282277
var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName);
283278

284279
using var cancellationSource = new CancellationTokenSource();
285-
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
280+
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
286281

287282
// Send a set of events.
288283

@@ -363,7 +358,7 @@ public async Task ProcessorClientBeginsWithTheNextEventAfterCheckpointing()
363358
var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName);
364359

365360
using var cancellationSource = new CancellationTokenSource();
366-
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
361+
cancellationSource.CancelAfter(EventHubsTestEnvironment.Instance.TestExecutionTimeLimit);
367362

368363
// Send a set of events.
369364

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientOptionsTests.cs

100644100755
File mode changed.

0 commit comments

Comments
 (0)