flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-7909) Unify cluster creation for test bases
Date Thu, 21 Dec 2017 12:29:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-7909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16299942#comment-16299942
] 

ASF GitHub Bot commented on FLINK-7909:
---------------------------------------

Github user GJL commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4896#discussion_r158265225
  
    --- 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);
    --- End diff --
    
    Maybe `protected final Logger log = LoggerFactory.getLogger(getClass());` so that the
class name of the implementation is logged.


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

Mime
View raw message