Class TestUtils

java.lang.Object
org.apache.flink.test.util.TestUtils

public class TestUtils extends Object
Test utilities.
  • 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 have SuccessException as 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 use CommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster) which is less prone to NoSuchFileException and IO-intensive.
      Throws:
      IOException
    • getMostRecentCompletedCheckpointMaybe

      @Deprecated public static Optional<File> getMostRecentCompletedCheckpointMaybe(File checkpointDir) throws IOException
      Deprecated.
      please use CommonTestUtils.getLatestCompletedCheckpointPath(JobID, MiniCluster) which is less prone to NoSuchFileException and IO-intensive.
      Throws:
      IOException
    • waitUntilExternalizedCheckpointCreated

      @Deprecated public static void waitUntilExternalizedCheckpointCreated(File checkpointDir) throws InterruptedException, IOException
      Deprecated.
      please use org.apache.flink.runtime.testutils.CommonTestUtils#waitForCheckpoint(JobID, MiniCluster, Deadline) which is less prone to NoSuchFileException and IO-intensive.
      Throws:
      InterruptedException
      IOException
    • waitUntilJobCanceled

      public static void waitUntilJobCanceled(org.apache.flink.api.common.JobID jobId, org.apache.flink.client.program.ClusterClient<?> client) throws ExecutionException, InterruptedException
      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 be InjectClusterClient.
      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.