slfan1989 commented on code in PR #5284:
URL: https://github.com/apache/hadoop/pull/5284#discussion_r1072908689
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java:
##########
@@ -1685,4 +1690,85 @@ public void testCancelDelegationToken() throws Exception
{
Assert.assertNotNull(cancelResponse);
Assert.assertEquals(response.getStatus(), Status.OK.getStatusCode());
}
+
+ @Test
+ public void testGetActivitiesNormal() {
+ ActivitiesInfo activitiesInfo = interceptor.getActivities(null, "1",
"DIAGNOSTIC");
+ Assert.assertNotNull(activitiesInfo);
+
+ String nodeId = activitiesInfo.getNodeId();
+ Assert.assertNotNull(nodeId);
+ Assert.assertEquals("1", nodeId);
+
+ String diagnostic = activitiesInfo.getDiagnostic();
+ Assert.assertNotNull(diagnostic);
+ Assert.assertTrue(StringUtils.contains(diagnostic, "Diagnostic"));
+
+ long timestamp = activitiesInfo.getTimestamp();
+ Assert.assertEquals(1673081972L, timestamp);
+
+ List<NodeAllocationInfo> allocationInfos = activitiesInfo.getAllocations();
+ Assert.assertNotNull(allocationInfos);
+ Assert.assertEquals(1, allocationInfos.size());
+ }
+
+ @Test
+ public void testGetActivitiesError() throws Exception {
+ // nodeId is empty
+ LambdaTestUtils.intercept(IllegalArgumentException.class,
+ "'nodeId' must not be empty.",
+ () -> interceptor.getActivities(null, "", "DIAGNOSTIC"));
+
+ // groupBy is empty
+ LambdaTestUtils.intercept(IllegalArgumentException.class,
+ "'groupBy' must not be empty.",
+ () -> interceptor.getActivities(null, "1", ""));
+
+ // groupBy value is wrong
+ LambdaTestUtils.intercept(IllegalArgumentException.class,
+ "Got invalid groupBy: TEST1, valid groupBy types: [DIAGNOSTIC]",
+ () -> interceptor.getActivities(null, "1", "TEST1"));
+ }
+
+ @Test
+ public void testGetBulkActivitiesNormal() throws InterruptedException {
+ BulkActivitiesInfo bulkActivitiesInfo =
+ interceptor.getBulkActivities(null, "DIAGNOSTIC", 5);
+ Assert.assertNotNull(bulkActivitiesInfo);
+
+ Assert.assertTrue(bulkActivitiesInfo instanceof
FederationBulkActivitiesInfo);
+
+ FederationBulkActivitiesInfo federationBulkActivitiesInfo =
+ FederationBulkActivitiesInfo.class.cast(bulkActivitiesInfo);
+ Assert.assertNotNull(federationBulkActivitiesInfo);
+
+ List<BulkActivitiesInfo> activitiesInfos =
federationBulkActivitiesInfo.getList();
+ Assert.assertNotNull(activitiesInfos);
+ Assert.assertTrue(activitiesInfos.size() == 4);
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]