-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/8.0] [tests] Use ResiliencePipeline in IntegrationTests (#3623)
* [tests] Use ResiliencePipeline in IntegrationTests .. with a policy to retry with 1 sec delays, and a total timeout of 90 secs on the service side. The test(client) side has an overall http request timeout for 120 secs which would allow the real errors from the service to get surfaced to the client. * address review feedback from @ eerhardt * Use the pipeline for MySql also * IntegrationServiceFixture.DumpComponentLogsAsync: error out if more than one resource is given * Rename TestUtils -> ResilienceUtils - feedback from @ eerhardt * [tests] Ignore `CA1305` for tests https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1305 ``` dotnet_diagnostic.CA1305.severity = none ``` Addresses review feedback from @ eerhardt . * Remove Polly reference * Make code consistent. * add comment addressing review feedback from @ eerhardt --------- Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
- Loading branch information
1 parent
b1dd348
commit 2f7c0c2
Showing
10 changed files
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/testproject/TestProject.IntegrationServiceA/ResilienceUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Polly; | ||
using Polly.Retry; | ||
|
||
namespace Aspire.TestProject; | ||
|
||
public static class ResilienceUtils | ||
{ | ||
public static ResiliencePipelineBuilder GetDefaultResiliencePipelineBuilder<TException>(Func<OnRetryArguments<object>, ValueTask> onRetry, int overallTimeoutSecs = 90) where TException : Exception | ||
{ | ||
// Retry for upto 20 times with delay of 1 sec between | ||
// attempts, and also stop before an overall timeout of | ||
// @overallTimeoutSecs | ||
var optionsOnRetry = new RetryStrategyOptions | ||
{ | ||
MaxRetryAttempts = 20, | ||
ShouldHandle = new PredicateBuilder().Handle<TException>(), | ||
Delay = TimeSpan.FromSeconds(1), | ||
OnRetry = onRetry | ||
}; | ||
return new ResiliencePipelineBuilder() | ||
.AddTimeout(TimeSpan.FromSeconds(overallTimeoutSecs)) | ||
.AddRetry(optionsOnRetry); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters