Myasuka commented on a change in pull request #9123: [FLINK-13281] Fix the 
verify logic of 
AdaptedRestartPipelinedRegionStrategyNGAbortPendingCheckpointsTest
URL: https://github.com/apache/flink/pull/9123#discussion_r303903541
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/AdaptedRestartPipelinedRegionStrategyNGAbortPendingCheckpointsTest.java
 ##########
 @@ -76,49 +80,64 @@ public void abortPendingCheckpointsWhenRestartingTasks() 
throws Exception {
                final ExecutionGraph executionGraph = 
createExecutionGraph(jobGraph);
 
                final Iterator<ExecutionVertex> vertexIterator = 
executionGraph.getAllExecutionVertices().iterator();
-               final ExecutionVertex onlyExecutionVertex = 
vertexIterator.next();
+               final ExecutionVertex firstExecutionVertex = 
vertexIterator.next();
 
-               setTaskRunning(executionGraph, onlyExecutionVertex);
+               setTaskRunning(executionGraph, firstExecutionVertex, 
vertexIterator.next());
 
                final CheckpointCoordinator checkpointCoordinator = 
executionGraph.getCheckpointCoordinator();
                checkState(checkpointCoordinator != null);
 
                
checkpointCoordinator.triggerCheckpoint(System.currentTimeMillis(),  false);
                final int pendingCheckpointsBeforeFailure = 
checkpointCoordinator.getNumberOfPendingCheckpoints();
+               long checkpointId = 
checkpointCoordinator.getPendingCheckpoints().keySet().iterator().next();
 
-               failVertex(onlyExecutionVertex);
+               AcknowledgeCheckpoint acknowledgeCheckpoint = new 
AcknowledgeCheckpoint(
+                       firstExecutionVertex.getJobId(),
+                       
firstExecutionVertex.getCurrentExecutionAttempt().getAttemptId(),
+                       checkpointId,
+                       mock(CheckpointMetrics.class),
+                       mock(TaskStateSnapshot.class));
+
+               // not let the first checkpoint to be discarded when 
firstExecutionVertex has been acknowledged.
+               
checkpointCoordinator.receiveAcknowledgeMessage(acknowledgeCheckpoint, "Unknown 
location");
+               failVertex(firstExecutionVertex);
 
                assertThat(pendingCheckpointsBeforeFailure, is(equalTo(1)));
                assertNoPendingCheckpoints(checkpointCoordinator);
        }
 
-       private void setTaskRunning(final ExecutionGraph executionGraph, final 
ExecutionVertex executionVertex) {
-               executionGraph.updateState(
-                       new TaskExecutionState(executionGraph.getJobID(),
-                               
executionVertex.getCurrentExecutionAttempt().getAttemptId(),
-                               ExecutionState.RUNNING));
+       private void setTaskRunning(final ExecutionGraph executionGraph, final 
ExecutionVertex... executionVertices) {
+               for (ExecutionVertex executionVertex : executionVertices) {
+                       executionGraph.updateState(
+                               new 
TaskExecutionState(executionGraph.getJobID(),
+                                       
executionVertex.getCurrentExecutionAttempt().getAttemptId(),
+                                       ExecutionState.RUNNING));
+               }
        }
 
        private void failVertex(final ExecutionVertex onlyExecutionVertex) {
                onlyExecutionVertex.getCurrentExecutionAttempt().fail(new 
Exception("Test Exception"));
                manualMainThreadExecutor.triggerAll();
+               manualMainThreadExecutor.triggerScheduledTasks();
 
 Review comment:
   fixed in latest commit.

----------------------------------------------------------------
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