use of org.apache.flink.runtime.scheduler.TestingSchedulerNGFactory in project flink by apache.
the class JobMasterTest method testJobMasterOnlyTerminatesAfterTheSchedulerHasClosed.
@Test
public void testJobMasterOnlyTerminatesAfterTheSchedulerHasClosed() throws Exception {
final CompletableFuture<Void> schedulerTerminationFuture = new CompletableFuture<>();
final TestingSchedulerNG testingSchedulerNG = TestingSchedulerNG.newBuilder().setCloseAsyncSupplier(() -> schedulerTerminationFuture).build();
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withSlotPoolServiceSchedulerFactory(DefaultSlotPoolServiceSchedulerFactory.create(TestingSlotPoolServiceBuilder.newBuilder(), new TestingSchedulerNGFactory(testingSchedulerNG))).createJobMaster();
jobMaster.start();
final CompletableFuture<Void> jobMasterTerminationFuture = jobMaster.closeAsync();
try {
jobMasterTerminationFuture.get(10L, TimeUnit.MILLISECONDS);
fail("Expected TimeoutException because the JobMaster should not terminate.");
} catch (TimeoutException expected) {
}
schedulerTerminationFuture.complete(null);
jobMasterTerminationFuture.get();
}
use of org.apache.flink.runtime.scheduler.TestingSchedulerNGFactory in project flink by apache.
the class JobMasterTest method testTriggerSavepointTimeout.
/**
* Tests that the timeout in {@link JobMasterGateway#triggerSavepoint(String, boolean,
* SavepointFormatType, Time)} is respected.
*/
@Test
public void testTriggerSavepointTimeout() throws Exception {
final TestingSchedulerNG testingSchedulerNG = TestingSchedulerNG.newBuilder().setTriggerSavepointFunction((ignoredA, ignoredB, formatType) -> new CompletableFuture<>()).build();
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withFatalErrorHandler(testingFatalErrorHandler).withSlotPoolServiceSchedulerFactory(DefaultSlotPoolServiceSchedulerFactory.create(TestingSlotPoolServiceBuilder.newBuilder(), new TestingSchedulerNGFactory(testingSchedulerNG))).createJobMaster();
try {
jobMaster.start();
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
final CompletableFuture<String> savepointFutureLowTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, SavepointFormatType.CANONICAL, Time.milliseconds(1));
final CompletableFuture<String> savepointFutureHighTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, SavepointFormatType.CANONICAL, RpcUtils.INF_TIMEOUT);
try {
savepointFutureLowTimeout.get(testingTimeout.getSize(), testingTimeout.getUnit());
fail();
} catch (final ExecutionException e) {
final Throwable cause = ExceptionUtils.stripExecutionException(e);
assertThat(cause, instanceOf(TimeoutException.class));
}
assertThat(savepointFutureHighTimeout.isDone(), is(equalTo(false)));
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
Aggregations