snuyanzin commented on code in PR #20805:
URL: https://github.com/apache/flink/pull/20805#discussion_r977286726


##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =
+                new RetryOnExceptionStrategy(numberOfRetries, 
expectedException.getClass());
+        for (int j = 0; j < numberOfRetries; j++) {
+            final int attemptIndex = j;
+            assertThatThrownBy(
+                            () ->
+                                    r.handleException(
+                                            "Any test name", attemptIndex, 
expectedException))
+                    .isInstanceOf(TestAbortedException.class);
+        }
+        assertThatThrownBy(
+                        () ->
+                                r.handleException(
+                                        "Any test name", numberOfRetries, 
expectedException))
+                .isInstanceOf(expectedException.getClass());
+    }
+
+    static class RetryTestException extends Exception {}
+
+    static class RetryTestRuntimeException extends RuntimeException {}
+

Review Comment:
   ```suggestion
   
   static class RetryTestThrowable extends Throwable {}
   
   ```



##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =
+                new RetryOnExceptionStrategy(numberOfRetries, 
expectedException.getClass());
+        for (int j = 0; j < numberOfRetries; j++) {
+            final int attemptIndex = j;
+            assertThatThrownBy(
+                            () ->
+                                    r.handleException(
+                                            "Any test name", attemptIndex, 
expectedException))
+                    .isInstanceOf(TestAbortedException.class);
+        }
+        assertThatThrownBy(
+                        () ->
+                                r.handleException(
+                                        "Any test name", numberOfRetries, 
expectedException))
+                .isInstanceOf(expectedException.getClass());
+    }
+
+    static class RetryTestException extends Exception {}
+
+    static class RetryTestRuntimeException extends RuntimeException {}
+
+    static Stream<Arguments> retryTestProvider() {
+        return Stream.of(of(4, new RetryTestException()), of(5, new 
RetryTestRuntimeException()));

Review Comment:
   ```suggestion
           return Stream.of(
                   of(3, new RetryTestError()),
                   of(4, new RetryTestException()),
                   of(5, new RetryTestRuntimeException()),
                   of(6, new RetryTestThrowable()));
   ```



##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =
+                new RetryOnExceptionStrategy(numberOfRetries, 
expectedException.getClass());
+        for (int j = 0; j < numberOfRetries; j++) {
+            final int attemptIndex = j;
+            assertThatThrownBy(
+                            () ->
+                                    r.handleException(

Review Comment:
   ```suggestion
                                       retryOnExceptionStrategy.handleException(
   ```



##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =
+                new RetryOnExceptionStrategy(numberOfRetries, 
expectedException.getClass());
+        for (int j = 0; j < numberOfRetries; j++) {
+            final int attemptIndex = j;
+            assertThatThrownBy(
+                            () ->
+                                    r.handleException(
+                                            "Any test name", attemptIndex, 
expectedException))
+                    .isInstanceOf(TestAbortedException.class);
+        }
+        assertThatThrownBy(
+                        () ->
+                                r.handleException(
+                                        "Any test name", numberOfRetries, 
expectedException))
+                .isInstanceOf(expectedException.getClass());
+    }
+

Review Comment:
   ```suggestion
   
   static class RetryTestError extends Error {}
   
   ```



##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =

Review Comment:
   ```suggestion
           RetryOnExceptionStrategy retryOnExceptionStrategy =
   ```



##########
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionExtensionTest.java:
##########
@@ -80,4 +89,33 @@ void testPassAfterOneFailure() {
             throw new IllegalArgumentException();
         }
     }
+
+    @ParameterizedTest(name = "With {0} retries for {1}")
+    @MethodSource("retryTestProvider")
+    void testRetryFailsWithExpectedExceptionAfterNumberOfRetries(
+            final int numberOfRetries, final Throwable expectedException) {
+        RetryOnExceptionStrategy r =
+                new RetryOnExceptionStrategy(numberOfRetries, 
expectedException.getClass());
+        for (int j = 0; j < numberOfRetries; j++) {
+            final int attemptIndex = j;
+            assertThatThrownBy(
+                            () ->
+                                    r.handleException(
+                                            "Any test name", attemptIndex, 
expectedException))
+                    .isInstanceOf(TestAbortedException.class);
+        }
+        assertThatThrownBy(
+                        () ->
+                                r.handleException(

Review Comment:
   ```suggestion
                                   retryOnExceptionStrategy.handleException(
   ```



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to