Package org.apache.flink.test.util
Class TestUtils
java.lang.Object
org.apache.flink.test.util.TestUtils
Test utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FilegetMostRecentCompletedCheckpoint(File checkpointDir) Deprecated.getMostRecentCompletedCheckpointMaybe(File checkpointDir) Deprecated.please useCommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster)which is less prone toNoSuchFileExceptionand IO-intensive.static org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadataloadCheckpointMetadata(String savepointPath) static voidsubmitJobAndWaitForResult(org.apache.flink.client.program.ClusterClient<?> client, org.apache.flink.runtime.jobgraph.JobGraph jobGraph, ClassLoader classLoader) static voidtryExecute(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment see, String name) Execute the job and wait for the job result synchronously.static voidWait util the give condition is met or timeout is reached, whichever comes first.static voidWait util the give condition is met or timeout is reached, whichever comes first.static voidwaitUntilAllTasksAreRunning(org.apache.flink.client.program.rest.RestClusterClient<?> restClusterClient, org.apache.flink.api.common.JobID jobId) Wait util all task of a job turns into RUNNING state.static voidwaitUntilExternalizedCheckpointCreated(File checkpointDir) Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#waitForCheckpoint(JobID, MiniCluster, Deadline)which is less prone toNoSuchFileExceptionand IO-intensive.static voidwaitUntilJobCanceled(org.apache.flink.api.common.JobID jobId, org.apache.flink.client.program.ClusterClient<?> client)
-
Constructor Details
-
TestUtils
public TestUtils()
-
-
Method Details
-
tryExecute
public static void tryExecute(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment see, String name) throws Exception Execute the job and wait for the job result synchronously.- Throws:
Exception- If executing the environment throws an exception which does not haveSuccessExceptionas a cause.
-
submitJobAndWaitForResult
public static void submitJobAndWaitForResult(org.apache.flink.client.program.ClusterClient<?> client, org.apache.flink.runtime.jobgraph.JobGraph jobGraph, ClassLoader classLoader) throws Exception - Throws:
Exception
-
loadCheckpointMetadata
public static org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata loadCheckpointMetadata(String savepointPath) throws IOException - Throws:
IOException
-
getMostRecentCompletedCheckpoint
@Deprecated public static File getMostRecentCompletedCheckpoint(File checkpointDir) throws IOException Deprecated.please useCommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster)which is less prone toNoSuchFileExceptionand IO-intensive.- Throws:
IOException
-
getMostRecentCompletedCheckpointMaybe
@Deprecated public static Optional<File> getMostRecentCompletedCheckpointMaybe(File checkpointDir) throws IOException Deprecated.please useCommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster)which is less prone toNoSuchFileExceptionand IO-intensive.- Throws:
IOException
-
waitUntilExternalizedCheckpointCreated
@Deprecated public static void waitUntilExternalizedCheckpointCreated(File checkpointDir) throws InterruptedException, IOException Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#waitForCheckpoint(JobID, MiniCluster, Deadline)which is less prone toNoSuchFileExceptionand IO-intensive.- Throws:
InterruptedExceptionIOException
-
waitUntilJobCanceled
public static void waitUntilJobCanceled(org.apache.flink.api.common.JobID jobId, org.apache.flink.client.program.ClusterClient<?> client) throws ExecutionException, InterruptedException -
waitUntilAllTasksAreRunning
public static void waitUntilAllTasksAreRunning(org.apache.flink.client.program.rest.RestClusterClient<?> restClusterClient, org.apache.flink.api.common.JobID jobId) throws Exception Wait util all task of a job turns into RUNNING state.- Parameters:
restClusterClient- RestClusterClient which could beInjectClusterClient.- Throws:
Exception
-
waitUntil
public static void waitUntil(Supplier<Boolean> condition, String message) throws InterruptedException, TimeoutException Wait util the give condition is met or timeout is reached, whichever comes first.- Parameters:
condition- the condition to meet.message- the message to show if the condition is not met before timeout.- Throws:
InterruptedException- when the thread is interrupted when waiting for the condition.TimeoutException- when the condition is not met after the specified timeout has elapsed.
-
waitUntil
public static void waitUntil(Supplier<Boolean> condition, Duration timeout, String message) throws InterruptedException, TimeoutException Wait util the give condition is met or timeout is reached, whichever comes first.- Parameters:
condition- the condition to meet.timeout- the maximum time to wait for the condition to become true.message- the message to show if the condition is not met before timeout.- Throws:
InterruptedException- when the thread is interrupted when waiting for the condition.TimeoutException- when the condition is not met after the specified timeout has elapsed.
-
CommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster)which is less prone toNoSuchFileExceptionand IO-intensive.