gaoyunhaii commented on a change in pull request #8740: [FLINK-12763][runtime]
Fail job immediately if tasks’ resource needs can not be satisfied.
URL: https://github.com/apache/flink/pull/8740#discussion_r294572208
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerTest.java
##########
@@ -1574,6 +1575,51 @@ public void
testOnlyFreeSlotsCanFulfillPendingTaskManagerSlot() throws Exception
}
}
+ /**
+ * Tests that check and fail resource requests that exceeds allowed
resource profiles.
+ */
+ @Test
+ public void testCheckSlotRequestResourceProfile() throws Exception {
+ final JobID jobId = new JobID();
+ ResourceProfile resourceProfile1 = new ResourceProfile(2.0,
100);
+ ResourceProfile resourceProfile2 = new ResourceProfile(1.0,
200);
+
+ final ResourceManagerId resourceManagerId =
ResourceManagerId.generate();
+ final ResourceActions resourceManagerActions = new
TestingResourceActionsBuilder().build();
+
+ Exception exception = null;
+ SlotRequest slotRequest1;
+ SlotRequest slotRequest2;
+
+ try (final SlotManager slotManager =
createSlotManager(resourceManagerId, resourceManagerActions)) {
+
+ // Initially, both requests should be allowed
+ slotRequest1 = createSlotRequest(jobId, new
ResourceProfile(1.0, 100));
+ slotRequest2 = createSlotRequest(jobId, new
ResourceProfile(2.0, 200));
+
assertTrue(slotManager.registerSlotRequest(slotRequest1));
+
assertTrue(slotManager.registerSlotRequest(slotRequest2));
+
+ // Set allowed slot resource profiles, request 1 should
be allowed, request 2 should fail
+
slotManager.setAllowedSlotResourceProfiles(Arrays.asList(resourceProfile1,
resourceProfile2));
+ slotRequest1 = createSlotRequest(jobId, new
ResourceProfile(1.0, 100));
+ slotRequest2 = createSlotRequest(jobId, new
ResourceProfile(2.0, 200));
+
assertTrue(slotManager.registerSlotRequest(slotRequest1));
+ try {
+ slotManager.registerSlotRequest(slotRequest2);
+ } catch (Exception e) {
+ exception = e;
+ }
+ assertNotNull(exception);
+
+ // Reset allowed slot resource profiles, both requests
should be allowed
+
slotManager.setAllowedSlotResourceProfiles(Collections.emptyList());
+ slotRequest1 = createSlotRequest(jobId, new
ResourceProfile(1.0, 100));
+ slotRequest2 = createSlotRequest(jobId, new
ResourceProfile(2.0, 200));
+
assertTrue(slotManager.registerSlotRequest(slotRequest1));
+
assertTrue(slotManager.registerSlotRequest(slotRequest2));
+ }
+ }
+
Review comment:
I think we may also need to test the case that pendingRequest is marked as
fail when setAllowedSlotResourceProfiles.
----------------------------------------------------------------
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