|
31 | 31 | import java.io.IOException; |
32 | 32 | import java.util.concurrent.atomic.AtomicBoolean; |
33 | 33 |
|
34 | | -import static org.hamcrest.CoreMatchers.equalTo; |
35 | 34 | import static org.mockito.Mockito.mock; |
36 | 35 |
|
37 | 36 | public class S3ServiceTests extends ESTestCase { |
@@ -82,23 +81,11 @@ public void testRetryOn403RetryPolicy() { |
82 | 81 | ) |
83 | 82 | ); |
84 | 83 |
|
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())); |
102 | 89 | } |
103 | 90 |
|
104 | 91 | @TestLogging(reason = "testing WARN log output", value = "org.elasticsearch.repositories.s3.S3Service:WARN") |
|
0 commit comments