use of org.apache.flink.runtime.webmonitor.TestingRestfulGateway in project flink by apache.
the class SavepointHandlersTest method testTriggerSavepointWithDefaultDirectory.
@Test
public void testTriggerSavepointWithDefaultDirectory() throws Exception {
final CompletableFuture<String> targetDirectoryFuture = new CompletableFuture<>();
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setTriggerSavepointFunction((AsynchronousJobOperationKey operationKey, String targetDirectory, SavepointFormatType formatType) -> {
targetDirectoryFuture.complete(targetDirectory);
return CompletableFuture.completedFuture(Acknowledge.get());
}).build();
final String defaultSavepointDir = "/other/dir";
final SavepointHandlers savepointHandlers = new SavepointHandlers(defaultSavepointDir);
final SavepointHandlers.SavepointTriggerHandler savepointTriggerHandler = savepointHandlers.new SavepointTriggerHandler(leaderRetriever, TIMEOUT, Collections.emptyMap());
savepointTriggerHandler.handleRequest(triggerSavepointRequestWithDefaultDirectory(), testingRestfulGateway).get();
assertThat(targetDirectoryFuture.get(), equalTo(defaultSavepointDir));
}
use of org.apache.flink.runtime.webmonitor.TestingRestfulGateway in project flink by apache.
the class SavepointHandlersTest method testQueryStatusOfUnknownOperationReturnsError.
@Test
public void testQueryStatusOfUnknownOperationReturnsError() throws HandlerRequestException, RestHandlerException {
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setGetSavepointStatusFunction(key -> FutureUtils.completedExceptionally(new UnknownOperationKeyException(key))).build();
final CompletableFuture<AsynchronousOperationResult<SavepointInfo>> statusFuture = savepointStatusHandler.handleRequest(savepointStatusRequest(new TriggerId()), testingRestfulGateway);
assertThat(statusFuture, RestMatchers.respondsWithError(HttpResponseStatus.NOT_FOUND));
}
Aggregations