tillrohrmann commented on a change in pull request #7676: [FLINK-11364][tests] 
Port TaskManagerFailsITCase to new code base
URL: https://github.com/apache/flink/pull/7676#discussion_r256298061
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
 ##########
 @@ -1430,6 +1422,125 @@ public void 
testReleasingTaskExecutorIfNoMoreSlotsRegistered() throws Exception
                }
        }
 
+       @Nonnull
+       private TestingResourceManagerGateway 
createAndRegisterTestingResourceManagerGateway() {
+               final TestingResourceManagerGateway 
testingResourceManagerGateway = new TestingResourceManagerGateway();
+               
rpcService.registerGateway(testingResourceManagerGateway.getAddress(), 
testingResourceManagerGateway);
+               return testingResourceManagerGateway;
+       }
+
+       /**
+        * Tests that the job execution is failed if the TaskExecutor 
disconnects from the
+        * JobMaster.
+        */
+       @Test
+       public void testJobFailureWhenGracefulTaskExecutorTermination() throws 
Exception {
+               runJobFailureWhenTaskExecutorTerminatesTest(
+                       () -> heartbeatServices,
+                       (localTaskManagerLocation, jobMasterGateway) -> 
jobMasterGateway.disconnectTaskManager(
+                               localTaskManagerLocation.getResourceID(),
+                               new FlinkException("Test disconnectTaskManager 
exception.")),
+                       (jobMasterGateway, resourceID) -> ignored -> {});
+       }
+
+       @Test
+       public void testJobFailureWhenTaskExecutorHeartbeatTimeout() throws 
Exception {
+               final AtomicBoolean respondToHeartbeats = new 
AtomicBoolean(true);
+               runJobFailureWhenTaskExecutorTerminatesTest(
+                       () -> fastHeartbeatServices,
+                       (localTaskManagerLocation, jobMasterGateway) -> 
respondToHeartbeats.set(false),
+                       (jobMasterGateway, taskManagerResourceId) -> resourceId 
-> {
+                               if (respondToHeartbeats.get()) {
+                                       
jobMasterGateway.heartbeatFromTaskManager(taskManagerResourceId, new 
AccumulatorReport(Collections.emptyList()));
+                               }
+                       }
+               );
+       }
+
+       private void runJobFailureWhenTaskExecutorTerminatesTest(
+                       Supplier<HeartbeatServices> heartbeatSupplier,
 
 Review comment:
   No, this is not correct. Will change.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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