[
https://issues.apache.org/jira/browse/FLINK-7909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16316405#comment-16316405
]
ASF GitHub Bot commented on FLINK-7909:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/4896#discussion_r160156245
--- Diff:
flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
---
@@ -19,81 +19,61 @@
package org.apache.flink.test.util;
import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster;
import org.apache.flink.util.FileUtils;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
-import java.util.Objects;
-
-import scala.concurrent.duration.FiniteDuration;
/**
- * A base class for tests that run test programs in a Flink mini cluster.
+ * Base class for unit tests that run multiple tests and want to reuse the
same
+ * Flink cluster. This saves a significant amount of time, since the
startup and
+ * shutdown of the Flink clusters (including actor systems, etc) usually
dominates
+ * the execution of the actual tests.
+ *
+ * <p>To write a unit test against this test base, simply extend it and add
+ * one or more regular test methods and retrieve the
StreamExecutionEnvironment from
+ * the context:
+ *
+ * <pre>
+ * {@literal @}Test
+ * public void someTest() {
+ * ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+ * // test code
+ * env.execute();
+ * }
+ *
+ * {@literal @}Test
+ * public void anotherTest() {
+ * StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+ * // test code
+ * env.execute();
+ * }
+ *
+ * </pre>
*/
public abstract class AbstractTestBase extends TestBaseUtils {
- /** Configuration to start the testing cluster with. */
- protected final Configuration config;
+ protected static final Logger LOG =
LoggerFactory.getLogger(AbstractTestBase.class);
- private final FiniteDuration timeout;
+ private static final int DEFAULT_PARALLELISM = 4;
- protected int taskManagerNumSlots = 1;
+ protected static final Configuration MINICLUSTER_CONFIGURATION = new
Configuration();
--- End diff --
You're right. This is bad and I'll fix it.
> Unify cluster creation for test bases
> -------------------------------------
>
> Key: FLINK-7909
> URL: https://issues.apache.org/jira/browse/FLINK-7909
> Project: Flink
> Issue Type: Improvement
> Components: Tests
> Affects Versions: 1.4.0
> Reporter: Till Rohrmann
> Assignee: Till Rohrmann
>
> Flink contains different test bases, e.g. {{AbstractTestBase}},
> {{MultipleProgramsTestBase}}, {{JavaProgramTestBase}} and the
> {{StreamingMultipleProgramsTestBase}}. Some of them start resources
> ({{FlinkMiniCluster}}) automatically, while others expose a start method.
> Some test bases set the {{ExecutionEnvironment}} while others use the
> {{FlinkMiniCluster}} directly. In order to make things more maintainable I
> propose to unify these test bases a bit and introduce an {{ExternalResource}}
> which encapsulates the resource start up and shut down.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)