zentol commented on code in PR #19968: URL: https://github.com/apache/flink/pull/19968#discussion_r901681503
########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/StopWithSavepointTest.java: ########## @@ -336,17 +342,83 @@ public void testRestartOnTaskFailureAfterSavepointCompletion() throws Exception executionGraph.registerExecution(execution); TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception); - assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true)); + assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition)).isTrue(); + } + } + + @Test + void testOnFailureWaitsForSavepointCompletion() throws Exception { + try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) { + CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling(); + CompletableFuture<String> savepointFuture = new CompletableFuture<>(); + StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph(); + StopWithSavepoint sws = + createStopWithSavepoint( + ctx, mockStopWithSavepointOperations, executionGraph, savepointFuture); + ctx.setStopWithSavepoint(sws); + + ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO)); + + sws.onFailure(new Exception("task failure")); + // this is a sanity check that we haven't scheduled a state transition + ctx.triggerExecutors(); + + ctx.setExpectRestarting(assertNonNull()); + savepointFuture.complete(SAVEPOINT_PATH); + ctx.triggerExecutors(); + } + } + + @Test + void testOnGloballyTerminalStateWaitsForSavepointCompletion() throws Exception { Review Comment: it's quite similar; testFinishedOnSuccessfulStopWithSavepoint is purely about the functional aspect, whereas this one is specifically about the waiting. -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org