From b0b52c4e11336ca2ad6a02d64c0b5d5a8f1339ae Mon Sep 17 00:00:00 2001 From: Xuan Date: Wed, 5 Nov 2014 20:42:38 -0800 Subject: [PATCH] YARN-2812. TestApplicationHistoryServer is likely to fail on less powerful machine. Contributed by Zhijie Shen --- hadoop-yarn-project/CHANGES.txt | 3 + .../TestApplicationHistoryServer.java | 77 +++++++++++-------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index d65860cdb25..aefc59f0a55 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -874,6 +874,9 @@ Release 2.6.0 - UNRELEASED YARN-2813. Fixed NPE from MemoryTimelineStore.getDomains. (Zhijie Shen via xgong) + YARN-2812. TestApplicationHistoryServer is likely to fail on less powerful machine. + (Zhijie Shen via xgong) + Release 2.5.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryServer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryServer.java index b11cda769d2..7a4062d9a8b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryServer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryServer.java @@ -29,6 +29,8 @@ import org.apache.hadoop.service.Service.STATE; import org.apache.hadoop.util.ExitUtil; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp; +import org.apache.hadoop.yarn.server.timeline.MemoryTimelineStore; +import org.apache.hadoop.yarn.server.timeline.TimelineStore; import org.apache.hadoop.yarn.server.timeline.security.TimelineAuthenticationFilterInitializer; import org.junit.After; import org.junit.Test; @@ -38,45 +40,56 @@ import java.util.Map; public class TestApplicationHistoryServer { - ApplicationHistoryServer historyServer = null; - // simple test init/start/stop ApplicationHistoryServer. Status should change. - @Test(timeout = 50000) + @Test(timeout = 60000) public void testStartStopServer() throws Exception { - historyServer = new ApplicationHistoryServer(); + ApplicationHistoryServer historyServer = new ApplicationHistoryServer(); Configuration config = new YarnConfiguration(); - historyServer.init(config); - assertEquals(STATE.INITED, historyServer.getServiceState()); - assertEquals(5, historyServer.getServices().size()); - ApplicationHistoryClientService historyService = - historyServer.getClientService(); - assertNotNull(historyServer.getClientService()); - assertEquals(STATE.INITED, historyService.getServiceState()); + config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE, + MemoryTimelineStore.class, TimelineStore.class); + config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0"); + try { + historyServer.init(config); + assertEquals(STATE.INITED, historyServer.getServiceState()); + assertEquals(5, historyServer.getServices().size()); + ApplicationHistoryClientService historyService = + historyServer.getClientService(); + assertNotNull(historyServer.getClientService()); + assertEquals(STATE.INITED, historyService.getServiceState()); - historyServer.start(); - assertEquals(STATE.STARTED, historyServer.getServiceState()); - assertEquals(STATE.STARTED, historyService.getServiceState()); - historyServer.stop(); - assertEquals(STATE.STOPPED, historyServer.getServiceState()); + historyServer.start(); + assertEquals(STATE.STARTED, historyServer.getServiceState()); + assertEquals(STATE.STARTED, historyService.getServiceState()); + historyServer.stop(); + assertEquals(STATE.STOPPED, historyServer.getServiceState()); + } finally { + historyServer.stop(); + } } // test launch method @Test(timeout = 60000) public void testLaunch() throws Exception { - ExitUtil.disableSystemExit(); + ApplicationHistoryServer historyServer = null; try { + // Not able to modify the config of this test case, + // but others have been customized to avoid conflicts historyServer = ApplicationHistoryServer.launchAppHistoryServer(new String[0]); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); + } finally { + if (historyServer != null) { + historyServer.stop(); + } } } - @Test(timeout = 50000) - public void testFilteOverrides() throws Exception { + @Test(timeout = 240000) + public void testFilterOverrides() throws Exception { HashMap driver = new HashMap(); driver.put("", TimelineAuthenticationFilterInitializer.class.getName()); @@ -97,21 +110,21 @@ public class TestApplicationHistoryServer { for (Map.Entry entry : driver.entrySet()) { String filterInitializer = entry.getKey(); String expectedValue = entry.getValue(); - historyServer = new ApplicationHistoryServer(); + ApplicationHistoryServer historyServer = new ApplicationHistoryServer(); Configuration config = new YarnConfiguration(); - config.set("hadoop.http.filter.initializers", filterInitializer); - historyServer.init(config); - historyServer.start(); - Configuration tmp = historyServer.getConfig(); - assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers")); - historyServer.stop(); + config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE, + MemoryTimelineStore.class, TimelineStore.class); + config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0"); + try { + config.set("hadoop.http.filter.initializers", filterInitializer); + historyServer.init(config); + historyServer.start(); + Configuration tmp = historyServer.getConfig(); + assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers")); + } finally { + historyServer.stop(); + } } } - @After - public void stop() { - if (historyServer != null) { - historyServer.stop(); - } - } }