Skip to content

Commit 30d7d94

Browse files
remove randomized non-403 retry testing: predicate no longer falls back to default retry logic, separate now
1 parent ae12724 commit 30d7d94

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/S3ServiceTests.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.io.IOException;
3232
import java.util.concurrent.atomic.AtomicBoolean;
3333

34-
import static org.hamcrest.CoreMatchers.equalTo;
3534
import static org.mockito.Mockito.mock;
3635

3736
public class S3ServiceTests extends ESTestCase {
@@ -82,23 +81,11 @@ public void testRetryOn403RetryPolicy() {
8281
)
8382
);
8483

85-
if (randomBoolean()) {
86-
// Random for another error status that is not 403
87-
var non403StatusCode = randomValueOtherThan(403, () -> between(0, 600));
88-
var non403Exception = S3Exception.builder().statusCode(non403StatusCode).awsErrorDetails(awsErrorDetails).build();
89-
var retryPolicyContext = RetryPolicyContext.builder().retriesAttempted(between(0, 9)).exception(non403Exception).build();
90-
// Retryable 403 condition delegates to the AWS default retry condition. Its result must be consistent with the decision
91-
// by the AWS default, e.g. some error status like 429 is retryable by default, the retryable 403 condition respects it.
92-
boolean actual = S3Service.RETRYABLE_403_PREDICATE(retryPolicyContext.exception());
93-
boolean expected = RetryCondition.defaultRetryCondition().shouldRetry(retryPolicyContext);
94-
assertThat(actual, equalTo(expected));
95-
} else {
96-
// Not retry for 403 with error code that is not invalid access key id
97-
String errorCode = randomAlphaOfLength(10);
98-
var exception = S3Exception.builder().awsErrorDetails(AwsErrorDetails.builder().errorCode(errorCode).build()).build();
99-
var retryPolicyContext = RetryPolicyContext.builder().retriesAttempted(between(0, 9)).exception(exception).build();
100-
assertFalse(S3Service.RETRYABLE_403_PREDICATE(retryPolicyContext.exception()));
101-
}
84+
// Not retry for 403 with error code that is not invalid access key id
85+
String errorCode = randomAlphaOfLength(10);
86+
var exception = S3Exception.builder().awsErrorDetails(AwsErrorDetails.builder().errorCode(errorCode).build()).build();
87+
var retryPolicyContext = RetryPolicyContext.builder().retriesAttempted(between(0, 9)).exception(exception).build();
88+
assertFalse(S3Service.RETRYABLE_403_PREDICATE(retryPolicyContext.exception()));
10289
}
10390

10491
@TestLogging(reason = "testing WARN log output", value = "org.elasticsearch.repositories.s3.S3Service:WARN")

0 commit comments

Comments
 (0)