use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testSuccessfulLocalCleanup.
@Test
public void testSuccessfulLocalCleanup() throws Throwable {
final TestingJobManagerRunner jobManagerRunner = registerTestingJobManagerRunner();
assertThat(testInstance.localCleanupAsync(jobManagerRunner.getJobID(), Executors.directExecutor())).isCompleted();
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isFalse();
assertThat(jobManagerRunner.getTerminationFuture()).isCompleted();
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DispatcherTest method testJobManagerRunnerInitializationFailureFailsJob.
@Test
public void testJobManagerRunnerInitializationFailureFailsJob() throws Exception {
final TestingJobMasterServiceLeadershipRunnerFactory testingJobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory();
dispatcher = createAndStartDispatcher(heartbeatServices, haServices, testingJobManagerRunnerFactory);
jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final JobGraph emptyJobGraph = JobGraphBuilder.newStreamingJobGraphBuilder().setJobId(jobId).build();
dispatcherGateway.submitJob(emptyJobGraph, TIMEOUT).get();
final TestingJobManagerRunner testingJobManagerRunner = testingJobManagerRunnerFactory.takeCreatedJobManagerRunner();
final FlinkException testFailure = new FlinkException("Test failure");
testingJobManagerRunner.completeResultFuture(JobManagerRunnerResult.forInitializationFailure(new ExecutionGraphInfo(ArchivedExecutionGraph.createSparseArchivedExecutionGraph(jobId, jobGraph.getName(), JobStatus.FAILED, testFailure, jobGraph.getCheckpointingSettings(), 1L)), testFailure));
// wait till job has failed
dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
// get failure cause
ArchivedExecutionGraph execGraph = dispatcherGateway.requestJob(jobGraph.getJobID(), TIMEOUT).get();
assertThat(execGraph.getState(), is(JobStatus.FAILED));
Assert.assertNotNull(execGraph.getFailureInfo());
Throwable throwable = execGraph.getFailureInfo().getException().deserializeError(ClassLoader.getSystemClassLoader());
// ensure correct exception type
assertThat(throwable, is(testFailure));
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DispatcherResourceCleanupTest method testErrorHandlingIfJobCannotBeMarkedAsCleanInJobResultStore.
@Test
public void testErrorHandlingIfJobCannotBeMarkedAsCleanInJobResultStore() throws Exception {
final CompletableFuture<JobResultEntry> dirtyJobFuture = new CompletableFuture<>();
final JobResultStore jobResultStore = TestingJobResultStore.builder().withCreateDirtyResultConsumer(dirtyJobFuture::complete).withMarkResultAsCleanConsumer(jobId -> {
throw new IOException("Expected IOException.");
}).build();
final TestingJobManagerRunnerFactory jobManagerRunnerFactory = startDispatcherAndSubmitJob(createTestingDispatcherBuilder().setJobResultStore(jobResultStore), 0);
ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(executionGraph));
final CompletableFuture<? extends Throwable> errorFuture = this.testingFatalErrorHandlerResource.getFatalErrorHandler().getErrorFuture();
try {
final Throwable unexpectedError = errorFuture.get(100, TimeUnit.MILLISECONDS);
fail("No error should have been reported but an " + unexpectedError.getClass() + " was handled.");
} catch (TimeoutException e) {
// expected
}
assertThat(dirtyJobFuture.get().getJobId(), is(jobId));
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DispatcherResourceCleanupTest method testFatalErrorIfJobCannotBeMarkedDirtyInJobResultStore.
@Test
public void testFatalErrorIfJobCannotBeMarkedDirtyInJobResultStore() throws Exception {
final JobResultStore jobResultStore = TestingJobResultStore.builder().withCreateDirtyResultConsumer(jobResult -> {
throw new IOException("Expected IOException.");
}).build();
final TestingJobManagerRunnerFactory jobManagerRunnerFactory = startDispatcherAndSubmitJob(createTestingDispatcherBuilder().setJobResultStore(jobResultStore), 0);
ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(executionGraph));
final CompletableFuture<? extends Throwable> errorFuture = this.testingFatalErrorHandlerResource.getFatalErrorHandler().getErrorFuture();
assertThat(errorFuture.get(100, TimeUnit.MILLISECONDS), IsInstanceOf.instanceOf(FlinkException.class));
testingFatalErrorHandlerResource.getFatalErrorHandler().clearError();
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DispatcherResourceCleanupTest method testDispatcherTerminationTerminatesRunningJobMasters.
@Test
public void testDispatcherTerminationTerminatesRunningJobMasters() throws Exception {
final TestingJobManagerRunnerFactory jobManagerRunnerFactory = startDispatcherAndSubmitJob();
dispatcher.closeAsync().get();
final TestingJobManagerRunner jobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
assertThat(jobManagerRunner.getTerminationFuture().isDone(), is(true));
}
Aggregations