Skip to content

Commit

Permalink
Fix SB extension tests (#27349)
Browse files Browse the repository at this point in the history
* Fix SB extension tests

* Fix

* Fix flaky tests
  • Loading branch information
JoshLove-msft authored Mar 4, 2022
1 parent 35066c4 commit 1538484
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ async Task ProcessMessage(ProcessMessageEventArgs args)
}

var initialLockedUntil = args.Message.LockedUntil;
// introduce a small delay so that the service honors the renewal request
await Task.Delay(500);
await args.RenewMessageLockAsync(args.Message);
Assert.Greater(args.Message.LockedUntil, initialLockedUntil);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ async Task ProcessMessage(ProcessSessionMessageEventArgs args)
}

var initialLockedUntil = args.SessionLockedUntil;
// introduce a small delay so that the service honors the renewal request
await Task.Delay(500);
await args.RenewSessionLockAsync();
Assert.Greater(args.SessionLockedUntil, initialLockedUntil);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ public static void Run(
DateTimeOffset[] expiresAtArray,
DateTime[] enqueuedTimeUtcArray,
DateTimeOffset[] enqueuedTimeArray,
DateTimeOffset[] lockedUntilArray,
string[] contentTypeArray,
string[] replyToArray,
string[] toArray,
Expand All @@ -1097,8 +1096,7 @@ public static void Run(
Assert.Greater(expiresAtUtcArray[i], DateTime.UtcNow);
Assert.AreEqual(expiresAtArray[i].DateTime, expiresAtUtcArray[i]);
Assert.Less(enqueuedTimeUtcArray[i], DateTime.UtcNow);
Assert.AreEqual(enqueuedTimeArray[i].DateTime, enqueuedTimeArray[i]);
Assert.Greater(lockedUntilArray[i], DateTimeOffset.UtcNow);
Assert.AreEqual(enqueuedTimeArray[i].DateTime, enqueuedTimeUtcArray[i]);
}
string[] messages = array.Select(x => x.Body.ToString()).ToArray();
ServiceBusMultipleTestJobsBase.ProcessMessages(messages);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public class DrainModeTestJobQueueBatch
public static async Task QueueWithSessionsBatch(
[ServiceBusTrigger(FirstQueueNameKey, IsSessionsEnabled = true)]
ServiceBusReceivedMessage[] array,
ServiceBusSessionMessageActions messageActions,
ServiceBusSessionMessageActions sessionActions,
CancellationToken cancellationToken,
ILogger logger)
{
Expand All @@ -710,11 +710,11 @@ public static async Task QueueWithSessionsBatch(
foreach (ServiceBusReceivedMessage msg in array)
{
// validate that manual lock renewal works
var initialLockedUntil = messageActions.SessionLockedUntil;
await messageActions.RenewSessionLockAsync();
Assert.Greater(messageActions.SessionLockedUntil, initialLockedUntil);
var initialLockedUntil = sessionActions.SessionLockedUntil;
await sessionActions.RenewSessionLockAsync();
Assert.Greater(sessionActions.SessionLockedUntil, initialLockedUntil);

await messageActions.CompleteMessageAsync(msg);
await sessionActions.CompleteMessageAsync(msg);
}

_drainValidationPostDelay.Set();
Expand Down

0 comments on commit 1538484

Please sign in to comment.