use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class WebSubmissionExtensionTest method uploadJar.
private static String uploadJar(WebSubmissionExtension extension, Path jarFile, DispatcherGateway dispatcherGateway) throws Exception {
final JarUploadHandler jarUploadHandler = extension.getJarUploadHandler();
final HandlerRequest<EmptyRequestBody> uploadRequest = HandlerRequest.create(EmptyRequestBody.getInstance(), EmptyMessageParameters.getInstance(), Collections.singletonList(jarFile.toFile()));
return jarUploadHandler.handleRequest(uploadRequest, dispatcherGateway).get().getFilename();
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JarUploadHandlerTest method testFailedUpload.
@Test
public void testFailedUpload() throws Exception {
final Path uploadedFile = jarDir.resolve("FooBazzleExample.jar");
final HandlerRequest<EmptyRequestBody> request = createRequest(uploadedFile);
try {
jarUploadHandler.handleRequest(request, mockDispatcherGateway).get();
fail("Expected exception not thrown.");
} catch (final ExecutionException e) {
final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause());
assertThat(throwable, instanceOf(RestHandlerException.class));
final RestHandlerException restHandlerException = (RestHandlerException) throwable;
assertThat(restHandlerException.getMessage(), containsString("Could not move uploaded jar file"));
assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
}
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JarUploadHandlerTest method testUploadJar.
@Test
public void testUploadJar() throws Exception {
final Path uploadedFile = Files.createFile(jarDir.resolve("FooBazzleExample.jar"));
final HandlerRequest<EmptyRequestBody> request = createRequest(uploadedFile);
final JarUploadResponseBody jarUploadResponseBody = jarUploadHandler.handleRequest(request, mockDispatcherGateway).get();
assertThat(jarUploadResponseBody.getStatus(), equalTo(JarUploadResponseBody.UploadStatus.success));
final String returnedFileNameWithUUID = jarUploadResponseBody.getFilename();
assertThat(returnedFileNameWithUUID, containsString("_"));
final String returnedFileName = returnedFileNameWithUUID.substring(returnedFileNameWithUUID.lastIndexOf("_") + 1);
assertThat(returnedFileName, equalTo(uploadedFile.getFileName().toString()));
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JobExceptionsHandlerTest method testNoExceptions.
@Test
public void testNoExceptions() throws HandlerRequestException {
final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().build());
final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
assertThat(response.getRootException(), is(nullValue()));
assertThat(response.getRootTimestamp(), is(nullValue()));
assertFalse(response.isTruncated());
assertThat(response.getAllExceptions(), empty());
assertThat(response.getExceptionHistory().getEntries(), empty());
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JobExceptionsHandlerTest method testWithExceptionHistory.
@Test
public void testWithExceptionHistory() throws HandlerRequestException {
final RootExceptionHistoryEntry rootCause = fromGlobalFailure(new RuntimeException("exception #0"), System.currentTimeMillis());
final RootExceptionHistoryEntry otherFailure = new RootExceptionHistoryEntry(new RuntimeException("exception #1"), System.currentTimeMillis(), "task name", new LocalTaskManagerLocation(), Collections.emptySet());
final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(rootCause, otherFailure);
final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause.getException(), rootCause.getTimestamp()), historyContainsJobExceptionInfo(otherFailure.getException(), otherFailure.getTimestamp(), otherFailure.getFailingTaskName(), JobExceptionsHandler.toString(otherFailure.getTaskManagerLocation()))));
assertFalse(response.getExceptionHistory().isTruncated());
}
Aggregations