public class FlinkContainerTestEnvironment extends Object implements TestEnvironment, ClusterControllable
FlinkContainers.TestEnvironment.Endpoint| Constructor and Description |
|---|
FlinkContainerTestEnvironment(org.apache.flink.configuration.Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
Collection<String> jarPaths) |
FlinkContainerTestEnvironment(org.apache.flink.configuration.Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths) |
FlinkContainerTestEnvironment(FlinkContainersSettings settings) |
FlinkContainerTestEnvironment(int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths) |
| 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. |
static FlinkContainerTestEnvironment |
fromSettings(FlinkContainersSettings settings) |
String |
getCheckpointUri()
Get a path in string for storing checkpoint and savepoint in the test environment.
|
FlinkContainers |
getFlinkContainers()
Get instance of Flink containers for cluster controlling.
|
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 FlinkContainerTestEnvironment(int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths)
public FlinkContainerTestEnvironment(org.apache.flink.configuration.Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths)
public FlinkContainerTestEnvironment(org.apache.flink.configuration.Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
Collection<String> jarPaths)
public FlinkContainerTestEnvironment(FlinkContainersSettings settings)
public static FlinkContainerTestEnvironment fromSettings(FlinkContainersSettings settings)
public 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()
TestResourceThe test resource should be able to tear down even without a startup (could be a no-op).
tearDown in interface TestResourcepublic 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 Exception
ClusterControllabletriggerJobManagerFailover in interface ClusterControllablejobClient - client of the running jobafterFailAction - action to take before restarting the JobManagerExceptionpublic 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 FlinkContainers getFlinkContainers()
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.