Skip to content

Commit db6ab9a

Browse files
authored
Retry flaky test and add some logging (#22953)
1 parent 3973fda commit db6ab9a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sdk/core/Azure.Core/tests/BearerTokenAuthenticationPolicyTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventA
676676
}
677677

678678
[Test]
679+
[Retry(3)] //https://github.com/Azure/azure-sdk-for-net/issues/21005
679680
public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshCancelledAndLogs()
680681
{
681682
var requestMre = new ManualResetEventSlim(true);
@@ -687,6 +688,7 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshCancelledAndL
687688
string msg = "fail to refresh";
688689
var credential = new BearerTokenAuthenticationPolicyTests.TokenCredentialStub((r, c) =>
689690
{
691+
TestContext.WriteLine($"Start TokenCredentialStub: requestCount: {requestCount}");
690692
if (Interlocked.Increment(ref requestCount) > 1)
691693
{
692694
Task.Delay(100).GetAwaiter().GetResult();
@@ -697,12 +699,14 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshCancelledAndL
697699
requestMre.Reset();
698700

699701
expires.TryDequeue(out var token);
702+
TestContext.WriteLine($"End TokenCredentialStub: callCount: {requestCount}");
700703
return new AccessToken(Guid.NewGuid().ToString(), token);
701704
},
702705
IsAsync);
703706

704707
AzureEventSourceListener listener = new((args, text) =>
705708
{
709+
TestContext.WriteLine(text);
706710
if (args.EventName == "BackgroundRefreshFailed" && text.Contains(msg))
707711
{
708712
logged = true;

0 commit comments

Comments
 (0)