zentol commented on a change in pull request #15707:
URL: https://github.com/apache/flink/pull/15707#discussion_r618321312



##########
File path: 
flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/testutils/junit/RetryRule.java
##########
@@ -70,26 +71,45 @@ public Statement apply(Statement statement, Description 
description) {
                     "You cannot combine the RetryOnFailure and 
RetryOnException annotations.");
         }
 
+        final Class<? extends Throwable> whitelistedException = 
getExpectedException(description);
+
         if (retryOnFailure != null) {
-            return new RetryOnFailureStatement(retryOnFailure.times(), 
statement);
+            return new RetryOnFailureStatement(
+                    retryOnFailure.times(), statement, whitelistedException);

Review comment:
       This is used to prevent tests annotated with 
`@Test(expected=IllegalArgumentException.class` to be retried multiple times; 
it would just waste time. The retry rule is evaluated before junit checks that 
the test fails as expected (=succeeded), so in this case we can exit early.
   This is for example used to check various preconditions, like rejecting 
nulls, which would not fail with an assertion.
   
   RetryOnException is just a special case of RetryOnFailure, limiting the 
retry to a specific exception that we now the test can occasionally fail with. 
It allows us to be a bit more selective when it comes to retries, and still 
have the test fail quickly if some other issue occurs.
   For example, in the case of cassandra, we know the test can occasionally 
fail with a NoHostAvailableException, but if there is some instabilities in the 
produced result then we want to fail asap.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to