-
Notifications
You must be signed in to change notification settings - Fork 927
Update the default retry strategy to standard from legacy #6294
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
Open
joviegas
wants to merge
8
commits into
master
Choose a base branch
from
joviegas/standard_rerty_default
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+139
−25
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
444d09e
Update the default retry strategy to standard from legacy
joviegas cab48fa
Junits updated after build checks failed
joviegas 9ce3003
Junits updated for DDB
joviegas 25002cc
updated s3 integ test
joviegas bffcf40
Merge branch 'master' into joviegas/standard_rerty_default
joviegas cbba880
Merge branch 'master' into joviegas/standard_rerty_default
joviegas ecea40d
add functional test cases with wiremock and explicilty state that tot…
joviegas ccc2455
Refactored test
joviegas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
{ | ||
"type": "feature", | ||
"category": "AWS SDK for Java v2", | ||
"contributor": "", | ||
"description": "Update the default retry strategy to standard based on [Modernizing the default retry strategy](https://aws.amazon.com/blogs/developer/updating-aws-sdk-defaults-aws-sts-service-endpoint-and-retry-strategy/)" | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
101 changes: 101 additions & 0 deletions
101
...est/java/software/amazon/awssdk/services/dynamodb/DynamoDbDefaultRetryFunctionalTest.java
This file contains hidden or 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,101 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.dynamodb; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.post; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
||
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
import com.github.tomakehurst.wiremock.junit5.WireMockTest; | ||
import java.net.URI; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.core.SdkSystemSetting; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; | ||
import software.amazon.awssdk.testutils.EnvironmentVariableHelper; | ||
|
||
/** | ||
* Functional tests to verify DynamoDB client retry behavior with different retry modes. | ||
*/ | ||
@WireMockTest | ||
class DynamoDbDefaultRetryFunctionalTest { | ||
|
||
private final EnvironmentVariableHelper environmentVariableHelper = new EnvironmentVariableHelper(); | ||
private DynamoDbClient dynamoDbClient; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
environmentVariableHelper.reset(); | ||
if (dynamoDbClient != null) { | ||
dynamoDbClient.close(); | ||
} | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"adaptive", "legacy", "standard"}) | ||
void listTables_whenRetryModeSet_shouldAttempt9Times(String retryMode, WireMockRuntimeInfo wm) { | ||
// Set the retry mode environment variable | ||
environmentVariableHelper.set(SdkSystemSetting.AWS_RETRY_MODE.environmentVariable(), retryMode); | ||
|
||
// Build the DynamoDB client here instead of setup so that environment variable options gets picked for each tests | ||
dynamoDbClient = DynamoDbClient.builder() | ||
.endpointOverride(URI.create(wm.getHttpBaseUrl())) | ||
.credentialsProvider(StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create("akid", "skid"))) | ||
.region(Region.US_EAST_1) | ||
.build(); | ||
|
||
stubFor(post(anyUrl()) | ||
.willReturn(aResponse().withStatus(503))); | ||
|
||
assertThatExceptionOfType(DynamoDbException.class) | ||
.isThrownBy(() -> dynamoDbClient.listTables()); | ||
|
||
int actualAttempts = wm.getWireMock().getAllServeEvents().size(); | ||
assertThat(actualAttempts) | ||
.as("Retry mode '%s' should result in 9 total attempts (1 initial + 8 retries)", retryMode) | ||
.isEqualTo(9); | ||
} | ||
|
||
@Test | ||
void listTables_whenUsingDefaultRetryMode_shouldAttempt9Times(WireMockRuntimeInfo wm) { | ||
dynamoDbClient = DynamoDbClient.builder() | ||
.endpointOverride(URI.create(wm.getHttpBaseUrl())) | ||
.credentialsProvider(StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create("akid", "skid"))) | ||
.region(Region.US_EAST_1) | ||
.build(); | ||
stubFor(post(anyUrl()) | ||
.willReturn(aResponse().withStatus(503))); | ||
assertThatExceptionOfType(DynamoDbException.class) | ||
.isThrownBy(() -> dynamoDbClient.listTables()); | ||
|
||
int actualAttempts = wm.getWireMock().getAllServeEvents().size(); | ||
assertThat(actualAttempts) | ||
.as("Default retry mode should result in 9 total attempts (1 initial + 8 retries)") | ||
.isEqualTo(9); | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't this test exactly identical to
listTables_whenNoRetryPolicySet_shouldAttempt9Times
?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.
Done