Class MiniClusterTestEnvironment

    • Constructor Detail

      • MiniClusterTestEnvironment

        public MiniClusterTestEnvironment()
      • MiniClusterTestEnvironment

        public MiniClusterTestEnvironment​(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration conf)
    • Method Detail

      • createExecutionEnvironment

        public org.apache.flink.streaming.api.environment.StreamExecutionEnvironment createExecutionEnvironment​(TestEnvironmentSettings envOptions)
        Description copied from interface: TestEnvironment
        Get an instance of StreamExecutionEnvironment for building and executing Flink jobs based on the provided configuration.

        Note that this environment should be bound with the Flink cluster, because this will be the entrypoint to submit Flink jobs (via StreamExecutionEnvironment.execute()) in test cases.

        Specified by:
        createExecutionEnvironment in interface TestEnvironment
        Parameters:
        envOptions - options for the environment to satisfy
      • getCheckpointUri

        public String getCheckpointUri()
        Description copied from interface: TestEnvironment
        Get a path in string for storing checkpoint and savepoint in the test environment.

        Note that testing framework may have no access to this storage (e.g. Flink cluster is on some cloud service and testing framework is executed locally). In test cases for testing failover scenario, this path will be passed to cluster client directly for triggering checkpoint / savepoint in this path and recovering from checkpoint / savepoint stored under this path.

        Specified by:
        getCheckpointUri in interface TestEnvironment
      • triggerTaskManagerFailover

        public void triggerTaskManagerFailover​(org.apache.flink.core.execution.JobClient jobClient,
                                               Runnable afterFailAction)
                                        throws Exception
        Description copied from interface: ClusterControllable
        Triggers TaskManager failover.
        Specified by:
        triggerTaskManagerFailover in interface ClusterControllable
        Parameters:
        jobClient - client of the running job
        afterFailAction - action to take before restarting TaskManager(s)
        Throws:
        Exception
      • isolateNetwork

        public void isolateNetwork​(org.apache.flink.core.execution.JobClient jobClient,
                                   Runnable afterFailAction)
        Description copied from interface: ClusterControllable
        Disconnect network between Flink cluster and external system.
        Specified by:
        isolateNetwork in interface ClusterControllable
        Parameters:
        jobClient - client of the running job
        afterFailAction - action to take before recovering the network connection
      • startUp

        public void startUp()
                     throws Exception
        Description copied from interface: TestResource
        Start up the test resource.

        The implementation of this method should be idempotent.

        Specified by:
        startUp in interface TestResource
        Throws:
        Exception - if anything wrong when starting the resource
      • tearDown

        public void tearDown()
                      throws Exception
        Description copied from interface: TestResource
        Tear down the test resource.

        The test resource should be able to tear down even without a startup (could be a no-op).

        Specified by:
        tearDown in interface TestResource
        Throws:
        Exception - if anything wrong when tearing the resource down