reswqa commented on code in PR #22176:
URL: https://github.com/apache/flink/pull/22176#discussion_r1138082595


##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/LeastUtilizationSlotMatchingStrategyTest.java:
##########
@@ -71,8 +69,63 @@ public void 
findMatchingSlot_multipleMatchingSlots_returnsSlotWithLeastUtilizati
                         freeSlots,
                         
createRegisteredSlotsLookupFunction(registeredSlotPerTaskExecutor));
 
-        assertTrue(matchingSlot.isPresent());
-        assertThat(matchingSlot.get().getSlotId(), 
is(leastUtilizedSlot.getSlotId()));
+        assertThat(matchingSlot).isPresent();
+        
assertThat(matchingSlot.get().getSlotId()).isEqualTo(leastUtilizedSlot.getSlotId());
+    }
+
+    @Test
+    public void
+            
findMatchingSlotMultipleMatchingSlotsReturnsSlotWithLeastUtilizationByAllocatedSlotNumber()
 {
+        InstanceID leastUtilizedInstance = new InstanceID();
+        InstanceID tooSmallInstance = new InstanceID();
+        InstanceID alternativeInstance = new InstanceID();
+        Collection<InstanceID> availableInstances =
+                Arrays.asList(tooSmallInstance, alternativeInstance, 
leastUtilizedInstance);
+
+        final Optional<InstanceID> matchingInstance =
+                
LeastUtilizationSlotMatchingStrategy.INSTANCE.findMatchingResource(
+                        instanceID -> !instanceID.equals(tooSmallInstance),
+                        availableInstances,
+                        instanceID -> {
+                            if (instanceID.equals(leastUtilizedInstance)) {
+                                return new TaskManagerResourceInfoSnapshot(
+                                        ResourceProfile.UNKNOWN, 
ResourceProfile.UNKNOWN, 0);
+                            } else {
+                                return new TaskManagerResourceInfoSnapshot(
+                                        ResourceProfile.UNKNOWN, 
ResourceProfile.UNKNOWN, 1);
+                            }
+                        });
+        assertThat(matchingInstance).isPresent();
+        assertThat(matchingInstance.get()).isEqualTo(leastUtilizedInstance);
+    }
+
+    @Test
+    public void 
findMatchingSlotMultipleMatchingSlotsReturnsSlotWithLeastUtilizationByResource()
 {

Review Comment:
   ```suggestion
       void 
findMatchingSlotMultipleMatchingSlotsReturnsSlotWithLeastUtilizationByResource()
 {
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to