Package org.apache.flink.test.util
Class TestUtils
- java.lang.Object
-
- org.apache.flink.test.util.TestUtils
-
public class TestUtils extends Object
Test utilities.
-
-
Constructor Summary
Constructors Constructor Description TestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static File
getMostRecentCompletedCheckpoint(File checkpointDir)
Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#getLatestCompletedCheckpointPath(JobID, MiniCluster)
which is less prone toNoSuchFileException
and IO-intensive.static Optional<File>
getMostRecentCompletedCheckpointMaybe(File checkpointDir)
Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#getLatestCompletedCheckpointPath(JobID, MiniCluster)
which is less prone toNoSuchFileException
and IO-intensive.static CheckpointMetadata
loadCheckpointMetadata(String savepointPath)
static void
submitJobAndWaitForResult(ClusterClient<?> client, JobGraph jobGraph, ClassLoader classLoader)
static void
tryExecute(StreamExecutionEnvironment see, String name)
Execute the job and wait for the job result synchronously.static void
waitUntil(Supplier<Boolean> condition, String message)
Wait util the give condition is met or timeout is reached, whichever comes first.static void
waitUntil(Supplier<Boolean> condition, Duration timeout, String message)
Wait util the give condition is met or timeout is reached, whichever comes first.static void
waitUntilAllTasksAreRunning(RestClusterClient<?> restClusterClient, JobID jobId)
Wait util all task of a job turns into RUNNING state.static void
waitUntilExternalizedCheckpointCreated(File checkpointDir)
Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#waitForCheckpoint(JobID, MiniCluster, Deadline)
which is less prone toNoSuchFileException
and IO-intensive.static void
waitUntilJobCanceled(JobID jobId, ClusterClient<?> client)
-
-
-
Method Detail
-
tryExecute
public static void tryExecute(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 haveSuccessException
as a cause.
-
submitJobAndWaitForResult
public static void submitJobAndWaitForResult(ClusterClient<?> client, JobGraph jobGraph, ClassLoader classLoader) throws Exception
- Throws:
Exception
-
loadCheckpointMetadata
public static CheckpointMetadata loadCheckpointMetadata(String savepointPath) throws IOException
- Throws:
IOException
-
getMostRecentCompletedCheckpoint
@Deprecated public static File getMostRecentCompletedCheckpoint(File checkpointDir) throws IOException
Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#getLatestCompletedCheckpointPath(JobID, MiniCluster)
which is less prone toNoSuchFileException
and IO-intensive.- Throws:
IOException
-
getMostRecentCompletedCheckpointMaybe
@Deprecated public static Optional<File> getMostRecentCompletedCheckpointMaybe(File checkpointDir) throws IOException
Deprecated.please useorg.apache.flink.runtime.testutils.CommonTestUtils#getLatestCompletedCheckpointPath(JobID, MiniCluster)
which is less prone toNoSuchFileException
and 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 toNoSuchFileException
and IO-intensive.- Throws:
InterruptedException
IOException
-
waitUntilJobCanceled
public static void waitUntilJobCanceled(JobID jobId, ClusterClient<?> client) throws ExecutionException, InterruptedException
-
waitUntilAllTasksAreRunning
public static void waitUntilAllTasksAreRunning(RestClusterClient<?> restClusterClient, 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.
-
-