GJL commented on a change in pull request #9240: [FLINK-13440] Add test that 
fails job when in-flight sync savepoint is discarded.
URL: https://github.com/apache/flink/pull/9240#discussion_r308231582
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinatorTest.java
 ##########
 @@ -3994,6 +4008,130 @@ public void testSharedStateRegistrationOnRestore() 
throws Exception {
                }
        }
 
+       @Test
+       public void jobFailsIfInFlightSynchronousSavepointIsDiscarded() throws 
Exception {
+               final JobID jobId = new JobID();
+
+               final ExecutionGraph executionGraph = getExecutionGraph(jobId);
+               final CheckpointCoordinator coordinator = 
enableCheckpointingAndGetCoordinator(executionGraph);
+               final ExecutionAttemptID attemptID = 
executeAndGetAttemptID(executionGraph);
+
+               assertEquals(JobStatus.RUNNING, executionGraph.getState());
+
+               final CompletableFuture<CompletedCheckpoint> savepointFuture = 
coordinator
+                               .triggerSynchronousSavepoint(10L, false, 
"test-dir");
+
+               final Throwable expectedRootCause = new 
IOException("Custom-Exception");
+               final PendingCheckpoint syncSavepoint = 
declineSynchronousSavepoint(jobId, coordinator, attemptID, expectedRootCause);
+               assertTrue(syncSavepoint.isDiscarded());
+
+               final JobStatus status = executionGraph.getState();
+               coordinator.shutdown(status);
+
+               assertEquals(JobStatus.FAILING, status);
+
+               final AtomicReference<Throwable> actualCause = new 
AtomicReference<>();
+               savepointFuture.handle((path, throwable) -> {
+                       if (throwable != null) {
+                               actualCause.set(throwable);
+                       }
+                       return path;
+               }).get();
+
+               assertThat(actualCause.get(), equals(expectedRootCause));
 
 Review comment:
   Consider `ExceptionUtils#stripCompletionException()` and 
`ExceptionUtils#findThrowableWithMessage()` instead of the `AtomicReference` 
and custom matcher.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to