You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/24 10:09:29 UTC

[GitHub] [flink] reswqa opened a new pull request, #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

reswqa opened a new pull request, #19560:
URL: https://github.com/apache/flink/pull/19560

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Migrate flink-k8s module's test from junit4 to junit5.
   
   
   ## Brief change log
   
     - migrate tests from junit assert to AssertJ
     - migrate tests from junit4 to junit5
   
   ## Verifying this change
   
   This change is already covered by existing tests.
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies : no 
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
   


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858229604


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesExtension.java:
##########
@@ -44,14 +48,14 @@ public class KubernetesResource extends ExternalResource {
 
     public static void checkEnv() {
         final String kubeConfigEnv = System.getenv("ITCASE_KUBECONFIG");
-        Assume.assumeTrue(
-                "ITCASE_KUBECONFIG environment is not set.",
-                !StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv));
+        assertThat(StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv))

Review Comment:
   Let me confirm that this line of code should reverts to the state before modification, so that the test will be skipped instead of failed in the CI environment without k8s, right?



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858386889


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesLeaderElectorITCase.java:
##########
@@ -19,36 +19,33 @@
 package org.apache.flink.kubernetes.kubeclient.resources;
 
 import org.apache.flink.configuration.Configuration;
-import org.apache.flink.kubernetes.KubernetesResource;
+import org.apache.flink.kubernetes.KubernetesExtension;
 import org.apache.flink.kubernetes.configuration.KubernetesLeaderElectionConfiguration;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import java.util.UUID;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /**
  * IT Tests for the {@link KubernetesLeaderElector}. Start multiple leader contenders currently, one
  * should elect successfully. And if current leader dies, a new one could take over.
  */
-public class KubernetesLeaderElectorITCase extends TestLogger {
-
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+public class KubernetesLeaderElectorITCase {
+    @RegisterExtension
+    private static final KubernetesExtension kubernetesExtension = new KubernetesExtension();

Review Comment:
   ah nvm, extensions can be private...



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858382210


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesExtension.java:
##########
@@ -44,14 +48,14 @@ public class KubernetesResource extends ExternalResource {
 
     public static void checkEnv() {
         final String kubeConfigEnv = System.getenv("ITCASE_KUBECONFIG");
-        Assume.assumeTrue(
-                "ITCASE_KUBECONFIG environment is not set.",
-                !StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv));
+        assertThat(StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv))

Review Comment:
   you should use `org.assertj.core.api.Assumptions.assumeThat`



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1107875325

   @flinkbot run azure
   


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858382667


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -138,7 +139,8 @@ protected void generateKerberosFileItems() throws IOException {
         KubernetesTestUtils.createTemporyFile("some conf", kerberosDir, KRB5_CONF_FILE);
     }
 
-    protected String writeKubeConfigForMockKubernetesServer() throws Exception {
+    protected String writeKubeConfigForMockKubernetesServer(@TempDir Path kubeConfPath)

Review Comment:
   if its unused go ahead and remove it



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858282379


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();
         assertThat(
-                flinkPod.getPodWithoutMainContainer()
-                        == copiedFlinkPod.getPodWithoutMainContainer(),
-                is(false));
-        assertThat(
-                flinkPod.getPodWithoutMainContainer(),
-                is(equalTo(copiedFlinkPod.getPodWithoutMainContainer())));
-        assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer(), is(false));
-        assertThat(flinkPod.getMainContainer(), is(equalTo(copiedFlinkPod.getMainContainer())));
+                        flinkPod.getPodWithoutMainContainer()
+                                == copiedFlinkPod.getPodWithoutMainContainer())
+                .isFalse();
+        assertThat(flinkPod.getPodWithoutMainContainer())
+                .isEqualTo(copiedFlinkPod.getPodWithoutMainContainer());
+        assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer()).isFalse();

Review Comment:
   Ditto



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858287296


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesLeaderElectorITCase.java:
##########
@@ -19,36 +19,33 @@
 package org.apache.flink.kubernetes.kubeclient.resources;
 
 import org.apache.flink.configuration.Configuration;
-import org.apache.flink.kubernetes.KubernetesResource;
+import org.apache.flink.kubernetes.KubernetesExtension;
 import org.apache.flink.kubernetes.configuration.KubernetesLeaderElectionConfiguration;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import java.util.UUID;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /**
  * IT Tests for the {@link KubernetesLeaderElector}. Start multiple leader contenders currently, one
  * should elect successfully. And if current leader dies, a new one could take over.
  */
-public class KubernetesLeaderElectorITCase extends TestLogger {
-
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+public class KubernetesLeaderElectorITCase {
+    @RegisterExtension
+    private static final KubernetesExtension kubernetesExtension = new KubernetesExtension();

Review Comment:
   What is the reason why the fields modified by @RegisterExtension cannot be private, will this affect the injection of Extension or is it just our specific requirement.



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1109367083

   @zentol Thank you very much for your timely and patient reviews and suggestions. I replied to your comments for some places that I am not sure how to modify. I will submit all the modifications after I determine how to modify them here.


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858251301


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStoreTest.java:
##########
@@ -399,31 +406,38 @@ public void testReplaceWithDeletingKeyWithFailingDiscard() throws Exception {
                             final TestingLongStateHandleHelper.LongStateHandle newState =
                                     new TestingLongStateHandleHelper.LongStateHandle(23456L);
 
-                            assertThat(store.exists(key), is(StringResourceVersion.notExisting()));
-                            final StateHandleStore.NotExistException exception =
-                                    assertThrows(
-                                            StateHandleStore.NotExistException.class,
+                            assertThat(store.exists(key))
+                                    .isEqualByComparingTo(StringResourceVersion.notExisting());
+                            StateHandleStore.NotExistException exception =
+                                    catchThrowableOfType(

Review Comment:
   I am not particularly familiar with this. If I change it in the following way, what method should I use to get the suppressed exception to make the required assertion by the next lines of code.
   ```
   assertThatThrownBy(() ->store.replace(
                                                       key,
                                                       StringResourceVersion.notExisting(),
                                                       newState)).isInstanceOf(StateHandleStore.NotExistException.class);
   ```



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1109586603

   @zentol I submitted a new commit to solve the review opinion. Please have a look when you have time.


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858246149


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -67,40 +68,47 @@
  * Tests for recovering from savepoint when Kubernetes HA is enabled. The savepoint will be
  * persisted as a checkpoint and stored in the ConfigMap when recovered successfully.
  */
-public class KubernetesHighAvailabilityRecoverFromSavepointITCase extends TestLogger {
+public class KubernetesHighAvailabilityRecoverFromSavepointITCase {
 
     private static final long TIMEOUT = 60 * 1000;
 
     private static final String CLUSTER_ID = "flink-on-k8s-cluster-" + System.currentTimeMillis();
 
     private static final String FLAT_MAP_UID = "my-flat-map";
 
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+    private static Path temporaryPath;

Review Comment:
   getConfiguration() will be called during initialization of MiniClusterExtension. A path is required here, but the injection time of @ TempDir seems to be later than the initialization of static variables, resulting in null path. I checked JUnit's doc and didn't find a way to modify the injection timing. Do you have any suggestions about this.
   
   



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1108093311

   @flinkbot run azure


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r857377443


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClusterClientFactoryTest.java:
##########
@@ -45,6 +45,6 @@ private void testKubernetesClusterClientFactoryDiscoveryHelper(final String targ
         final ClusterClientFactory<String> factory =
                 serviceLoader.getClusterClientFactory(configuration);
 
-        assertTrue(factory instanceof KubernetesClusterClientFactory);
+        assertThat(factory instanceof KubernetesClusterClientFactory).isTrue();

Review Comment:
   use proper isInstanceOf assertion



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesExtension.java:
##########
@@ -44,14 +48,14 @@ public class KubernetesResource extends ExternalResource {
 
     public static void checkEnv() {
         final String kubeConfigEnv = System.getenv("ITCASE_KUBECONFIG");
-        Assume.assumeTrue(
-                "ITCASE_KUBECONFIG environment is not set.",
-                !StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv));
+        assertThat(StringUtils.isNullOrWhitespaceOnly(kubeConfigEnv))

Review Comment:
   this causes CI failures; you must use assumeThat here.



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -37,18 +36,22 @@
 import io.fabric8.kubernetes.api.model.NamedContextBuilder;
 import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
 import io.fabric8.kubernetes.client.utils.Serialization;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.Map;
 
 /** Base test class for Kubernetes. */
-public class KubernetesTestBase extends TestLogger {
+public class KubernetesTestBase {

Review Comment:
   can this class me package-private?



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -105,8 +106,8 @@ public final void setup() throws Exception {
         onSetup();
     }
 
-    @After
-    public void tearDown() throws Exception {
+    @AfterEach
+    private void tearDown() throws Exception {

Review Comment:
   life-cycle methods should be package-private as per official junit javadocs.
   
   ```suggestion
       void tearDown() throws Exception {
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/cli/KubernetesSessionCliTest.java:
##########
@@ -77,20 +75,19 @@ public void testDynamicProperties() throws Exception {
         final Configuration executorConfig = cli.getEffectiveConfiguration(args);
         final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 
-        Assert.assertNotNull(clientFactory);
+        assertThat(clientFactory).isNotNull();
 
         final Map<String, String> executorConfigMap = executorConfig.toMap();
-        assertEquals(4, executorConfigMap.size());
-        assertEquals("5 min", executorConfigMap.get("akka.ask.timeout"));
-        assertEquals("-DappName=foobar", executorConfigMap.get("env.java.opts"));
-        assertEquals(
-                tmp.getRoot().getAbsolutePath(),
-                executorConfig.get(DeploymentOptionsInternal.CONF_DIR));
-        assertTrue(executorConfigMap.containsKey(DeploymentOptions.TARGET.key()));
+        assertThat(executorConfigMap).hasSize(4);
+        assertThat(executorConfigMap.get("akka.ask.timeout")).isEqualTo("5 min");

Review Comment:
   This block can be re-written to:
   `assertThat(executorConfigMap).contains(entry(<key>, <value>), entry(...), ...);`



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesLeaderElectionDriverTest.java:
##########
@@ -71,24 +68,21 @@ public void testNotLeader() throws Exception {
                             getLeaderCallback().notLeader();
 
                             electionEventHandler.waitForRevokeLeader();
-                            assertThat(electionEventHandler.isLeader(), is(false));
-                            assertThat(
-                                    electionEventHandler.getConfirmedLeaderInformation(),
-                                    is(LeaderInformation.empty()));
+                            assertThat(electionEventHandler.isLeader()).isFalse();
+                            assertThat(electionEventHandler.getConfirmedLeaderInformation())
+                                    .isEqualTo(LeaderInformation.empty());
                             // The ConfigMap should also be cleared
-                            assertThat(
-                                    getLeaderConfigMap().getData().get(LEADER_ADDRESS_KEY),
-                                    is(nullValue()));
-                            assertThat(
-                                    getLeaderConfigMap().getData().get(LEADER_SESSION_ID_KEY),
-                                    is(nullValue()));
+                            assertThat(getLeaderConfigMap().getData().get(LEADER_ADDRESS_KEY))

Review Comment:
   can be re-written as a doesNotContain assertion against the map itself



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityTestBase.java:
##########
@@ -44,7 +43,7 @@
 import java.util.concurrent.TimeUnit;
 
 /** Base class for high availability unit tests with a configured testing Kubernetes client. */
-public class KubernetesHighAvailabilityTestBase extends TestLogger {
+public class KubernetesHighAvailabilityTestBase {

Review Comment:
   can this be package-private?



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientITCase.java:
##########
@@ -87,8 +85,8 @@ public void setup() throws Exception {
                         data.size(), new ExecutorThreadFactory("test-leader-io"));
     }
 
-    @After
-    public void teardown() throws Exception {
+    @AfterEach
+    private void teardown() throws Exception {

Review Comment:
   ```suggestion
       void teardown() throws Exception {
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientITCase.java:
##########
@@ -40,17 +39,16 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.everyItem;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /**
  * IT Tests for {@link org.apache.flink.kubernetes.kubeclient.Fabric8FlinkKubeClient} with real K8s
  * server and client.
  */
-public class Fabric8FlinkKubeClientITCase extends TestLogger {
+public class Fabric8FlinkKubeClientITCase {

Review Comment:
   ```suggestion
   class Fabric8FlinkKubeClientITCase {
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/AbstractKubernetesParametersTest.java:
##########
@@ -24,121 +24,120 @@
 import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
 import org.apache.flink.kubernetes.utils.Constants;
 import org.apache.flink.util.StringUtils;
-import org.apache.flink.util.TestLogger;
 import org.apache.flink.util.function.RunnableWithException;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Random;
 
-import static org.apache.flink.core.testutils.CommonTestUtils.assertThrows;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
+import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** General tests for the {@link AbstractKubernetesParameters}. */
-public class AbstractKubernetesParametersTest extends TestLogger {
+public class AbstractKubernetesParametersTest {
 
     private final Configuration flinkConfig = new Configuration();
     private final TestingKubernetesParameters testingKubernetesParameters =
             new TestingKubernetesParameters(flinkConfig);
 
-    @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
     @Test
-    public void testClusterIdMustNotBeBlank() {
+    void testClusterIdMustNotBeBlank() {
         flinkConfig.set(KubernetesConfigOptions.CLUSTER_ID, "  ");
-        assertThrows(
-                "must not be blank",
-                IllegalArgumentException.class,
-                testingKubernetesParameters::getClusterId);
+        assertThatThrownBy(testingKubernetesParameters::getClusterId)
+                .satisfies(anyCauseMatches(IllegalArgumentException.class, "must not be blank"));
     }
 
     @Test
-    public void testClusterIdLengthLimitation() {
+    void testClusterIdLengthLimitation() {
         final String stringWithIllegalLength =
                 StringUtils.generateRandomAlphanumericString(
                         new Random(), Constants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID + 1);
         flinkConfig.set(KubernetesConfigOptions.CLUSTER_ID, stringWithIllegalLength);
-        assertThrows(
-                "must be no more than "
-                        + Constants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID
-                        + " characters",
-                IllegalArgumentException.class,
-                testingKubernetesParameters::getClusterId);
+        assertThatThrownBy(testingKubernetesParameters::getClusterId)
+                .satisfies(
+                        anyCauseMatches(
+                                IllegalArgumentException.class,
+                                "must be no more than "
+                                        + Constants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID
+                                        + " characters"));
     }
 
     @Test
-    public void getConfigDirectory() {
+    void getConfigDirectory() {
         final String confDir = "/path/of/flink-conf";
         flinkConfig.set(DeploymentOptionsInternal.CONF_DIR, confDir);
-        assertThat(testingKubernetesParameters.getConfigDirectory(), is(confDir));
+        assertThat(testingKubernetesParameters.getConfigDirectory()).isEqualTo(confDir);
     }
 
     @Test
-    public void getConfigDirectoryFallbackToPodConfDir() {
+    void getConfigDirectoryFallbackToPodConfDir() {
         final String confDirInPod = flinkConfig.get(KubernetesConfigOptions.FLINK_CONF_DIR);
-        assertThat(testingKubernetesParameters.getConfigDirectory(), is(confDirInPod));
+        assertThat(testingKubernetesParameters.getConfigDirectory()).isEqualTo(confDirInPod);
     }
 
     @Test
-    public void testGetLocalHadoopConfigurationDirectoryReturnEmptyWhenHadoopEnvIsNotSet()
+    void testGetLocalHadoopConfigurationDirectoryReturnEmptyWhenHadoopEnvIsNotSet()
             throws Exception {
         runTestWithEmptyEnv(
                 () -> {
                     final Optional<String> optional =
                             testingKubernetesParameters.getLocalHadoopConfigurationDirectory();
-                    assertThat(optional.isPresent(), is(false));
+                    assertThat(optional).isNotPresent();
                 });
     }
 
     @Test
-    public void testGetLocalHadoopConfigurationDirectoryFromHadoopConfDirEnv() throws Exception {
+    void testGetLocalHadoopConfigurationDirectoryFromHadoopConfDirEnv() throws Exception {
         runTestWithEmptyEnv(
                 () -> {
                     final String hadoopConfDir = "/etc/hadoop/conf";
                     setEnv(Constants.ENV_HADOOP_CONF_DIR, hadoopConfDir);
 
                     final Optional<String> optional =
                             testingKubernetesParameters.getLocalHadoopConfigurationDirectory();
-                    assertThat(optional.isPresent(), is(true));
-                    assertThat(optional.get(), is(hadoopConfDir));
+                    assertThat(optional).isPresent();
+                    assertThat(optional.get()).isEqualTo(hadoopConfDir);
                 });
     }
 
     @Test
-    public void testGetLocalHadoopConfigurationDirectoryFromHadoop2HomeEnv() throws Exception {
+    void testGetLocalHadoopConfigurationDirectoryFromHadoop2HomeEnv(@TempDir Path temporaryFolder)
+            throws Exception {
         runTestWithEmptyEnv(
                 () -> {
-                    final String hadoopHome = temporaryFolder.getRoot().getAbsolutePath();
-                    temporaryFolder.newFolder("etc", "hadoop");
+                    final String hadoopHome = temporaryFolder.toAbsolutePath().toString();
+                    Files.createDirectories(temporaryFolder.resolve("etc/hadoop"));

Review Comment:
   ```suggestion
                       Files.createDirectories(temporaryFolder.resolve(Paths.get("etc", "hadoop")));
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesTaskManagerParametersTest.java:
##########
@@ -106,17 +103,17 @@ protected void onSetup() throws Exception {
     }
 
     @Test
-    public void testGetEnvironments() {
-        assertEquals(customizedEnvs, kubernetesTaskManagerParameters.getEnvironments());
+    void testGetEnvironments() {
+        assertThat(kubernetesTaskManagerParameters.getEnvironments()).isEqualTo(customizedEnvs);
     }
 
     @Test
-    public void testGetEmptyAnnotations() {
-        assertTrue(kubernetesTaskManagerParameters.getAnnotations().isEmpty());
+    void testGetEmptyAnnotations() {
+        assertThat(kubernetesTaskManagerParameters.getAnnotations().isEmpty()).isTrue();

Review Comment:
   ```suggestion
           assertThat(kubernetesTaskManagerParameters.getAnnotations()).isEmpty();
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesLeaderElectorITCase.java:
##########
@@ -19,36 +19,33 @@
 package org.apache.flink.kubernetes.kubeclient.resources;
 
 import org.apache.flink.configuration.Configuration;
-import org.apache.flink.kubernetes.KubernetesResource;
+import org.apache.flink.kubernetes.KubernetesExtension;
 import org.apache.flink.kubernetes.configuration.KubernetesLeaderElectionConfiguration;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import java.util.UUID;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /**
  * IT Tests for the {@link KubernetesLeaderElector}. Start multiple leader contenders currently, one
  * should elect successfully. And if current leader dies, a new one could take over.
  */
-public class KubernetesLeaderElectorITCase extends TestLogger {
-
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+public class KubernetesLeaderElectorITCase {
+    @RegisterExtension
+    private static final KubernetesExtension kubernetesExtension = new KubernetesExtension();

Review Comment:
   ```suggestion
       static final KubernetesExtension kubernetesExtension = new KubernetesExtension();
   ```
   Please also check for occurrences in other files.



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerDriverTest.java:
##########
@@ -47,23 +47,21 @@
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
 
 /** Tests for {@link KubernetesResourceManagerDriver}. */
-public class KubernetesResourceManagerDriverTest
+class KubernetesResourceManagerDriverTest
         extends ResourceManagerDriverTestBase<KubernetesWorkerNode> {
 
     private static final String CLUSTER_ID = "testing-flink-cluster";
     private static final KubernetesResourceManagerDriverConfiguration
             KUBERNETES_RESOURCE_MANAGER_CONFIGURATION =
                     new KubernetesResourceManagerDriverConfiguration(CLUSTER_ID, "localhost:9000");
 
-    @Test
-    public void testOnPodAdded() throws Exception {
+    @org.junit.jupiter.api.Test

Review Comment:
   dont use qualified imports



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -161,7 +163,7 @@ protected String writeKubeConfigForMockKubernetesServer() throws Exception {
                                         .build())
                         .withNewCurrentContext(CLUSTER_ID)
                         .build();
-        final File kubeConfigFile = new File(temporaryFolder.newFolder(".kube"), "config");
+        final File kubeConfigFile = new File(kubeConfPath.resolve(".kube").toFile(), "config");

Review Comment:
   ```suggestion
           final File kubeConfigFile = kubeConfPath.resolve(".kube").resolve("config").toFile();
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -138,7 +139,8 @@ protected void generateKerberosFileItems() throws IOException {
         KubernetesTestUtils.createTemporyFile("some conf", kerberosDir, KRB5_CONF_FILE);
     }
 
-    protected String writeKubeConfigForMockKubernetesServer() throws Exception {
+    protected String writeKubeConfigForMockKubernetesServer(@TempDir Path kubeConfPath)

Review Comment:
   The annotation shouldn't work here, as it is neither a lifecycle nor test method.
   ```suggestion
       protected String writeKubeConfigForMockKubernetesServer(Path kubeConfPath)
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -88,11 +87,13 @@ protected void setupFlinkConfig() {
 
     protected void onSetup() throws Exception {}
 
-    @Before
-    public final void setup() throws Exception {
-        flinkConfDir = temporaryFolder.newFolder().getAbsoluteFile();
-        hadoopConfDir = temporaryFolder.newFolder().getAbsoluteFile();
-        kerberosDir = temporaryFolder.newFolder().getAbsoluteFile();
+    @BeforeEach
+    private final void setup(

Review Comment:
   ```suggestion
       void setup(
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/entrypoint/KubernetesWorkerResourceSpecFactoryTest.java:
##########
@@ -22,48 +22,43 @@
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.TaskManagerOptions;
 import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link KubernetesWorkerResourceSpecFactory}. */
-public class KubernetesWorkerResourceSpecFactoryTest extends TestLogger {
+class KubernetesWorkerResourceSpecFactoryTest {
 
     @Test
-    public void testGetCpuCoresCommonOption() {
+    void testGetCpuCoresCommonOption() {
         final Configuration configuration = new Configuration();
         configuration.setDouble(TaskManagerOptions.CPU_CORES, 1.0);
         configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU, 2.0);
         configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU_LIMIT_FACTOR, 1.5);
         configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
 
-        assertThat(
-                KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration),
-                is(new CPUResource(1.0)));
+        assertThat(KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration))
+                .isEqualByComparingTo(new CPUResource(1.0));
     }
 
     @Test
-    public void testGetCpuCoresKubernetesOption() {
+    void testGetCpuCoresKubernetesOption() {
         final Configuration configuration = new Configuration();
         configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU, 2.0);
         configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU_LIMIT_FACTOR, 1.5);
         configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
 
-        assertThat(
-                KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration),
-                is(new CPUResource(2.0)));
+        assertThat(KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration))
+                .isEqualByComparingTo(new CPUResource(2.0));
     }
 
     @Test
-    public void testGetCpuCoresNumSlots() {
+    void testGetCpuCoresNumSlots() {
         final Configuration configuration = new Configuration();
         configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
 
-        assertThat(
-                KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration),
-                is(new CPUResource(3.0)));
+        assertThat(KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration))
+                .isEqualByComparingTo(new CPUResource(3.0));

Review Comment:
   isEqualTo should work just fine.



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -67,40 +68,47 @@
  * Tests for recovering from savepoint when Kubernetes HA is enabled. The savepoint will be
  * persisted as a checkpoint and stored in the ConfigMap when recovered successfully.
  */
-public class KubernetesHighAvailabilityRecoverFromSavepointITCase extends TestLogger {
+public class KubernetesHighAvailabilityRecoverFromSavepointITCase {
 
     private static final long TIMEOUT = 60 * 1000;
 
     private static final String CLUSTER_ID = "flink-on-k8s-cluster-" + System.currentTimeMillis();
 
     private static final String FLAT_MAP_UID = "my-flat-map";
 
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+    private static Path temporaryPath;

Review Comment:
   this should have the `@TempDir` annotation.



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java:
##########
@@ -361,138 +355,121 @@ private void testNodePortService(KubernetesConfigOptions.NodePortAddressType add
                     throw new IllegalArgumentException(
                             String.format("Unexpected address type %s.", addressType));
             }
-            assertThat(resultEndpoint.get().getAddress(), isIn(expectedIps));
-            assertThat(resultEndpoint.get().getPort(), is(NODE_PORT));
+            assertThat(resultEndpoint.get().getAddress()).isIn(expectedIps);
+            assertThat(resultEndpoint.get().getPort()).isEqualTo(NODE_PORT);
         }
     }
 
     @Test
-    public void testNodePortServiceWithNoMatchingIP() {
+    void testNodePortServiceWithNoMatchingIP() {
         mockExpectedServiceFromServerSide(buildExternalServiceWithNodePort());
-        assertFalse(flinkKubeClient.getRestEndpoint(CLUSTER_ID).isPresent());
+        assertThat(flinkKubeClient.getRestEndpoint(CLUSTER_ID).isPresent()).isFalse();

Review Comment:
   ```suggestion
           assertThat(flinkKubeClient.getRestEndpoint(CLUSTER_ID)).isNotPresent();



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -130,19 +139,19 @@ public void testRecoverFromSavepoint() throws Exception {
         assertThat(clusterClient.requestJobResult(jobId).join().isSuccess()).isTrue();
     }
 
-    private Configuration getConfiguration() {
+    private static Configuration getConfiguration() {
         Configuration configuration = new Configuration();
         configuration.set(KubernetesConfigOptions.CLUSTER_ID, CLUSTER_ID);
         configuration.set(
                 HighAvailabilityOptions.HA_MODE,
                 KubernetesHaServicesFactory.class.getCanonicalName());
         try {
-            configuration.set(
-                    HighAvailabilityOptions.HA_STORAGE_PATH,
-                    temporaryFolder.newFolder().getAbsolutePath());
+            temporaryPath = Files.createTempDirectory("haStorage");
         } catch (IOException e) {
-            throw new FlinkRuntimeException("Failed to create HA storage", e);
+            throw new RuntimeException("can't create ha storage path.");

Review Comment:
   why are you changing this?



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStoreTest.java:
##########
@@ -399,31 +406,38 @@ public void testReplaceWithDeletingKeyWithFailingDiscard() throws Exception {
                             final TestingLongStateHandleHelper.LongStateHandle newState =
                                     new TestingLongStateHandleHelper.LongStateHandle(23456L);
 
-                            assertThat(store.exists(key), is(StringResourceVersion.notExisting()));
-                            final StateHandleStore.NotExistException exception =
-                                    assertThrows(
-                                            StateHandleStore.NotExistException.class,
+                            assertThat(store.exists(key))
+                                    .isEqualByComparingTo(StringResourceVersion.notExisting());
+                            StateHandleStore.NotExistException exception =
+                                    catchThrowableOfType(

Review Comment:
   This can still be modeled as `assertThatThrownBy().satisfies(...);`



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -67,40 +68,47 @@
  * Tests for recovering from savepoint when Kubernetes HA is enabled. The savepoint will be
  * persisted as a checkpoint and stored in the ConfigMap when recovered successfully.
  */
-public class KubernetesHighAvailabilityRecoverFromSavepointITCase extends TestLogger {
+public class KubernetesHighAvailabilityRecoverFromSavepointITCase {
 
     private static final long TIMEOUT = 60 * 1000;
 
     private static final String CLUSTER_ID = "flink-on-k8s-cluster-" + System.currentTimeMillis();
 
     private static final String FLAT_MAP_UID = "my-flat-map";
 
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+    private static Path temporaryPath;
 
-    @ClassRule public static TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-    @Rule
-    public MiniClusterWithClientResource miniClusterResource =
-            new MiniClusterWithClientResource(
+    @RegisterExtension
+    @Order(1)

Review Comment:
   why is the order relevant?



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientITCase.java:
##########
@@ -69,9 +67,9 @@ public class Fabric8FlinkKubeClientITCase extends TestLogger {
 
     private ExecutorService executorService;
 
-    @Before
-    public void setup() throws Exception {
-        flinkKubeClient = kubernetesResource.getFlinkKubeClient();
+    @BeforeEach
+    private void setup() throws Exception {

Review Comment:
   ```suggestion
       void setup() throws Exception {
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/cli/KubernetesSessionCliTest.java:
##########
@@ -77,20 +75,19 @@ public void testDynamicProperties() throws Exception {
         final Configuration executorConfig = cli.getEffectiveConfiguration(args);
         final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 
-        Assert.assertNotNull(clientFactory);
+        assertThat(clientFactory).isNotNull();
 
         final Map<String, String> executorConfigMap = executorConfig.toMap();
-        assertEquals(4, executorConfigMap.size());
-        assertEquals("5 min", executorConfigMap.get("akka.ask.timeout"));
-        assertEquals("-DappName=foobar", executorConfigMap.get("env.java.opts"));
-        assertEquals(
-                tmp.getRoot().getAbsolutePath(),
-                executorConfig.get(DeploymentOptionsInternal.CONF_DIR));
-        assertTrue(executorConfigMap.containsKey(DeploymentOptions.TARGET.key()));
+        assertThat(executorConfigMap).hasSize(4);
+        assertThat(executorConfigMap.get("akka.ask.timeout")).isEqualTo("5 min");
+        assertThat(executorConfigMap.get("env.java.opts")).isEqualTo("-DappName=foobar");
+        assertThat(confDirPath.toAbsolutePath().toString())
+                .isEqualTo(executorConfig.get(DeploymentOptionsInternal.CONF_DIR));

Review Comment:
   invert assertion



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStoreTest.java:
##########
@@ -575,38 +594,40 @@ public void testReplaceFailedWithPossiblyInconsistentState() throws Exception {
                                                     LOCK_IDENTITY);
 
                             final StringResourceVersion resourceVersion = anotherStore.exists(key);
-                            assertThat(resourceVersion.isExisting(), is(true));
-                            try {
-                                anotherStore.replace(
-                                        key,
-                                        resourceVersion,
-                                        new TestingLongStateHandleHelper.LongStateHandle(23456L));
-                                fail(
-                                        "An exception having a PossibleInconsistentStateException as its cause should have been thrown.");
-                            } catch (Exception ex) {
-                                assertThat(ex, is(updateException));
-                            }
-                            assertThat(anotherStore.getAllAndLock().size(), is(1));
+                            assertThat(resourceVersion.isExisting()).isTrue();
+                            assertThatThrownBy(
+                                            () ->
+                                                    anotherStore.replace(
+                                                            key,
+                                                            resourceVersion,
+                                                            new TestingLongStateHandleHelper
+                                                                    .LongStateHandle(23456L)),
+                                            "An exception having a PossibleInconsistentStateException as its cause should have been thrown.")
+                                    .satisfies(
+                                            cause -> assertThat(cause).isEqualTo(updateException));

Review Comment:
   ```suggestion
                                       .isEqualTo(updateException);
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java:
##########
@@ -361,138 +355,121 @@ private void testNodePortService(KubernetesConfigOptions.NodePortAddressType add
                     throw new IllegalArgumentException(
                             String.format("Unexpected address type %s.", addressType));
             }
-            assertThat(resultEndpoint.get().getAddress(), isIn(expectedIps));
-            assertThat(resultEndpoint.get().getPort(), is(NODE_PORT));
+            assertThat(resultEndpoint.get().getAddress()).isIn(expectedIps);
+            assertThat(resultEndpoint.get().getPort()).isEqualTo(NODE_PORT);
         }
     }
 
     @Test
-    public void testNodePortServiceWithNoMatchingIP() {
+    void testNodePortServiceWithNoMatchingIP() {
         mockExpectedServiceFromServerSide(buildExternalServiceWithNodePort());
-        assertFalse(flinkKubeClient.getRestEndpoint(CLUSTER_ID).isPresent());
+        assertThat(flinkKubeClient.getRestEndpoint(CLUSTER_ID).isPresent()).isFalse();
     }
 
     @Test
-    public void testClusterIPService() {
+    void testClusterIPService() {
         mockExpectedServiceFromServerSide(buildExternalServiceWithClusterIP());
 
         final Optional<Endpoint> resultEndpoint = flinkKubeClient.getRestEndpoint(CLUSTER_ID);
-        assertThat(resultEndpoint.isPresent(), is(true));
-        assertThat(
-                resultEndpoint.get().getAddress(),
-                is(
+        assertThat(resultEndpoint).isPresent();
+        assertThat(resultEndpoint.get().getAddress())
+                .isEqualTo(
                         ExternalServiceDecorator.getNamespacedExternalServiceName(
-                                CLUSTER_ID, NAMESPACE)));
-        assertThat(resultEndpoint.get().getPort(), is(REST_PORT));
+                                CLUSTER_ID, NAMESPACE));
+        assertThat(resultEndpoint.get().getPort()).isEqualTo(REST_PORT);
     }
 
     @Test
-    public void testStopAndCleanupCluster() throws Exception {
+    void testStopAndCleanupCluster() throws Exception {
         this.flinkKubeClient.createJobManagerComponent(this.kubernetesJobManagerSpecification);
 
         final KubernetesPod kubernetesPod = buildKubernetesPod(TASKMANAGER_POD_NAME);
         this.flinkKubeClient.createTaskManagerPod(kubernetesPod).get();
 
-        assertEquals(
-                1,
-                this.kubeClient
-                        .apps()
-                        .deployments()
-                        .inNamespace(NAMESPACE)
-                        .list()
-                        .getItems()
-                        .size());
-        assertEquals(
-                1, this.kubeClient.configMaps().inNamespace(NAMESPACE).list().getItems().size());
-        assertEquals(2, this.kubeClient.services().inNamespace(NAMESPACE).list().getItems().size());
-        assertEquals(1, this.kubeClient.pods().inNamespace(NAMESPACE).list().getItems().size());
+        assertThat(
+                        this.kubeClient
+                                .apps()
+                                .deployments()
+                                .inNamespace(NAMESPACE)
+                                .list()
+                                .getItems()
+                                .size())
+                .isEqualTo(1);
+        assertThat(this.kubeClient.configMaps().inNamespace(NAMESPACE).list().getItems().size())
+                .isEqualTo(1);
+        assertThat(this.kubeClient.services().inNamespace(NAMESPACE).list().getItems()).hasSize(2);
+        assertThat(this.kubeClient.pods().inNamespace(NAMESPACE).list().getItems()).hasSize(1);
 
         this.flinkKubeClient.stopAndCleanupCluster(CLUSTER_ID);
-        assertTrue(
-                this.kubeClient
-                        .apps()
-                        .deployments()
-                        .inNamespace(NAMESPACE)
-                        .list()
-                        .getItems()
-                        .isEmpty());
+        assertThat(this.kubeClient.apps().deployments().inNamespace(NAMESPACE).list().getItems())
+                .isEmpty();
     }
 
     @Test
-    public void testCreateConfigMap() throws Exception {
+    void testCreateConfigMap() throws Exception {
         final KubernetesConfigMap configMap = buildTestingConfigMap();
         this.flinkKubeClient.createConfigMap(configMap).get();
         final Optional<KubernetesConfigMap> currentOpt =
                 this.flinkKubeClient.getConfigMap(TESTING_CONFIG_MAP_NAME);
-        assertThat(currentOpt.isPresent(), is(true));
-        assertThat(
-                currentOpt.get().getData().get(TESTING_CONFIG_MAP_KEY),
-                is(TESTING_CONFIG_MAP_VALUE));
+        assertThat(currentOpt).isPresent();
+        assertThat(currentOpt.get().getData())
+                .containsEntry(TESTING_CONFIG_MAP_KEY, TESTING_CONFIG_MAP_VALUE);

Review Comment:
   could be combined to `assertThat(currentOpt).hasValueSatisfying(...)`



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();
         assertThat(
-                flinkPod.getPodWithoutMainContainer()
-                        == copiedFlinkPod.getPodWithoutMainContainer(),
-                is(false));
-        assertThat(
-                flinkPod.getPodWithoutMainContainer(),
-                is(equalTo(copiedFlinkPod.getPodWithoutMainContainer())));
-        assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer(), is(false));
-        assertThat(flinkPod.getMainContainer(), is(equalTo(copiedFlinkPod.getMainContainer())));
+                        flinkPod.getPodWithoutMainContainer()

Review Comment:
   isNotEqualTo



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();
         assertThat(
-                flinkPod.getPodWithoutMainContainer()
-                        == copiedFlinkPod.getPodWithoutMainContainer(),
-                is(false));
-        assertThat(
-                flinkPod.getPodWithoutMainContainer(),
-                is(equalTo(copiedFlinkPod.getPodWithoutMainContainer())));
-        assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer(), is(false));
-        assertThat(flinkPod.getMainContainer(), is(equalTo(copiedFlinkPod.getMainContainer())));
+                        flinkPod.getPodWithoutMainContainer()
+                                == copiedFlinkPod.getPodWithoutMainContainer())
+                .isFalse();
+        assertThat(flinkPod.getPodWithoutMainContainer())
+                .isEqualTo(copiedFlinkPod.getPodWithoutMainContainer());
+        assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer()).isFalse();

Review Comment:
   isNotEqualTo



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();

Review Comment:
   isNotEqualTo



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesPodsWatcherTest.java:
##########
@@ -75,25 +71,23 @@ public void testCallbackHandler() {
         podsWatcher.eventReceived(Watcher.Action.DELETED, pod.getPodWithoutMainContainer());
         podsWatcher.eventReceived(Watcher.Action.ERROR, pod.getPodWithoutMainContainer());
 
-        assertThat(podAddedList.size(), is(1));
-        assertThat(podModifiedList.size(), is(1));
-        assertThat(podDeletedList.size(), is(1));
-        assertThat(podErrorList.size(), is(1));
+        assertThat(podAddedList).hasSize(1);
+        assertThat(podModifiedList).hasSize(1);
+        assertThat(podDeletedList).hasSize(1);
+        assertThat(podErrorList).hasSize(1);
     }
 
     @Test
-    public void testClosingWithTooOldResourceVersion() {
+    void testClosingWithTooOldResourceVersion() {
         final String errMsg = "too old resource version";
         final KubernetesPodsWatcher podsWatcher =
                 new KubernetesPodsWatcher(
                         new TestingCallbackHandler(
                                 e -> {
-                                    assertThat(
-                                            e,
-                                            Matchers.instanceOf(
-                                                    KubernetesTooOldResourceVersionException
-                                                            .class));
-                                    assertThat(e, FlinkMatchers.containsMessage(errMsg));
+                                    assertThat(e)
+                                            .isInstanceOf(
+                                                    KubernetesTooOldResourceVersionException.class);
+                                    assertThat(e).hasMessageContaining(errMsg);

Review Comment:
   ```suggestion
                                       assertThat(e)
                                               .isInstanceOf(
                                                       KubernetesTooOldResourceVersionException.class)
                                               .hasMessageContaining(errMsg);
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesJobManagerParametersTest.java:
##########
@@ -76,16 +72,16 @@ public void testGetEnvironments() {
         final Map<String, String> resultEnvironments =
                 kubernetesJobManagerParameters.getEnvironments();
 
-        assertEquals(expectedEnvironments, resultEnvironments);
+        assertThat(resultEnvironments).isEqualTo(expectedEnvironments);
     }
 
     @Test
-    public void testGetEmptyAnnotations() {
-        assertTrue(kubernetesJobManagerParameters.getAnnotations().isEmpty());
+    void testGetEmptyAnnotations() {
+        assertThat(kubernetesJobManagerParameters.getAnnotations().isEmpty()).isTrue();

Review Comment:
   ```suggestion
           assertThat(kubernetesJobManagerParameters.getAnnotations()).isEmpty();
   ```



##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java:
##########
@@ -571,35 +543,34 @@ public void testCheckAndUpdateConfigMapWhenGetConfigMapFailed() throws Exception
         mockGetConfigMapFailed(configMap.getInternalResource());
 
         final int initialRequestCount = server.getRequestCount();
-        try {
-            this.flinkKubeClient
-                    .checkAndUpdateConfigMap(
-                            TESTING_CONFIG_MAP_NAME,
-                            c -> {
-                                throw new AssertionError(
-                                        "The replace operation should have never been triggered.");
-                            })
-                    .get();
-            fail(
-                    "checkAndUpdateConfigMap should fail without a PossibleInconsistentStateException being the cause when number of retries has been exhausted.");
-        } catch (Exception ex) {
-            assertThat(
-                    ex,
-                    FlinkMatchers.containsMessage(
-                            "Could not complete the "
-                                    + "operation. Number of retries has been exhausted."));
-            final int actualRetryCount = server.getRequestCount() - initialRequestCount;
-            assertThat(actualRetryCount, is(configuredRetries + 1));
-            assertThat(
-                    "An error while retrieving the ConfigMap should not cause a PossibleInconsistentStateException.",
-                    ExceptionUtils.findThrowable(ex, PossibleInconsistentStateException.class)
-                            .isPresent(),
-                    is(false));
-        }
+        assertThatThrownBy(
+                        () ->
+                                this.flinkKubeClient
+                                        .checkAndUpdateConfigMap(
+                                                TESTING_CONFIG_MAP_NAME,
+                                                c -> {
+                                                    throw new AssertionError(
+                                                            "The replace operation should have never been triggered.");
+                                                })
+                                        .get(),
+                        "checkAndUpdateConfigMap should fail without a PossibleInconsistentStateException being the cause when number of retries has been exhausted.")
+                .satisfies(
+                        anyCauseMatches(
+                                "Could not complete the "
+                                        + "operation. Number of retries has been exhausted."))

Review Comment:
   ```suggestion
                                   "Could not complete the operation. Number of retries has been exhausted."))
   ```



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858385410


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();

Review Comment:
   sure



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858281125


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/FlinkPodTest.java:
##########
@@ -23,32 +23,29 @@
 import org.apache.flink.kubernetes.kubeclient.FlinkPod;
 import org.apache.flink.kubernetes.utils.KubernetesUtils;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Tests for {@link FlinkPod}. */
-public class FlinkPodTest extends KubernetesTestBase {
+class FlinkPodTest extends KubernetesTestBase {
 
     @Test
-    public void testCopyFlinkPod() {
+    void testCopyFlinkPod() {
         final FlinkPod flinkPod =
                 KubernetesUtils.loadPodFromTemplateFile(
                         flinkKubeClient,
                         KubernetesPodTemplateTestUtils.getPodTemplateFile(),
                         KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
         final FlinkPod copiedFlinkPod = flinkPod.copy();
-        assertThat(flinkPod == copiedFlinkPod, is(false));
+        assertThat(flinkPod == copiedFlinkPod).isFalse();

Review Comment:
   I think we should use isNotSameAs here.



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1108026337

   @flinkbot run azure


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] flinkbot commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1107809270

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "56f5293f945806959ce2b498251ce586a560abb0",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "56f5293f945806959ce2b498251ce586a560abb0",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 56f5293f945806959ce2b498251ce586a560abb0 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858235227


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -138,7 +139,8 @@ protected void generateKerberosFileItems() throws IOException {
         KubernetesTestUtils.createTemporyFile("some conf", kerberosDir, KRB5_CONF_FILE);
     }
 
-    protected String writeKubeConfigForMockKubernetesServer() throws Exception {
+    protected String writeKubeConfigForMockKubernetesServer(@TempDir Path kubeConfPath)

Review Comment:
   Actually, the method is not use in any place, I wonder if I can delete this method?



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol merged pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol merged PR #19560:
URL: https://github.com/apache/flink/pull/19560


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858437919


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -67,40 +68,47 @@
  * Tests for recovering from savepoint when Kubernetes HA is enabled. The savepoint will be
  * persisted as a checkpoint and stored in the ConfigMap when recovered successfully.
  */
-public class KubernetesHighAvailabilityRecoverFromSavepointITCase extends TestLogger {
+public class KubernetesHighAvailabilityRecoverFromSavepointITCase {
 
     private static final long TIMEOUT = 60 * 1000;
 
     private static final String CLUSTER_ID = "flink-on-k8s-cluster-" + System.currentTimeMillis();
 
     private static final String FLAT_MAP_UID = "my-flat-map";
 
-    @ClassRule public static KubernetesResource kubernetesResource = new KubernetesResource();
+    private static Path temporaryPath;

Review Comment:
   urgh, yeah we don't have a nice solution for this atm. let's keep it as-is.



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] zentol commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858384925


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStoreTest.java:
##########
@@ -399,31 +406,38 @@ public void testReplaceWithDeletingKeyWithFailingDiscard() throws Exception {
                             final TestingLongStateHandleHelper.LongStateHandle newState =
                                     new TestingLongStateHandleHelper.LongStateHandle(23456L);
 
-                            assertThat(store.exists(key), is(StringResourceVersion.notExisting()));
-                            final StateHandleStore.NotExistException exception =
-                                    assertThrows(
-                                            StateHandleStore.NotExistException.class,
+                            assertThat(store.exists(key))
+                                    .isEqualByComparingTo(StringResourceVersion.notExisting());
+                            StateHandleStore.NotExistException exception =
+                                    catchThrowableOfType(

Review Comment:
   use `satisfies()` and pass a consumer that makes the instanceof check.
   ```
   assertThatThrownBy(...)
      .satisfies(ex -> assertThat(ex.isInstangeOf(...)))
   ```



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #19560:
URL: https://github.com/apache/flink/pull/19560#issuecomment-1107846789

   @flinkbot run azure


-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858277262


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java:
##########
@@ -37,18 +36,22 @@
 import io.fabric8.kubernetes.api.model.NamedContextBuilder;
 import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
 import io.fabric8.kubernetes.client.utils.Serialization;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.Map;
 
 /** Base test class for Kubernetes. */
-public class KubernetesTestBase extends TestLogger {
+public class KubernetesTestBase {

Review Comment:
   It shouldn't be possible here, because some classes are not in the same package, but inherit it, such as `KubernetesJobManagerParametersTest` in package `org.apache.flink.kubernetes.kubeclient.parameters`;



-- 
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-unsubscribe@flink.apache.org

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


[GitHub] [flink] reswqa commented on a diff in pull request #19560: [FLINK-25550][k8s] Migrate flink-k8s module's test from junit4 to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #19560:
URL: https://github.com/apache/flink/pull/19560#discussion_r858244786


##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesHighAvailabilityRecoverFromSavepointITCase.java:
##########
@@ -130,19 +139,19 @@ public void testRecoverFromSavepoint() throws Exception {
         assertThat(clusterClient.requestJobResult(jobId).join().isSuccess()).isTrue();
     }
 
-    private Configuration getConfiguration() {
+    private static Configuration getConfiguration() {
         Configuration configuration = new Configuration();
         configuration.set(KubernetesConfigOptions.CLUSTER_ID, CLUSTER_ID);
         configuration.set(
                 HighAvailabilityOptions.HA_MODE,
                 KubernetesHaServicesFactory.class.getCanonicalName());
         try {
-            configuration.set(
-                    HighAvailabilityOptions.HA_STORAGE_PATH,
-                    temporaryFolder.newFolder().getAbsolutePath());
+            temporaryPath = Files.createTempDirectory("haStorage");
         } catch (IOException e) {
-            throw new FlinkRuntimeException("Failed to create HA storage", e);
+            throw new RuntimeException("can't create ha storage path.");

Review Comment:
   Accidentally changed here...



-- 
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-unsubscribe@flink.apache.org

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