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_r313905790
##########
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));
+ }
+
+ private JobManagerTable createJobManagerTableWithOneJob(JobMasterId
jobMasterId) {
+ final JobManagerConnection jobManagerConnection = new
JobManagerConnection(
+ jobId,
+ ResourceID.generate(),
+ new
TestingJobMasterGatewayBuilder().setFencingTokenSupplier(() ->
jobMasterId).build(),
+ new NoOpTaskManagerActions(),
+ new TestCheckpointResponder(),
+ new TestGlobalAggregateManager(),
+ ContextClassLoaderLibraryCacheManager.INSTANCE,
+ new NoOpResultPartitionConsumableNotifier(),
+ (j, i, r) -> CompletableFuture.completedFuture(null));
+
+ final JobManagerTable jobManagerTable = new JobManagerTable();
+ jobManagerTable.put(jobId, jobManagerConnection);
+ return jobManagerTable;
+ }
+
+ private TaskDeploymentDescriptor createTaskDeploymentDescriptor(
Review comment:
What about introducing a `TaskDeploymentDescriptorBuilder` and replacing the
different test instantiations of `TDDs` with that?
----------------------------------------------------------------
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