slfan1989 commented on code in PR #4764:
URL: https://github.com/apache/hadoop/pull/4764#discussion_r954527995
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java:
##########
@@ -1254,4 +1275,250 @@ public void testNodesToAttributes() throws Exception {
NodeAttributeType.STRING, "nvida");
Assert.assertTrue(nodeAttributeMap.get("0-host1").contains(gpu));
}
+
+ @Test
+ public void testGetNewReservation() throws Exception {
+ LOG.info("Test FederationClientInterceptor : Get NewReservation request.");
+
+ // null request
+ LambdaTestUtils.intercept(YarnException.class,
+ "Missing getNewReservation request.", () ->
interceptor.getNewReservation(null));
+
+ // normal request
+ GetNewReservationRequest request = GetNewReservationRequest.newInstance();
+ GetNewReservationResponse response =
interceptor.getNewReservation(request);
+ Assert.assertNotNull(response);
+
+ ReservationId reservationId = response.getReservationId();
+ Assert.assertNotNull(reservationId);
+ Assert.assertTrue(reservationId.toString().contains("reservation"));
+ Assert.assertEquals(reservationId.getClusterTimestamp(),
ResourceManager.getClusterTimeStamp());
+ }
+
+ @Test
+ public void testSubmitReservation() throws Exception {
+ LOG.info("Test FederationClientInterceptor : SubmitReservation request.");
+
+ // get new reservationId
+ GetNewReservationRequest request = GetNewReservationRequest.newInstance();
+ GetNewReservationResponse response =
interceptor.getNewReservation(request);
+ Assert.assertNotNull(response);
+
+ // allow plan follower to synchronize, manually trigger an assignment
+ Map<SubClusterId, MockRM> mockRMs = interceptor.getMockRMs();
+ for (MockRM mockRM : mockRMs.values()) {
+ ReservationSystem reservationSystem = mockRM.getReservationSystem();
+ reservationSystem.synchronizePlan("root.decided", true);
+ }
+
+ // Submit Reservation
+ ReservationId reservationId = response.getReservationId();
+ ReservationDefinition rDefinition = createReservationDefinition(1024, 1);
+ ReservationSubmissionRequest rSubmissionRequest =
ReservationSubmissionRequest.newInstance(
+ rDefinition, "decided", reservationId);
+
+ ReservationSubmissionResponse submissionResponse =
+ interceptor.submitReservation(rSubmissionRequest);
+ Assert.assertNotNull(submissionResponse);
+
+ SubClusterId subClusterId =
stateStoreUtil.queryReservationHomeSC(reservationId);
+ Assert.assertNotNull(subClusterId);
+ Assert.assertTrue(subClusters.contains(subClusterId));
+ }
+
+ @Test
+ public void testSubmitReservationEmptyRequest() throws Exception {
+ LOG.info("Test FederationClientInterceptor : SubmitReservation request
empty.");
+
+ // null request1
+ LambdaTestUtils.intercept(YarnException.class,
+ "Missing submitReservation request or reservationId or reservation
definition or queue.",
+ () -> interceptor.submitReservation(null));
+
+ // null request2
+ LambdaTestUtils.intercept(YarnException.class,
+ "Missing submitReservation request or reservationId or reservation
definition or queue.",
+ () -> interceptor.submitReservation(
+ ReservationSubmissionRequest.newInstance(null, null, null)));
Review Comment:
I will fix it.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]