Class MiniClusterTestEnvironment
- java.lang.Object
-
- org.apache.flink.connector.testframe.environment.MiniClusterTestEnvironment
-
- All Implemented Interfaces:
ClusterControllable,TestEnvironment,TestResource
@Experimental public class MiniClusterTestEnvironment extends Object implements TestEnvironment, ClusterControllable
Test environment for running jobs on Flink mini-cluster.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.connector.testframe.environment.TestEnvironment
TestEnvironment.Endpoint
-
-
Constructor Summary
Constructors Constructor Description MiniClusterTestEnvironment()MiniClusterTestEnvironment(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration conf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentcreateExecutionEnvironment(TestEnvironmentSettings envOptions)Get an instance ofStreamExecutionEnvironmentfor building and executing Flink jobs based on the provided configuration.StringgetCheckpointUri()Get a path in string for storing checkpoint and savepoint in the test environment.TestEnvironment.EndpointgetRestEndpoint()Get endpoint of the test environment for connecting via REST API.voidisolateNetwork(org.apache.flink.core.execution.JobClient jobClient, Runnable afterFailAction)Disconnect network between Flink cluster and external system.voidstartUp()Start up the test resource.voidtearDown()Tear down the test resource.StringtoString()voidtriggerJobManagerFailover(org.apache.flink.core.execution.JobClient jobClient, Runnable afterFailAction)Triggers a JobManager failover.voidtriggerTaskManagerFailover(org.apache.flink.core.execution.JobClient jobClient, Runnable afterFailAction)Triggers TaskManager failover.
-
-
-
Method Detail
-
createExecutionEnvironment
public org.apache.flink.streaming.api.environment.StreamExecutionEnvironment createExecutionEnvironment(TestEnvironmentSettings envOptions)
Description copied from interface:TestEnvironmentGet an instance ofStreamExecutionEnvironmentfor 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:
createExecutionEnvironmentin interfaceTestEnvironment- Parameters:
envOptions- options for the environment to satisfy
-
getRestEndpoint
public TestEnvironment.Endpoint getRestEndpoint()
Description copied from interface:TestEnvironmentGet endpoint of the test environment for connecting via REST API.- Specified by:
getRestEndpointin interfaceTestEnvironment
-
getCheckpointUri
public String getCheckpointUri()
Description copied from interface:TestEnvironmentGet 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:
getCheckpointUriin interfaceTestEnvironment
-
triggerJobManagerFailover
public void triggerJobManagerFailover(org.apache.flink.core.execution.JobClient jobClient, Runnable afterFailAction) throws ExecutionException, InterruptedExceptionDescription copied from interface:ClusterControllableTriggers a JobManager failover.- Specified by:
triggerJobManagerFailoverin interfaceClusterControllable- Parameters:
jobClient- client of the running jobafterFailAction- action to take before restarting the JobManager- Throws:
ExecutionExceptionInterruptedException
-
triggerTaskManagerFailover
public void triggerTaskManagerFailover(org.apache.flink.core.execution.JobClient jobClient, Runnable afterFailAction) throws ExceptionDescription copied from interface:ClusterControllableTriggers TaskManager failover.- Specified by:
triggerTaskManagerFailoverin interfaceClusterControllable- Parameters:
jobClient- client of the running jobafterFailAction- 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:ClusterControllableDisconnect network between Flink cluster and external system.- Specified by:
isolateNetworkin interfaceClusterControllable- Parameters:
jobClient- client of the running jobafterFailAction- action to take before recovering the network connection
-
startUp
public void startUp() throws ExceptionDescription copied from interface:TestResourceStart up the test resource.The implementation of this method should be idempotent.
- Specified by:
startUpin interfaceTestResource- Throws:
Exception- if anything wrong when starting the resource
-
tearDown
public void tearDown() throws ExceptionDescription copied from interface:TestResourceTear down the test resource.The test resource should be able to tear down even without a startup (could be a no-op).
- Specified by:
tearDownin interfaceTestResource- Throws:
Exception- if anything wrong when tearing the resource down
-
-