Search in sources :

Example 1 with TestingJobManagerRunner

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;
}
Also used : TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)

Example 2 with TestingJobManagerRunner

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);
}
Also used : TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) Test(org.junit.jupiter.api.Test)

Example 3 with TestingJobManagerRunner

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();
}
Also used : TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) Test(org.junit.jupiter.api.Test)

Example 4 with TestingJobManagerRunner

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();
}
Also used : TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) Test(org.junit.jupiter.api.Test)

Example 5 with TestingJobManagerRunner

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);
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) JobManagerRunner(org.apache.flink.runtime.jobmaster.JobManagerRunner) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Aggregations

TestingJobManagerRunner (org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)22 Test (org.junit.Test)16 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)7 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)5 JobID (org.apache.flink.api.common.JobID)4 FlinkException (org.apache.flink.util.FlinkException)4 ArrayDeque (java.util.ArrayDeque)3 TimeoutException (java.util.concurrent.TimeoutException)3 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)3 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)3 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)3 JobManagerRunner (org.apache.flink.runtime.jobmaster.JobManagerRunner)3 Test (org.junit.jupiter.api.Test)3 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 Optional (java.util.Optional)2 Queue (java.util.Queue)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2