瀏覽代碼

Merge r1578487 from branch-2. YARN-1830. Fixed TestRMRestart#testQueueMetricsOnRMRestart failure due to race condition when app is submitted. Contributed by Zhijie Shen

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.4@1578488 13f79535-47bb-0310-9956-ffa450edef68
Jian He 11 年之前
父節點
當前提交
f57cd8657c

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -436,6 +436,9 @@ Release 2.4.0 - UNRELEASED
     YARN-1789. ApplicationSummary does not escape newlines in the app name
     (Tsuyoshi OZAWA via jlowe)
 
+    YARN-1830. Fixed TestRMRestart#testQueueMetricsOnRMRestart failure due to
+    race condition when app is submitted. (Zhijie Shen via jianhe)
+
 Release 2.3.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 5 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java

@@ -1614,7 +1614,7 @@ public class TestRMRestart {
   }
 
   @SuppressWarnings("resource")
-  @Test
+  @Test (timeout = 60000)
   public void testQueueMetricsOnRMRestart() throws Exception {
     conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS,
         YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS);
@@ -1674,15 +1674,14 @@ public class TestRMRestart {
             ContainerState.COMPLETE, "Killed AM container", 143);
     containerStatuses.add(containerStatus);
     nm1.registerNode(containerStatuses);
-    int timeoutSecs = 0;
-    while (loadedApp1.getAppAttempts().size() != 2 && timeoutSecs++ < 40) {;
+    while (loadedApp1.getAppAttempts().size() != 2) {
       Thread.sleep(200);
     }
-
-    assertQueueMetrics(qm2, 1, 1, 0, 0);
-    nm1.nodeHeartbeat(true);
     attempt1 = loadedApp1.getCurrentAppAttempt();
     attemptId1 = attempt1.getAppAttemptId();
+    rm2.waitForState(attemptId1, RMAppAttemptState.SCHEDULED);
+    assertQueueMetrics(qm2, 1, 1, 0, 0);
+    nm1.nodeHeartbeat(true);
     rm2.waitForState(attemptId1, RMAppAttemptState.ALLOCATED);
     assertQueueMetrics(qm2, 1, 0, 1, 0);
     am1 = rm2.sendAMLaunched(attempt1.getAppAttemptId());