slfan1989 commented on code in PR #4757:
URL: https://github.com/apache/hadoop/pull/4757#discussion_r952024447
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java:
##########
@@ -592,4 +594,92 @@ public static AppAttemptInfo generateAppAttemptInfo(int
attemptId) {
when(appAttemptInfo.getLogsLink()).thenReturn("LogLink_" + attemptId);
return appAttemptInfo;
}
+
+ @Test
+ public void testMergeApplicationStatisticsInfo() {
+ ApplicationStatisticsInfo infoA = new ApplicationStatisticsInfo();
+ ApplicationStatisticsInfo infoB = new ApplicationStatisticsInfo();
+
+ StatisticsItemInfo item1 =
+ new StatisticsItemInfo(YarnApplicationState.ACCEPTED, "*", 10);
+ StatisticsItemInfo item2 =
+ new StatisticsItemInfo(YarnApplicationState.ACCEPTED, "*", 20);
+
+ infoA.add(item1);
+ infoB.add(item2);
+
+ List<ApplicationStatisticsInfo> lists = new ArrayList<>();
+ lists.add(infoA);
+ lists.add(infoB);
+
+ ApplicationStatisticsInfo mergeInfo =
+ RouterWebServiceUtil.mergeApplicationStatisticsInfo(lists);
+ ArrayList<StatisticsItemInfo> statItem = mergeInfo.getStatItems();
+
+ Assert.assertNotNull(statItem);
+ Assert.assertEquals(1, statItem.size());
+
+ StatisticsItemInfo first = statItem.get(0);
+
+ Assert.assertEquals(item1.getCount() + item2.getCount(), first.getCount());
+ Assert.assertEquals(item1.getType(), first.getType());
+ Assert.assertEquals(item1.getState(), first.getState());
+ }
+
+ @Test
+ public void testMergeDiffApplicationStatisticsInfo() {
+ ApplicationStatisticsInfo infoA = new ApplicationStatisticsInfo();
+ StatisticsItemInfo item1 =
+ new StatisticsItemInfo(YarnApplicationState.ACCEPTED, "*", 10);
+ StatisticsItemInfo item2 =
+ new StatisticsItemInfo(YarnApplicationState.NEW_SAVING, "test1", 20);
+ infoA.add(item1);
+ infoA.add(item2);
+
+ ApplicationStatisticsInfo infoB = new ApplicationStatisticsInfo();
+ StatisticsItemInfo item3 =
+ new StatisticsItemInfo(YarnApplicationState.NEW_SAVING, "test1", 30);
+ StatisticsItemInfo item4 =
+ new StatisticsItemInfo(YarnApplicationState.FINISHED, "test3", 40);
+ infoB.add(item3);
+ infoB.add(item4);
+
+ List<ApplicationStatisticsInfo> lists = new ArrayList<>();
+ lists.add(infoA);
+ lists.add(infoB);
+
+ ApplicationStatisticsInfo mergeInfo =
+ RouterWebServiceUtil.mergeApplicationStatisticsInfo(lists);
+
+ Assert.assertEquals(3, mergeInfo.getStatItems().size());
+ ArrayList<StatisticsItemInfo> mergeInfoStatItems =
mergeInfo.getStatItems();
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]