@Experimental public class MiniClusterTestEnvironment extends Object implements TestEnvironment, ClusterControllable
TestEnvironment.Endpoint| Constructor and Description |
|---|
MiniClusterTestEnvironment() |
MiniClusterTestEnvironment(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration conf) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment |
createExecutionEnvironment(TestEnvironmentSettings envOptions)
Get an instance of
StreamExecutionEnvironment for building and executing Flink jobs
based on the provided configuration. |
String |
getCheckpointUri()
Get a path in string for storing checkpoint and savepoint in the test environment.
|
TestEnvironment.Endpoint |
getRestEndpoint()
Get endpoint of the test environment for connecting via REST API.
|
void |
isolateNetwork(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
Disconnect network between Flink cluster and external system.
|
void |
startUp()
Start up the test resource.
|
void |
tearDown()
Tear down the test resource.
|
String |
toString() |
void |
triggerJobManagerFailover(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
Triggers a JobManager failover.
|
void |
triggerTaskManagerFailover(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
Triggers TaskManager failover.
|
public MiniClusterTestEnvironment()
public MiniClusterTestEnvironment(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration conf)
public org.apache.flink.streaming.api.environment.StreamExecutionEnvironment createExecutionEnvironment(TestEnvironmentSettings envOptions)
TestEnvironmentStreamExecutionEnvironment 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.
createExecutionEnvironment in interface TestEnvironmentenvOptions - options for the environment to satisfypublic TestEnvironment.Endpoint getRestEndpoint()
TestEnvironmentgetRestEndpoint in interface TestEnvironmentpublic String getCheckpointUri()
TestEnvironmentNote 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.
getCheckpointUri in interface TestEnvironmentpublic void triggerJobManagerFailover(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
throws ExecutionException,
InterruptedException
ClusterControllabletriggerJobManagerFailover in interface ClusterControllablejobClient - client of the running jobafterFailAction - action to take before restarting the JobManagerExecutionExceptionInterruptedExceptionpublic void triggerTaskManagerFailover(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
throws Exception
ClusterControllabletriggerTaskManagerFailover in interface ClusterControllablejobClient - client of the running jobafterFailAction - action to take before restarting TaskManager(s)Exceptionpublic void isolateNetwork(org.apache.flink.core.execution.JobClient jobClient,
Runnable afterFailAction)
ClusterControllableisolateNetwork in interface ClusterControllablejobClient - client of the running jobafterFailAction - action to take before recovering the network connectionpublic void startUp()
throws Exception
TestResourceThe implementation of this method should be idempotent.
startUp in interface TestResourceException - if anything wrong when starting the resourcepublic void tearDown()
throws Exception
TestResourceThe test resource should be able to tear down even without a startup (could be a no-op).
tearDown in interface TestResourceException - if anything wrong when tearing the resource downCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.