akshatb1 commented on a change in pull request #3135:
URL: https://github.com/apache/hadoop/pull/3135#discussion_r658479871
##########
File path:
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java
##########
@@ -531,4 +536,107 @@ public void testGetClusterMetricsRequest() throws
YarnException, IOException {
GetClusterMetricsResponse.class);
Assert.assertEquals(true, clusterMetrics.isEmpty());
}
+
+ /**
+ * This test validates the correctness of
+ * GetApplicationsResponse in case the
+ * application exists in the cluster.
+ */
+ @Test
+ public void testGetApplicationsResponse()
+ throws YarnException, IOException, InterruptedException {
+ LOG.info("Test FederationClientInterceptor: " +
+ "Get Applications Response");
+ ApplicationId appId =
+ ApplicationId.newInstance(System.currentTimeMillis(), 1);
+
+ SubmitApplicationRequest request = mockSubmitApplicationRequest(appId);
+ SubmitApplicationResponse response =
interceptor.submitApplication(request);
+
+ Assert.assertNotNull(response);
+ Assert.assertNotNull(stateStoreUtil.queryApplicationHomeSC(appId));
+
+ Set<String> appTypes = Collections.singleton("MockApp");
+ GetApplicationsRequest requestGet =
+ GetApplicationsRequest.newInstance(appTypes);
+
+ GetApplicationsResponse responseGet =
+ interceptor.getApplications(requestGet);
+
+ Assert.assertNotNull(responseGet);
+ }
+
+ /**
+ * This test validates
+ * the correctness of GetApplicationsResponse in case of
+ * empty request.
+ */
+ @Test
+ public void testGetApplicationsNullRequest() throws Exception {
+ LOG.info("Test FederationClientInterceptor : Get Applications request");
+ LambdaTestUtils.intercept(YarnException.class,
+ "Missing getApplications request.",
+ () -> interceptor.getApplications(null));
+ }
+
+ /**
+ * This test validates
+ * the correctness of GetApplicationsResponse in case applications
+ * with given type does not exist.
+ */
+ @Test
+ public void testGetApplicationsApplicationTypeNotExists() throws Exception{
+ LOG.info("Test FederationClientInterceptor :" +
+ " Application with type does not exist");
+
+ ApplicationId appId =
+ ApplicationId.newInstance(System.currentTimeMillis(), 1);
+
+ SubmitApplicationRequest request = mockSubmitApplicationRequest(appId);
+ SubmitApplicationResponse response =
interceptor.submitApplication(request);
+
+ Assert.assertNotNull(response);
+ Assert.assertNotNull(stateStoreUtil.queryApplicationHomeSC(appId));
+
+ Set<String> appTypes = Collections.singleton("SPARK");
+
+ GetApplicationsResponse responseGet =
+ interceptor.getApplications(
+ GetApplicationsRequest.
+ newInstance(appTypes));
+
+ Assert.assertNotNull(responseGet);
+ Assert.assertEquals(0, responseGet.getApplicationList().size());
+ }
+
+ /**
+ * This test validates
+ * the correctness of GetApplicationsResponse in case applications
+ * with given YarnApplicationState does not exist.
+ */
+ @Test
+ public void testGetApplicationsApplicationStateNotExists() throws Exception{
+ LOG.info("Test FederationClientInterceptor :" +
+ " Application with state does not exist");
+
+ ApplicationId appId =
+ ApplicationId.newInstance(System.currentTimeMillis(), 1);
+
+ SubmitApplicationRequest request = mockSubmitApplicationRequest(appId);
+ SubmitApplicationResponse response =
interceptor.submitApplication(request);
+
+ Assert.assertNotNull(response);
+ Assert.assertNotNull(stateStoreUtil.queryApplicationHomeSC(appId));
+
+ EnumSet<YarnApplicationState> applicationStates = EnumSet.noneOf(
+ YarnApplicationState.class);
+ applicationStates.add(YarnApplicationState.KILLED);
+
+ GetApplicationsResponse responseGet =
+ interceptor.getApplications(
+ GetApplicationsRequest.
Review comment:
Done.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]