You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2022/11/04 13:19:04 UTC

[flink] branch release-1.16 updated: [FLINK-27740][test] Revert JUnit5 migration for RetryOnFailureTest

This is an automated email from the ASF dual-hosted git repository.

mapohl pushed a commit to branch release-1.16
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.16 by this push:
     new e76e7819a82 [FLINK-27740][test] Revert JUnit5 migration for RetryOnFailureTest
e76e7819a82 is described below

commit e76e7819a826bb0a840142da8a8751c8a0a2a154
Author: Ryan Skraba <rs...@apache.org>
AuthorDate: Fri Oct 21 17:32:01 2022 +0200

    [FLINK-27740][test] Revert JUnit5 migration for RetryOnFailureTest
    
    It's actually meant to test the JUnit4 RetryRule feature. The corresponding JUnit5 Extension is tested in `RetryOnFailureExtensionTest`.
---
 .../testutils/junit/RetryOnExceptionTest.java      | 35 +++++++++++-----------
 .../flink/testutils/junit/RetryOnFailureTest.java  | 31 ++++++++++---------
 2 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionTest.java b/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionTest.java
index 1aa104aa9b2..0f32b54d71d 100644
--- a/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionTest.java
+++ b/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnExceptionTest.java
@@ -18,17 +18,16 @@
 
 package org.apache.flink.testutils.junit;
 
-import org.apache.flink.testutils.junit.extensions.retry.RetryExtension;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.TestTemplate;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-/** Tests for the RetryOnException annotation. */
-@ExtendWith(RetryExtension.class)
-class RetryOnExceptionTest {
+/** Tests for the {@link RetryOnException} annotation on JUnit4 {@link RetryRule}. */
+public class RetryOnExceptionTest {
+
+    @Rule public RetryRule retryRule = new RetryRule();
 
     private static final int NUMBER_OF_RUNS = 3;
 
@@ -40,41 +39,41 @@ class RetryOnExceptionTest {
 
     private static int runsForPassAfterOneFailure = 0;
 
-    @AfterAll
+    @AfterClass
     public static void verify() {
         assertThat(runsForTestWithMatchingException).isEqualTo(NUMBER_OF_RUNS + 1);
         assertThat(runsForTestWithSubclassException).isEqualTo(NUMBER_OF_RUNS + 1);
-        assertThat(runsForSuccessfulTest).isEqualTo(1);
+        assertThat(runsForSuccessfulTest).isOne();
         assertThat(runsForPassAfterOneFailure).isEqualTo(2);
     }
 
-    @TestTemplate
+    @Test
     @RetryOnException(times = NUMBER_OF_RUNS, exception = IllegalArgumentException.class)
-    void testSuccessfulTest() {
+    public void testSuccessfulTest() {
         runsForSuccessfulTest++;
     }
 
-    @TestTemplate
+    @Test
     @RetryOnException(times = NUMBER_OF_RUNS, exception = IllegalArgumentException.class)
-    void testMatchingException() {
+    public void testMatchingException() {
         runsForTestWithMatchingException++;
         if (runsForTestWithMatchingException <= NUMBER_OF_RUNS) {
             throw new IllegalArgumentException();
         }
     }
 
-    @TestTemplate
+    @Test
     @RetryOnException(times = NUMBER_OF_RUNS, exception = RuntimeException.class)
-    void testSubclassException() {
+    public void testSubclassException() {
         runsForTestWithSubclassException++;
         if (runsForTestWithSubclassException <= NUMBER_OF_RUNS) {
             throw new IllegalArgumentException();
         }
     }
 
-    @TestTemplate
+    @Test
     @RetryOnException(times = NUMBER_OF_RUNS, exception = IllegalArgumentException.class)
-    void testPassAfterOneFailure() {
+    public void testPassAfterOneFailure() {
         runsForPassAfterOneFailure++;
         if (runsForPassAfterOneFailure == 1) {
             throw new IllegalArgumentException();
diff --git a/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnFailureTest.java b/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnFailureTest.java
index d0b551ccbb7..3fdf9c0cda2 100644
--- a/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnFailureTest.java
+++ b/flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/testutils/junit/RetryOnFailureTest.java
@@ -18,17 +18,16 @@
 
 package org.apache.flink.testutils.junit;
 
-import org.apache.flink.testutils.junit.extensions.retry.RetryExtension;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.TestTemplate;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-/** Tests for the RetryOnFailure annotation. */
-@ExtendWith(RetryExtension.class)
-class RetryOnFailureTest {
+/** Tests for the {@link RetryOnFailure} annotation on JUnit4 {@link RetryRule}. */
+public class RetryOnFailureTest {
+
+    @Rule public RetryRule retryRule = new RetryRule();
 
     private static final int NUMBER_OF_RUNS = 5;
 
@@ -38,15 +37,15 @@ class RetryOnFailureTest {
 
     private static boolean firstRun = true;
 
-    @AfterAll
-    static void verify() {
+    @AfterClass
+    public static void verify() throws Exception {
         assertThat(numberOfFailedRuns).isEqualTo(NUMBER_OF_RUNS + 1);
         assertThat(numberOfSuccessfulRuns).isEqualTo(3);
     }
 
-    @TestTemplate
+    @Test
     @RetryOnFailure(times = NUMBER_OF_RUNS)
-    void testRetryOnFailure() {
+    public void testRetryOnFailure() throws Exception {
         // All but the (expected) last run should be successful
         if (numberOfFailedRuns < NUMBER_OF_RUNS) {
             numberOfFailedRuns++;
@@ -56,9 +55,9 @@ class RetryOnFailureTest {
         }
     }
 
-    @TestTemplate
+    @Test
     @RetryOnFailure(times = NUMBER_OF_RUNS)
-    void testRetryOnceOnFailure() {
+    public void testRetryOnceOnFailure() throws Exception {
         if (firstRun) {
             numberOfFailedRuns++;
             firstRun = false;
@@ -68,9 +67,9 @@ class RetryOnFailureTest {
         }
     }
 
-    @TestTemplate
+    @Test
     @RetryOnFailure(times = NUMBER_OF_RUNS)
-    void testDontRetryOnSuccess() {
+    public void testDontRetryOnSuccess() throws Exception {
         numberOfSuccessfulRuns++;
     }
 }