diff --git a/tests/NuGet.Services.AzureSearch.Tests/IndexBuilderFacts.cs b/tests/NuGet.Services.AzureSearch.Tests/IndexBuilderFacts.cs index a50964361f..9cd8228d56 100644 --- a/tests/NuGet.Services.AzureSearch.Tests/IndexBuilderFacts.cs +++ b/tests/NuGet.Services.AzureSearch.Tests/IndexBuilderFacts.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -50,7 +50,10 @@ public async Task CanRetryOnConflict() sw.Stop(); _cloudBlobContainer.Verify(x => x.CreateAsync(true), Times.Exactly(2)); - Assert.InRange(sw.Elapsed, _retryDuration, TimeSpan.MaxValue); + + // allow for some variance in the retry duration + // 15ms due to Windows clock: https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.delay + Assert.InRange(sw.Elapsed, _retryDuration - TimeSpan.FromMilliseconds(16), TimeSpan.MaxValue); } [Fact] @@ -140,7 +143,7 @@ public BaseFacts(ITestOutputHelper output) StorageContainer = "container-name", }; _logger = output.GetLogger(); - _retryDuration = TimeSpan.FromMilliseconds(10); + _retryDuration = TimeSpan.FromMilliseconds(100); _options .Setup(x => x.Value) @@ -160,7 +163,7 @@ protected void EnableConflict() { _cloudBlobContainer .SetupSequence(x => x.CreateAsync(It.IsAny())) - .Throws(new CloudBlobConflictException(null)) + .ThrowsAsync(new CloudBlobConflictException(null)) .Returns(Task.CompletedTask); }