use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method registerTestingJobManagerRunner.
private TestingJobManagerRunner registerTestingJobManagerRunner() {
final TestingJobManagerRunner jobManagerRunner = TestingJobManagerRunner.newBuilder().build();
testInstance.register(jobManagerRunner);
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isTrue();
assertThat(jobManagerRunner.getTerminationFuture()).isNotDone();
return jobManagerRunner;
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testFailingLocalCleanupAsync.
@Test
public void testFailingLocalCleanupAsync() throws Exception {
final TestingJobManagerRunner jobManagerRunner = registerTestingJobManagerRunner();
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isTrue();
assertThat(jobManagerRunner.getTerminationFuture()).isNotDone();
final RuntimeException expectedException = new RuntimeException("Expected exception");
jobManagerRunner.completeTerminationFutureExceptionally(expectedException);
final CompletableFuture<Void> cleanupResult = testInstance.localCleanupAsync(jobManagerRunner.getJobID(), Executors.directExecutor());
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isFalse();
assertThat(cleanupResult).isCompletedExceptionally().failsWithin(Duration.ZERO).withThrowableOfType(ExecutionException.class).extracting(FlinkAssertions::chainOfCauses, FlinkAssertions.STREAM_THROWABLE).hasExactlyElementsOfTypes(ExecutionException.class, FlinkException.class, expectedException.getClass()).last().isEqualTo(expectedException);
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testSuccessfulLocalCleanupAsync.
@Test
public void testSuccessfulLocalCleanupAsync() throws Exception {
final TestingJobManagerRunner jobManagerRunner = registerTestingJobManagerRunner();
final CompletableFuture<Void> cleanupResult = testInstance.localCleanupAsync(jobManagerRunner.getJobID(), Executors.directExecutor());
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isFalse();
assertThat(cleanupResult).isCompleted();
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DefaultJobManagerRunnerRegistryTest method testFailingLocalCleanup.
@Test
public void testFailingLocalCleanup() {
final TestingJobManagerRunner jobManagerRunner = registerTestingJobManagerRunner();
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isTrue();
assertThat(jobManagerRunner.getTerminationFuture()).isNotDone();
final RuntimeException expectedException = new RuntimeException("Expected exception");
jobManagerRunner.completeTerminationFutureExceptionally(expectedException);
assertThat(testInstance.localCleanupAsync(jobManagerRunner.getJobID(), Executors.directExecutor())).failsWithin(Duration.ZERO).withThrowableOfType(ExecutionException.class).extracting(FlinkAssertions::chainOfCauses, FlinkAssertions.STREAM_THROWABLE).hasExactlyElementsOfTypes(ExecutionException.class, FlinkException.class, expectedException.getClass()).last().isEqualTo(expectedException);
assertThat(testInstance.isRegistered(jobManagerRunner.getJobID())).isFalse();
}
use of org.apache.flink.runtime.jobmaster.TestingJobManagerRunner in project flink by apache.
the class DispatcherResourceCleanupTest method testGlobalCleanupWhenJobFinishedWhileClosingDispatcher.
@Test
public void testGlobalCleanupWhenJobFinishedWhileClosingDispatcher() throws Exception {
final TestingJobManagerRunner testingJobManagerRunner = TestingJobManagerRunner.newBuilder().setBlockingTermination(true).setJobId(jobId).build();
final Queue<JobManagerRunner> jobManagerRunners = new ArrayDeque<>(Arrays.asList(testingJobManagerRunner));
startDispatcher(new QueueJobManagerRunnerFactory(jobManagerRunners));
submitJobAndWait();
final CompletableFuture<Void> dispatcherTerminationFuture = dispatcher.closeAsync();
testingJobManagerRunner.getCloseAsyncCalledLatch().await();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build()));
testingJobManagerRunner.completeTerminationFuture();
// check that no exceptions have been thrown
dispatcherTerminationFuture.get();
assertGlobalCleanupTriggered(jobId);
}
Aggregations