tillrohrmann commented on a change in pull request #7227: [FLINK-11059] 
[runtime] do not add releasing failed slot to free slots
URL: https://github.com/apache/flink/pull/7227#discussion_r292897055
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
 ##########
 @@ -1662,6 +1665,82 @@ public void testTerminationOnFatalError() throws 
Throwable {
                }
        }
 
+       /**
+        * Tests that task manager will sync slot with job master throw 
heartbeat (See FLINK-11059).
+        */
+       @Test(timeout = 10000L)
+       public void testSyncSlotsWithJobMasterByHeartbeat() throws Exception {
+               final TaskSlotTable taskSlotTable = new TaskSlotTable(
+                               Arrays.asList(ResourceProfile.UNKNOWN, 
ResourceProfile.UNKNOWN),
+                               timerService);
+               final TaskManagerServices taskManagerServices = new 
TaskManagerServicesBuilder().setTaskSlotTable(taskSlotTable).build();
+
+               final TaskExecutor taskExecutor = 
createTaskExecutor(taskManagerServices);
+
+               final TestingResourceManagerGateway 
testingResourceManagerGateway = new TestingResourceManagerGateway();
+
+               final CompletableFuture<AllocationID> allocationNotifiedFree = 
new CompletableFuture<>();
+
+               final CompletableFuture<Void> initialSlotReportFuture = new 
CompletableFuture<>();
+               
testingResourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3
 -> {
+                       initialSlotReportFuture.complete(null);
+                       return 
CompletableFuture.completedFuture(Acknowledge.get());
+
+               });
+
+               
testingResourceManagerGateway.setNotifySlotAvailableConsumer(instanceIDSlotIDAllocationIDTuple3
 ->
+                       
allocationNotifiedFree.complete(instanceIDSlotIDAllocationIDTuple3.f2));
 
 Review comment:
   Instead of using a `CompletableFuture` which can only be completed once we 
could use a `ArrayBlockingQueue` with a capacity of `2`. That way we could 
assert (probabilistically) via a `queue.poll(5L, TimeUnit.MILLISECONDS)` that 
no other slots are freed. That way we could guard against future changes which 
could make this test pass if always the `allocationIdOnlyInTM` is freed first 
if multiple slots are being freed.

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