tillrohrmann commented on a change in pull request #9072: [FLINK-11630] Wait 
for the termination of all running Tasks when shutting down TaskExecutor
URL: https://github.com/apache/flink/pull/9072#discussion_r313904389
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
 ##########
 @@ -760,6 +767,79 @@ public void invoke() throws Exception {
                }
        }
 
+       @Test
+       public void testTaskInterruptionAndTerminationOnShutdown() throws 
Exception {
+               final CompletableFuture<Void> taskSlotTableStarted = new 
CompletableFuture<>();
+               final TaskSlotTable taskSlotTable = new 
TaskSlotTableWithStartFuture(taskSlotTableStarted, timerService);
+               final JobMasterId jobMasterId = JobMasterId.generate();
+               final AllocationID allocationId = new AllocationID();
+               final TaskDeploymentDescriptor taskDeploymentDescriptor =
+                       
createTaskDeploymentDescriptor(TestInterruptableInvokable.class, allocationId);
+               final TaskExecutor taskExecutor = createTaskExecutor(new 
TaskManagerServicesBuilder()
+                       .setTaskSlotTable(taskSlotTable)
+                       
.setJobManagerTable(createJobManagerTableWithOneJob(jobMasterId))
+                       .build());
+
+               try {
+                       taskExecutor.start();
+                       taskSlotTableStarted.get();
+                       taskSlotTable.allocateSlot(0, jobId, allocationId, 
timeout);
+                       taskExecutor
+                               .getSelfGateway(TaskExecutorGateway.class)
+                               .submitTask(taskDeploymentDescriptor, 
jobMasterId, timeout);
+                       TestInterruptableInvokable.STARTED_FUTURE.get();
+               } finally {
+                       RpcUtils.terminateRpcEndpoint(taskExecutor, timeout);
+               }
+               taskExecutor.getTerminationFuture().get();
+
+               Task task = 
taskSlotTable.getTask(taskDeploymentDescriptor.getExecutionAttemptId());
+               assertThat(task.getTerminationFuture().isDone(), is(true));
+               
assertThat(TestInterruptableInvokable.INTERRUPTED_FUTURE.isDone(), is(true));
 
 Review comment:
   Can't we change the test so that we have control over the submitted task's 
termination future `t`. Given that, we could stop the `TaskExecutor` and check 
that it has not terminated if the task's termination future `t` is not 
completed. Then we complete `t` and check that the `TaskExecutor` terminates. 
Then there would also be no need to interact directly with the `TaskSlotTable` 
which is an implementation detail of the `TaskExecutor`.

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