dimas-b commented on code in PR #1046:
URL: https://github.com/apache/polaris/pull/1046#discussion_r1972507075
##########
quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java:
##########
@@ -1521,23 +1530,46 @@ private void createNonExistingNamespaces(Namespace
namespace) {
}
}
- @Test
- public void testRetriableException() {
- Iterator<String> accessDeniedHint =
- Iterators.cycle(IcebergExceptionMapper.getAccessDeniedHints());
- RuntimeException s3Exception = new
RuntimeException(accessDeniedHint.next());
- RuntimeException azureBlobStorageException = new
RuntimeException(accessDeniedHint.next());
- RuntimeException gcsException = new
RuntimeException(accessDeniedHint.next());
- RuntimeException otherException = new RuntimeException(new
IOException("Connection reset"));
-
Assertions.assertThat(BasePolarisCatalog.SHOULD_RETRY_REFRESH_PREDICATE.test(s3Exception))
- .isFalse();
- Assertions.assertThat(
-
BasePolarisCatalog.SHOULD_RETRY_REFRESH_PREDICATE.test(azureBlobStorageException))
- .isFalse();
-
Assertions.assertThat(BasePolarisCatalog.SHOULD_RETRY_REFRESH_PREDICATE.test(gcsException))
- .isFalse();
-
Assertions.assertThat(BasePolarisCatalog.SHOULD_RETRY_REFRESH_PREDICATE.test(otherException))
- .isTrue();
+ @ParameterizedTest
+ @MethodSource
+ public void testRetriableException(Exception exception, boolean shouldRetry)
{
+
Assertions.assertThat(BasePolarisCatalog.SHOULD_RETRY_REFRESH_PREDICATE.test(exception))
+ .isEqualTo(shouldRetry);
+ }
+
+ static Stream<Arguments> testRetriableException() {
+ Set<Integer> NON_RETRYABLE_CODES = Set.of(401, 403, 404);
+ Set<Integer> RETRYABLE_CODES = Set.of(408, 504);
+
+ // Create a map of HTTP code returned from a cloud provider to whether it
should be retried
+ Map<Integer, Boolean> cloudCodeMappings = new HashMap<>();
+ NON_RETRYABLE_CODES.forEach(code -> cloudCodeMappings.put(code, false));
+ RETRYABLE_CODES.forEach(code -> cloudCodeMappings.put(code, true));
+
+ return Stream.of(
+ Stream.of(
+ Arguments.of(new RuntimeException(new IOException("Connection
reset")), true),
+ Arguments.of(RetryableException.builder().build(), true),
+ Arguments.of(NonRetryableException.builder().build(), false)),
+ IcebergExceptionMapper.getAccessDeniedHints().stream()
+ .map(hint -> Arguments.of(new RuntimeException(hint), false)),
+ cloudCodeMappings.entrySet().stream()
+ .flatMap(
+ entry ->
+ Stream.of(
+ Arguments.of(
+ new HttpResponseException(
+ "", new
FakeAzureHttpResponse(entry.getKey()), ""),
+ entry.getValue()),
+ Arguments.of(
+ new StorageException(entry.getKey(), ""),
entry.getValue()))),
+ IcebergExceptionMapper.RETRYABLE_AZURE_HTTP_CODES.stream()
+ .map(
+ code ->
+ Arguments.of(
+ new HttpResponseException("", new
FakeAzureHttpResponse(code), ""),
+ true)))
+ .flatMap(Function.identity());
Review Comment:
nit: I believe there's a "concat" method for Streams.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]