use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.
the class DefaultExecutionGraphCacheTest method testCacheEntryCleanup.
/**
* Tests that cache entries are cleaned up when their TTL has expired upon calling {@link
* DefaultExecutionGraphCache#cleanup()}.
*/
@Test
public void testCacheEntryCleanup() throws Exception {
final Time timeout = Time.milliseconds(100L);
final Time timeToLive = Time.milliseconds(1L);
final JobID expectedJobId2 = new JobID();
final ExecutionGraphInfo expectedExecutionGraphInfo2 = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().build());
final AtomicInteger requestJobCalls = new AtomicInteger(0);
final TestingRestfulGateway restfulGateway = new TestingRestfulGateway.Builder().setRequestExecutionGraphInfoFunction(jobId -> {
requestJobCalls.incrementAndGet();
if (jobId.equals(expectedJobId)) {
return CompletableFuture.completedFuture(expectedExecutionGraphInfo);
} else if (jobId.equals(expectedJobId2)) {
return CompletableFuture.completedFuture(expectedExecutionGraphInfo2);
} else {
throw new AssertionError("Invalid job id received.");
}
}).build();
try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
CompletableFuture<ExecutionGraphInfo> executionGraph1Future = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
CompletableFuture<ExecutionGraphInfo> executionGraph2Future = executionGraphCache.getExecutionGraphInfo(expectedJobId2, restfulGateway);
assertEquals(expectedExecutionGraphInfo, executionGraph1Future.get());
assertEquals(expectedExecutionGraphInfo2, executionGraph2Future.get());
assertThat(requestJobCalls.get(), Matchers.equalTo(2));
Thread.sleep(timeToLive.toMilliseconds());
executionGraphCache.cleanup();
assertTrue(executionGraphCache.size() == 0);
}
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder 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()));
}
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder 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)));
}
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.
the class JobResultTest method testFailedJobIsFailureResult.
@Test
public void testFailedJobIsFailureResult() {
final JobResult jobResult = JobResult.createFrom(new ArchivedExecutionGraphBuilder().setJobID(new JobID()).setState(JobStatus.FAILED).setFailureCause(new ErrorInfo(new FlinkException("Test exception"), 42L)).build());
assertThat(jobResult.isSuccess(), is(false));
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.
the class DefaultJobMasterServiceProcessTest method testSuccessOnTerminalState.
@Test
public void testSuccessOnTerminalState() throws Exception {
final CompletableFuture<JobMasterService> jobMasterServiceFuture = new CompletableFuture<>();
DefaultJobMasterServiceProcess serviceProcess = createTestInstance(jobMasterServiceFuture);
jobMasterServiceFuture.complete(new TestingJobMasterService());
ArchivedExecutionGraph archivedExecutionGraph = new ArchivedExecutionGraphBuilder().setState(JobStatus.FINISHED).build();
serviceProcess.jobReachedGloballyTerminalState(new ExecutionGraphInfo(archivedExecutionGraph));
assertThat(serviceProcess.getResultFuture()).isCompletedWithValueMatching(JobManagerRunnerResult::isSuccess).isCompletedWithValueMatching(r -> r.getExecutionGraphInfo().getArchivedExecutionGraph().getState() == JobStatus.FINISHED);
}
Aggregations