diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClientTestBase.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClientTestBase.java index beed8493a6327..6459a88133d0d 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClientTestBase.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClientTestBase.java @@ -30,7 +30,6 @@ import io.fabric8.kubernetes.api.model.ServicePortBuilder; import io.fabric8.kubernetes.api.model.ServiceStatus; import io.fabric8.kubernetes.api.model.ServiceStatusBuilder; -import org.junit.Before; import javax.annotation.Nullable; @@ -45,11 +44,6 @@ public class KubernetesClientTestBase extends KubernetesTestBase { protected static final int REST_PORT = 9021; protected static final int NODE_PORT = 31234; - @Before - public void setup() throws Exception { - super.setup(); - } - protected void mockExpectedServiceFromServerSide(Service expectedService) { final String serviceName = expectedService.getMetadata().getName(); final String path = String.format("/api/v1/namespaces/%s/services/%s", NAMESPACE, serviceName); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClusterDescriptorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClusterDescriptorTest.java index f82bfdc4a4740..6fab70194d57e 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClusterDescriptorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClusterDescriptorTest.java @@ -38,7 +38,6 @@ import io.fabric8.kubernetes.api.model.EnvVar; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.apps.Deployment; -import org.junit.Before; import org.junit.Test; import java.util.Arrays; @@ -66,9 +65,9 @@ public class KubernetesClusterDescriptorTest extends KubernetesClientTestBase { private KubernetesClusterDescriptor descriptor; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); descriptor = new KubernetesClusterDescriptor(flinkConfig, flinkKubeClient); } diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerTest.java index 5dc445c911e9e..a1d034b05119b 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerTest.java @@ -81,7 +81,6 @@ import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import org.hamcrest.Matchers; import org.junit.Assert; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -122,9 +121,9 @@ protected void setupFlinkConfig() { flinkConfig.setString(TaskManagerOptions.RPC_PORT, String.valueOf(Constants.TASK_MANAGER_RPC_PORT)); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + public void onSetup() throws Exception { + super.onSetup(); final Deployment mockDeployment = new DeploymentBuilder() .editOrNewMetadata() diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java index f29b15d4b12e6..dc088528a805f 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesTestBase.java @@ -79,8 +79,11 @@ protected void setupFlinkConfig() { flinkConfig.set(JobManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(JOB_MANAGER_MEMORY)); } + protected void onSetup() throws Exception { + } + @Before - public void setup() throws Exception { + public final void setup() throws Exception { setupFlinkConfig(); flinkConfDir = temporaryFolder.newFolder().getAbsoluteFile(); @@ -94,6 +97,8 @@ public void setup() throws Exception { kubeClient = server.getClient().inNamespace(NAMESPACE); flinkKubeClient = new Fabric8FlinkKubeClient(flinkConfig, kubeClient, Executors::newDirectExecutorService); + + onSetup(); } @After diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java index c69f8eec4e8ef..bb7a0b612756c 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClientTest.java @@ -38,7 +38,6 @@ import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.apps.Deployment; -import org.junit.Before; import org.junit.Test; import java.util.List; @@ -83,9 +82,9 @@ protected void setupFlinkConfig() { flinkConfig.set(KubernetesConfigOptions.JOB_MANAGER_SERVICE_ACCOUNT, SERVICE_ACCOUNT_NAME); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "logback.xml"); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "log4j.properties"); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesJobManagerTestBase.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesJobManagerTestBase.java index d3618c04cf682..3fdb1aab31fd6 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesJobManagerTestBase.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesJobManagerTestBase.java @@ -28,8 +28,6 @@ import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions; import org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters; -import org.junit.Before; - import java.util.HashMap; import java.util.Map; @@ -87,10 +85,8 @@ protected void setupFlinkConfig() { this.flinkConfig.set(JobManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(JOB_MANAGER_MEMORY)); } - @Before - public void setup() throws Exception { - super.setup(); - + @Override + protected void onSetup() throws Exception { final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder() .setMasterMemoryMB(JOB_MANAGER_MEMORY) .setTaskManagerMemoryMB(1024) diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesTaskManagerTestBase.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesTaskManagerTestBase.java index 28a7f386260c2..e71b52b28f126 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesTaskManagerTestBase.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/KubernetesTaskManagerTestBase.java @@ -28,8 +28,6 @@ import org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec; import org.apache.flink.runtime.clusterframework.TaskExecutorProcessUtils; -import org.junit.Before; - import java.util.HashMap; import java.util.Map; @@ -88,10 +86,8 @@ protected void setupFlinkConfig() { this.flinkConfig.set(KubernetesConfigOptions.TASK_MANAGER_NODE_SELECTOR, nodeSelector); } - @Before - public void setup() throws Exception { - super.setup(); - + @Override + protected void onSetup() throws Exception { taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromConfig(flinkConfig); containeredTaskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, taskExecutorProcessSpec); kubernetesTaskManagerParameters = new KubernetesTaskManagerParameters( diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/ExternalServiceDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/ExternalServiceDecoratorTest.java index 1d47ddf9cf343..66ed88e14608d 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/ExternalServiceDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/ExternalServiceDecoratorTest.java @@ -27,7 +27,6 @@ import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServicePort; import io.fabric8.kubernetes.api.model.ServicePortBuilder; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -55,9 +54,9 @@ public class ExternalServiceDecoratorTest extends KubernetesJobManagerTestBase { } }; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); this.flinkConfig.set(KubernetesConfigOptions.REST_SERVICE_ANNOTATIONS, customizedAnnotations); this.externalServiceDecorator = new ExternalServiceDecorator(this.kubernetesJobManagerParameters); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/FlinkConfMountDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/FlinkConfMountDecoratorTest.java index 4b776d77a3a89..da5069f7b76ef 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/FlinkConfMountDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/FlinkConfMountDecoratorTest.java @@ -33,7 +33,6 @@ import io.fabric8.kubernetes.api.model.VolumeBuilder; import io.fabric8.kubernetes.api.model.VolumeMount; import io.fabric8.kubernetes.api.model.VolumeMountBuilder; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -63,9 +62,9 @@ protected void setupFlinkConfig() { this.flinkConfig.set(KubernetesConfigOptions.FLINK_CONF_DIR, FLINK_CONF_DIR_IN_POD); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); this.flinkConfMountDecorator = new FlinkConfMountDecorator(kubernetesJobManagerParameters); } diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/HadoopConfMountDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/HadoopConfMountDecoratorTest.java index 8c7517908e7bb..fc4cb4f9ec086 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/HadoopConfMountDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/HadoopConfMountDecoratorTest.java @@ -30,7 +30,6 @@ import io.fabric8.kubernetes.api.model.KeyToPath; import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeMount; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -52,9 +51,10 @@ public class HadoopConfMountDecoratorTest extends KubernetesJobManagerTestBase { private HadoopConfMountDecorator hadoopConfMountDecorator; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); + this.hadoopConfMountDecorator = new HadoopConfMountDecorator(kubernetesJobManagerParameters); } diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorTest.java index 4a78919a070d3..7b5bbec115e28 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorTest.java @@ -34,7 +34,6 @@ import io.fabric8.kubernetes.api.model.ResourceRequirements; import io.fabric8.kubernetes.api.model.Toleration; import org.hamcrest.Matchers; -import org.junit.Before; import org.junit.Test; import java.util.Arrays; @@ -81,9 +80,9 @@ protected void setupFlinkConfig() { this.flinkConfig.setString(KubernetesConfigOptions.JOB_MANAGER_TOLERATIONS.key(), TOLERATION_STRING); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); final InitJobManagerDecorator initJobManagerDecorator = new InitJobManagerDecorator(this.kubernetesJobManagerParameters); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitTaskManagerDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitTaskManagerDecoratorTest.java index f94462a5d135d..23f87befc6512 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitTaskManagerDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitTaskManagerDecoratorTest.java @@ -33,7 +33,6 @@ import io.fabric8.kubernetes.api.model.ResourceRequirements; import io.fabric8.kubernetes.api.model.Toleration; import org.hamcrest.Matchers; -import org.junit.Before; import org.junit.Test; import java.util.Arrays; @@ -78,9 +77,9 @@ protected void setupFlinkConfig() { this.flinkConfig.setString(KubernetesConfigOptions.TASK_MANAGER_TOLERATIONS.key(), TOLERATION_STRING); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); final InitTaskManagerDecorator initTaskManagerDecorator = new InitTaskManagerDecorator(kubernetesTaskManagerParameters); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InternalServiceDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InternalServiceDecoratorTest.java index f0f79ede490a6..1bafc133cc9e4 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InternalServiceDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InternalServiceDecoratorTest.java @@ -29,7 +29,6 @@ import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServicePort; import io.fabric8.kubernetes.api.model.ServicePortBuilder; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -47,9 +46,10 @@ public class InternalServiceDecoratorTest extends KubernetesJobManagerTestBase { private InternalServiceDecorator internalServiceDecorator; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); + this.internalServiceDecorator = new InternalServiceDecorator(this.kubernetesJobManagerParameters); } diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdJobManagerDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdJobManagerDecoratorTest.java index a220ecb6f7351..f236d473246c4 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdJobManagerDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdJobManagerDecoratorTest.java @@ -29,7 +29,6 @@ import org.apache.flink.runtime.util.config.memory.ProcessMemoryUtils; import io.fabric8.kubernetes.api.model.Container; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -80,9 +79,9 @@ protected void setupFlinkConfig() { flinkConfig.set(KubernetesConfigOptions.KUBERNETES_ENTRY_PATH, KUBERNETES_ENTRY_PATH); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); this.javaCmdJobManagerDecorator = new JavaCmdJobManagerDecorator(kubernetesJobManagerParameters); } diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdTaskManagerDecoratorTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdTaskManagerDecoratorTest.java index 83108ff80c987..41ec6c66d016c 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdTaskManagerDecoratorTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdTaskManagerDecoratorTest.java @@ -27,7 +27,6 @@ import org.apache.flink.runtime.clusterframework.TaskExecutorProcessUtils; import io.fabric8.kubernetes.api.model.Container; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -80,9 +79,9 @@ protected void setupFlinkConfig() { flinkConfig.set(KubernetesConfigOptions.FLINK_LOG_DIR, FLINK_LOG_DIR_IN_POD); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + public void onSetup() throws Exception { + super.onSetup(); this.mainClassArgs = String.format( "%s--configDir %s", diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesJobManagerFactoryTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesJobManagerFactoryTest.java index 9b3208db87db4..96a3f73c8732a 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesJobManagerFactoryTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesJobManagerFactoryTest.java @@ -38,7 +38,6 @@ import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentSpec; -import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -74,9 +73,9 @@ protected void setupFlinkConfig() { flinkConfig.set(KubernetesConfigOptions.JOB_MANAGER_SERVICE_ACCOUNT, SERVICE_ACCOUNT_NAME); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "logback.xml"); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "log4j.properties"); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesTaskManagerFactoryTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesTaskManagerFactoryTest.java index d0716b397fcf8..cc7f57d1dd3c7 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesTaskManagerFactoryTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesTaskManagerFactoryTest.java @@ -24,7 +24,6 @@ import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.Pod; -import org.junit.Before; import org.junit.Test; import java.util.List; @@ -39,9 +38,9 @@ public class KubernetesTaskManagerFactoryTest extends KubernetesTaskManagerTestB private Pod resultPod; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "logback.xml"); KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, "log4j.properties"); diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesTaskManagerParametersTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesTaskManagerParametersTest.java index b3ae37db8c24a..62c6127466443 100644 --- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesTaskManagerParametersTest.java +++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesTaskManagerParametersTest.java @@ -28,7 +28,6 @@ import org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec; import org.apache.flink.runtime.clusterframework.TaskExecutorProcessUtils; -import org.junit.Before; import org.junit.Test; import java.util.HashMap; @@ -73,9 +72,9 @@ protected void setupFlinkConfig() { flinkConfig.setString(ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX + k, v)); } - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void onSetup() throws Exception { + super.onSetup(); final TaskExecutorProcessSpec taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromConfig(flinkConfig);