Myracle commented on a change in pull request #12958:
URL: https://github.com/apache/flink/pull/12958#discussion_r462655894



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/TaskManagerCheckInSlotManagerTest.java
##########
@@ -135,14 +216,80 @@ public void 
testTaskManagerIsNotReleasedInCaseOfConcurrentAllocation() throws Ex
                }
        }
 
+       /**
+        * Register four taskManagers that all have two slots.
+        * The difference between the taskManagers is whether the slot is 
allocated.
+        * To maintain redundantTaskManagerNum, SlotManagerImpl may release or 
allocate taskManagers.
+        * @param redundantTaskManagerNum
+        * @throws Exception
+        */
+       private void registerAndCheckMultiTaskManagers(int 
redundantTaskManagerNum) throws Exception {
+               SlotManagerImpl slotManager = 
createAndStartSlotManager(redundantTaskManagerNum, 2);
+
+               // Both slots are free.
+               AtomicReference<CompletableFuture<Boolean>> 
canBeReleasedFuture0 = new AtomicReference<>();
+               registerTaskManagerWithTwoSlots(slotManager, 
canBeReleasedFuture0, true, true);
+
+               // Both slots are allocated.
+               AtomicReference<CompletableFuture<Boolean>> 
canBeReleasedFuture1 = new AtomicReference<>();
+               registerTaskManagerWithTwoSlots(slotManager, 
canBeReleasedFuture1, false, false);
+
+               // One slot is allocated, the other is free.
+               AtomicReference<CompletableFuture<Boolean>> 
canBeReleasedFuture2 = new AtomicReference<>();
+               registerTaskManagerWithTwoSlots(slotManager, 
canBeReleasedFuture2, false, true);
+
+               // One slot is free, the other is allocated.
+               AtomicReference<CompletableFuture<Boolean>> 
canBeReleasedFuture3 = new AtomicReference<>();
+               registerTaskManagerWithTwoSlots(slotManager, 
canBeReleasedFuture3, true, false);
+
+               
checkTaskManagerTimeoutWithCustomCanBeReleasedResponse(slotManager, true, () -> 
{},
+                       Arrays.asList(canBeReleasedFuture0, 
canBeReleasedFuture1, canBeReleasedFuture2, canBeReleasedFuture3));

Review comment:
       All the suggestions are valuable. I have modified the code. Please have 
a look again. Thank you, @xintongsong 




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


Reply via email to