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

    https://github.com/apache/flink/pull/3340#discussion_r102995512
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
 ---
    @@ -440,6 +440,72 @@ public void testSendCancelAndReceiveFail() {
                }
        }
     
    +   /**
    +    * For job manager failure recovery case, the execution may still in 
reconciling state but already recovered
    +    * basic information including slot, when process the failed execution, 
it will trigger to cancel all the current
    +    * executions. It is necessary to send cancel rpc to reconciling state 
execution with slot because the task manger
    +    * already reports its status for recovery.
    +    */
    +   @Test
    +   public void testCancelFromReconcilingWithSlot() {
    +           try {
    +                   final JobVertexID jid = new JobVertexID();
    +                   final ExecutionJobVertex ejv = getExecutionVertex(jid, 
new DirectScheduledExecutorService());
    +                   final ExecutionVertex vertex = new ExecutionVertex(ejv, 
0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
    +                   final ActorGateway actorGateway = new 
CancelSequenceActorGateway(TestingUtils.directExecutionContext(), 1);
    +
    +                   final Instance instance = getInstance(new 
ActorTaskManagerGateway(actorGateway));
    +                   final SimpleSlot slot = instance.allocateSimpleSlot(new 
JobID());
    +
    +                   setVertexState(vertex, ExecutionState.RECONCILING);
    +                   setVertexResource(vertex, slot);
    +
    +                   assertEquals(ExecutionState.RECONCILING, 
vertex.getExecutionState());
    +
    +                   vertex.cancel();
    +                   
vertex.getCurrentExecutionAttempt().cancelingComplete(); // response by task 
manager once actually canceled
    +
    +                   assertEquals(ExecutionState.CANCELED, 
vertex.getExecutionState());
    +                   assertTrue(slot.isReleased());
    +                   assertNull(vertex.getFailureCause());
    +                   
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
    +                   
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
    +                   
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELED) > 0);
    +           } catch (Exception e) {
    +                   e.printStackTrace();
    +                   fail(e.getMessage());
    +           }
    +   }
    +
    +   /**
    +    * For job manager failure recovery case, the execution may still in 
reconciling state because the task manager
    +    *  does not report its status within duration time. It is no need to 
send cancel rpc for such execution with no real
    +    *  attempt id and slot. And it can be transition to canceled state 
directly, the same with the cases of scheduled or created.
    +    */
    +   @Test
    +   public void testCancelFromReconcilingNoSlot() {
    +           try {
    --- End diff --
    
    We are trying to avoid this pattern now (we used it in the earlier days).
    It is better for logging and debugging to simply declare `throws Exception` 
on the test method.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to