Search in sources :

Example 96 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobMasterServiceLeadershipRunnerTest method testResultFutureCompletionOfOutdatedLeaderIsIgnored.

@Test
public void testResultFutureCompletionOfOutdatedLeaderIsIgnored() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> resultFuture = new CompletableFuture<>();
    final JobMasterServiceLeadershipRunner jobManagerRunner = newJobMasterServiceLeadershipRunnerBuilder().withSingleJobMasterServiceProcess(TestingJobMasterServiceProcess.newBuilder().setJobManagerRunnerResultFuture(resultFuture).build()).build();
    jobManagerRunner.start();
    leaderElectionService.isLeader(UUID.randomUUID()).join();
    leaderElectionService.notLeader();
    resultFuture.complete(JobManagerRunnerResult.forSuccess(createFailedExecutionGraphInfo(new FlinkException("test exception"))));
    assertThat(jobManagerRunner.getResultFuture(), willNotComplete(Duration.ofMillis(5L)));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 97 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobResultTest method testCancelledJobThrowsJobCancellationException.

@Test
public void testCancelledJobThrowsJobCancellationException() throws Exception {
    final FlinkException cause = new FlinkException("Test exception");
    final JobResult jobResult = JobResult.createFrom(new ArchivedExecutionGraphBuilder().setJobID(new JobID()).setState(JobStatus.CANCELED).setFailureCause(new ErrorInfo(cause, 42L)).build());
    try {
        jobResult.toJobExecutionResult(getClass().getClassLoader());
        fail("Job should fail with an JobCancellationException.");
    } catch (JobCancellationException expected) {
        // the failure cause in the execution graph should not be the cause of the canceled job
        // result
        assertThat(expected.getCause(), is(nullValue()));
    }
}
Also used : JobCancellationException(org.apache.flink.runtime.client.JobCancellationException) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) FlinkException(org.apache.flink.util.FlinkException) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 98 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobResultTest method testFailedJobThrowsJobExecutionException.

@Test
public void testFailedJobThrowsJobExecutionException() throws Exception {
    final FlinkException cause = new FlinkException("Test exception");
    final JobResult jobResult = JobResult.createFrom(new ArchivedExecutionGraphBuilder().setJobID(new JobID()).setState(JobStatus.FAILED).setFailureCause(new ErrorInfo(cause, 42L)).build());
    try {
        jobResult.toJobExecutionResult(getClass().getClassLoader());
        fail("Job should fail with JobExecutionException.");
    } catch (JobExecutionException expected) {
        assertThat(expected.getCause(), is(equalTo(cause)));
    }
}
Also used : JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) FlinkException(org.apache.flink.util.FlinkException) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 99 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class CreatingExecutionGraphTest method testSuspendTransitionsToFinished.

@Test
public void testSuspendTransitionsToFinished() throws Exception {
    try (MockCreatingExecutionGraphContext context = new MockCreatingExecutionGraphContext()) {
        final CreatingExecutionGraph creatingExecutionGraph = new CreatingExecutionGraph(context, new CompletableFuture<>(), log, CreatingExecutionGraphTest::createTestingOperatorCoordinatorHandler);
        context.setExpectFinished(archivedExecutionGraph -> assertThat(archivedExecutionGraph.getState()).isEqualTo(JobStatus.SUSPENDED));
        creatingExecutionGraph.suspend(new FlinkException("Job has been suspended."));
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.jupiter.api.Test)

Example 100 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class CreatingExecutionGraphTest method testGlobalFailureTransitionsToFinished.

@Test
public void testGlobalFailureTransitionsToFinished() throws Exception {
    try (MockCreatingExecutionGraphContext context = new MockCreatingExecutionGraphContext()) {
        final CreatingExecutionGraph creatingExecutionGraph = new CreatingExecutionGraph(context, new CompletableFuture<>(), log, CreatingExecutionGraphTest::createTestingOperatorCoordinatorHandler);
        context.setExpectFinished(archivedExecutionGraph -> assertThat(archivedExecutionGraph.getState()).isEqualTo(JobStatus.FAILED));
        creatingExecutionGraph.handleGlobalFailure(new FlinkException("Test exception"));
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.jupiter.api.Test)

Aggregations

FlinkException (org.apache.flink.util.FlinkException)197 Test (org.junit.Test)91 CompletableFuture (java.util.concurrent.CompletableFuture)59 IOException (java.io.IOException)38 ExecutionException (java.util.concurrent.ExecutionException)26 ArrayList (java.util.ArrayList)25 JobID (org.apache.flink.api.common.JobID)24 Collection (java.util.Collection)22 CompletionException (java.util.concurrent.CompletionException)22 Configuration (org.apache.flink.configuration.Configuration)21 TimeoutException (java.util.concurrent.TimeoutException)19 FutureUtils (org.apache.flink.util.concurrent.FutureUtils)19 Time (org.apache.flink.api.common.time.Time)16 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)16 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)16 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)15 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)14 Collections (java.util.Collections)13 List (java.util.List)13 ExecutorService (java.util.concurrent.ExecutorService)13