Browse Source

YARN-4320. TestJobHistoryEventHandler fails as AHS in MiniYarnCluster no longer binds to default port 8188. Contributed by Varun Saxena.

(cherry picked from commit ce31b22739512804da38cf87e0ce1059e3128da3)
Tsuyoshi Ozawa 9 years ago
parent
commit
6b27de0f36

+ 7 - 3
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java

@@ -446,9 +446,6 @@ public class TestJobHistoryEventHandler {
     TestParams t = new TestParams(false);
     TestParams t = new TestParams(false);
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
-    conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, true);
-    JHEvenHandlerForTest jheh = new JHEvenHandlerForTest(t.mockAppContext, 0);
-    jheh.init(conf);
     MiniYARNCluster yarnCluster = null;
     MiniYARNCluster yarnCluster = null;
     long currentTime = System.currentTimeMillis();
     long currentTime = System.currentTimeMillis();
     try {
     try {
@@ -456,6 +453,13 @@ public class TestJobHistoryEventHandler {
             TestJobHistoryEventHandler.class.getSimpleName(), 1, 1, 1, 1);
             TestJobHistoryEventHandler.class.getSimpleName(), 1, 1, 1, 1);
       yarnCluster.init(conf);
       yarnCluster.init(conf);
       yarnCluster.start();
       yarnCluster.start();
+      Configuration confJHEH = new YarnConfiguration(conf);
+      confJHEH.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, true);
+      confJHEH.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
+          MiniYARNCluster.getHostname() + ":" +
+          yarnCluster.getApplicationHistoryServer().getPort());
+      JHEvenHandlerForTest jheh = new JHEvenHandlerForTest(t.mockAppContext, 0);
+      jheh.init(confJHEH);
       jheh.start();
       jheh.start();
       TimelineStore ts = yarnCluster.getApplicationHistoryServer()
       TimelineStore ts = yarnCluster.getApplicationHistoryServer()
               .getTimelineStore();
               .getTimelineStore();

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

@@ -18,6 +18,9 @@ Release 2.6.3 - UNRELEASED
     YARN-4312. TestSubmitApplicationWithRMHA fails on branch-2.7 and branch-2.6
     YARN-4312. TestSubmitApplicationWithRMHA fails on branch-2.7 and branch-2.6
     as some of the test cases time out. (Varun Saxena via ozawa)
     as some of the test cases time out. (Varun Saxena via ozawa)
 
 
+    YARN-4320. TestJobHistoryEventHandler fails as AHS in MiniYarnCluster no longer
+    binds to default port 8188. (Varun Saxena via ozawa)
+
 Release 2.6.2 - 2015-10-28
 Release 2.6.2 - 2015-10-28
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 6 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java

@@ -127,6 +127,12 @@ public class ApplicationHistoryServer extends CompositeService {
     return this.ahsClientService;
     return this.ahsClientService;
   }
   }
 
 
+  @Private
+  @VisibleForTesting
+  public int getPort() {
+    return this.webApp.httpServer().getConnectorAddress(0).getPort();
+  }
+
   /**
   /**
    * @return ApplicationTimelineStore
    * @return ApplicationTimelineStore
    */
    */