public class FlinkContainerTestEnvironment extends Object implements TestEnvironment, ClusterControllable
FlinkContainers
.TestEnvironment.Endpoint
Constructor and Description |
---|
FlinkContainerTestEnvironment(Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
Collection<String> jarPaths) |
FlinkContainerTestEnvironment(Configuration clusterConfiguration,
int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths) |
FlinkContainerTestEnvironment(FlinkContainersSettings settings) |
FlinkContainerTestEnvironment(int numTaskManagers,
int numSlotsPerTaskManager,
String... jarPaths) |
Modifier and Type | Method and Description |
---|---|
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(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(JobClient jobClient,
Runnable afterFailAction)
Triggers a JobManager failover.
|
void |
triggerTaskManagerFailover(JobClient jobClient,
Runnable afterFailAction)
Triggers TaskManager failover.
|
public FlinkContainerTestEnvironment(int numTaskManagers, int numSlotsPerTaskManager, String... jarPaths)
public FlinkContainerTestEnvironment(Configuration clusterConfiguration, int numTaskManagers, int numSlotsPerTaskManager, String... jarPaths)
public FlinkContainerTestEnvironment(Configuration clusterConfiguration, int numTaskManagers, int numSlotsPerTaskManager, Collection<String> jarPaths)
public FlinkContainerTestEnvironment(FlinkContainersSettings settings)
public static FlinkContainerTestEnvironment fromSettings(FlinkContainersSettings settings)
public void startUp() throws Exception
TestResource
The implementation of this method should be idempotent.
startUp
in interface TestResource
Exception
- if anything wrong when starting the resourcepublic void tearDown()
TestResource
The test resource should be able to tear down even without a startup (could be a no-op).
tearDown
in interface TestResource
public StreamExecutionEnvironment createExecutionEnvironment(TestEnvironmentSettings envOptions)
TestEnvironment
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.
createExecutionEnvironment
in interface TestEnvironment
envOptions
- options for the environment to satisfypublic TestEnvironment.Endpoint getRestEndpoint()
TestEnvironment
getRestEndpoint
in interface TestEnvironment
public String getCheckpointUri()
TestEnvironment
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.
getCheckpointUri
in interface TestEnvironment
public void triggerJobManagerFailover(JobClient jobClient, Runnable afterFailAction) throws Exception
ClusterControllable
triggerJobManagerFailover
in interface ClusterControllable
jobClient
- client of the running jobafterFailAction
- action to take before restarting the JobManagerException
public void triggerTaskManagerFailover(JobClient jobClient, Runnable afterFailAction) throws Exception
ClusterControllable
triggerTaskManagerFailover
in interface ClusterControllable
jobClient
- client of the running jobafterFailAction
- action to take before restarting TaskManager(s)Exception
public void isolateNetwork(JobClient jobClient, Runnable afterFailAction)
ClusterControllable
isolateNetwork
in interface ClusterControllable
jobClient
- client of the running jobafterFailAction
- action to take before recovering the network connectionpublic FlinkContainers getFlinkContainers()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.