Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6222#discussion_r199171079
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobSubmitHandlerTest.java
 ---
    @@ -87,4 +89,33 @@ public void testSuccessfulJobSubmission() throws 
Exception {
                handler.handleRequest(new HandlerRequest<>(request, 
EmptyMessageParameters.getInstance()), mockGateway)
                        .get();
        }
    +
    +   @Test
    +   public void testFailedJobSubmission() throws Exception {
    +           final String errorMessage = "test";
    +           DispatcherGateway mockGateway = mock(DispatcherGateway.class);
    +           when(mockGateway.submitJob(any(JobGraph.class), 
any(Time.class))).thenReturn(FutureUtils.completedExceptionally(new 
Exception(errorMessage)));
    +           GatewayRetriever<DispatcherGateway> mockGatewayRetriever = 
mock(GatewayRetriever.class);
    +
    +           JobSubmitHandler handler = new JobSubmitHandler(
    +                   
CompletableFuture.completedFuture("http://localhost:1234";),
    +                   mockGatewayRetriever,
    +                   RpcUtils.INF_TIMEOUT,
    +                   Collections.emptyMap());
    +
    +           JobGraph job = new JobGraph("testjob");
    +           JobSubmitRequestBody request = new JobSubmitRequestBody(job);
    +
    +           try {
    +                   handler.handleRequest(new HandlerRequest<>(request, 
EmptyMessageParameters.getInstance()), mockGateway)
    +                           .get();
    +           } catch (Exception e) {
    +                   Throwable t = ExceptionUtils.stripExecutionException(e);
    +                   if (t instanceof RestHandlerException){
    +                           Assert.assertTrue(t.getMessage().equals("Job 
submission failed."));
    +                   } else {
    +                           throw e;
    +                   }
    +           }
    --- End diff --
    
    I think we should make sure that `errorMessage` is part of the 
`RestHandlerException#message`. Otherwise this information won't be sent to the 
client in the form of the `ErrorResponseBody`.


---

Reply via email to