-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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] Track Two (Test Stability) #9188
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1956,7 +1956,7 @@ public async Task ConsumerCannotReadEventsSentToAnotherPartition() | |
|
||
var receivedEvents = new List<EventData>(); | ||
var wereEventsPublished = false; | ||
var maximumConsecutiveEmpties = 5; | ||
var maximumConsecutiveEmpties = 10; | ||
var consecutiveEmpties = 0; | ||
|
||
await foreach (var partitionEvent in consumer.ReadEventsFromPartitionAsync(partitionIds[1], EventPosition.Latest, DefaultReadOptions, cancellationSource.Token)) | ||
|
@@ -2030,7 +2030,7 @@ public async Task ConsumersInDifferentConsumerGroupsShouldAllReadEvents() | |
|
||
// Read back the events from two different consumer groups. | ||
|
||
var maximumConsecutiveEmpties = 5; | ||
var maximumConsecutiveEmpties = 10; | ||
var consecutiveEmpties = 0; | ||
var consumerReceivedEvents = new List<EventData>(); | ||
var anotherReceivedEvents = new List<EventData>(); | ||
|
@@ -2116,7 +2116,6 @@ public async Task ReadStopsWhenMaximumWaitTimeIsReached(int maximumWaitTimeInSec | |
/// </summary> | ||
/// | ||
[Test] | ||
[Ignore("Consistently failing on Linux and macOS. To be fixed with the upcoming test stabilization.")] | ||
public async Task ConsumerCannotReadWhenProxyIsInvalid() | ||
{ | ||
await using (EventHubScope scope = await EventHubScope.CreateAsync(1)) | ||
|
@@ -2140,7 +2139,7 @@ public async Task ConsumerCannotReadWhenProxyIsInvalid() | |
|
||
await using (var invalidProxyConsumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString, options)) | ||
{ | ||
var readOptions = new ReadEventOptions { MaximumWaitTime = TimeSpan.FromMilliseconds(250) }; | ||
var readOptions = new ReadEventOptions { MaximumWaitTime = null }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Behavior on Linux and macOS is different for this scenario than it is on Windows. They do not immediately terminate with a web socket exception, but continue to attempt to connect until the timeout is exhausted. The previous setting was causing the test to terminate before the timeout period. Since it is not important that the read pulls events, setting no wait time and allowing it to block until the timeout period for connections (60 seconds) expires correctly executes on all platforms. Note that the cancellation token continues to prevent stalling by allowing for twice the connection timeout, just in case. |
||
Assert.That(async () => await ReadNothingAsync(invalidProxyConsumer, partition, EventPosition.Latest, readOptions, 25), Throws.InstanceOf<WebSocketException>().Or.InstanceOf<TimeoutException>()); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1779,7 +1779,22 @@ public async Task ReadEventsAsyncRespectsWaitTimeWhenPublishingEvents() | |
|
||
Assert.That(cancellation.IsCancellationRequested, Is.False, "The iteration should have completed normally."); | ||
Assert.That(receivedEvents.Count, Is.AtLeast(events.Count + 1).And.LessThanOrEqualTo(events.Count * thresholdModifier), "There should be empty events present due to the wait time."); | ||
Assert.That(receivedEvents.Where(item => item != null), Is.EquivalentTo(events), "The received events should match the published events when empty events are removed."); | ||
Assert.That(receivedEvents.Where(item => item != null).Count(), Is.EqualTo(events.Count), "The received event count should match the published events when empty events are removed."); | ||
|
||
// Validate that each message received appeared in the source set once. | ||
|
||
var sourceEventMessages = new HashSet<string>(); | ||
|
||
foreach (var message in events.Select(item => Encoding.UTF8.GetString(item.Body.ToArray()))) | ||
{ | ||
sourceEventMessages.Add(message); | ||
} | ||
|
||
foreach (var receivedMessage in receivedEvents.Where(item => item != null).Select(item => Encoding.UTF8.GetString(item.Body.ToArray()))) | ||
{ | ||
Assert.That(sourceEventMessages.Contains(receivedMessage), $"The message: { receivedEvents } was not in the source set or has appeared more than oncesss."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to take a note and defer this in order to avoid pushing just this change. |
||
sourceEventMessages.Remove(receivedMessage); | ||
} | ||
} | ||
|
||
/// <summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to assert that? It doesn't feel like something we should worry about in this scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was previously a difficult-to-detect issue where garbage collection was kicking in and the test was failing when the run was slow. Adding this check here is mostly unnecessary other than it offers an active reference to the variable, preventing the compiler from optimizing such that it may be collected.
I had originally left a comment with some silly does-nothing property access outside of an assert, but that looked and felt odd.