YARN-2812. TestApplicationHistoryServer is likely to fail on less powerful machine. Contributed by Zhijie Shen

(cherry picked from commit b0b52c4e11)
This commit is contained in:
Xuan 2014-11-05 20:42:38 -08:00
parent ee44d8fb3f
commit 4aa98d5991
2 changed files with 48 additions and 32 deletions

View File

@ -847,6 +847,9 @@ Release 2.6.0 - UNRELEASED
YARN-2813. Fixed NPE from MemoryTimelineStore.getDomains. (Zhijie Shen via xgong) 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 Release 2.5.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -29,6 +29,8 @@ import org.apache.hadoop.service.Service.STATE;
import org.apache.hadoop.util.ExitUtil; import org.apache.hadoop.util.ExitUtil;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp; 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.apache.hadoop.yarn.server.timeline.security.TimelineAuthenticationFilterInitializer;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -38,45 +40,56 @@ import java.util.Map;
public class TestApplicationHistoryServer { public class TestApplicationHistoryServer {
ApplicationHistoryServer historyServer = null;
// simple test init/start/stop ApplicationHistoryServer. Status should change. // simple test init/start/stop ApplicationHistoryServer. Status should change.
@Test(timeout = 50000) @Test(timeout = 60000)
public void testStartStopServer() throws Exception { public void testStartStopServer() throws Exception {
historyServer = new ApplicationHistoryServer(); ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
Configuration config = new YarnConfiguration(); Configuration config = new YarnConfiguration();
historyServer.init(config); config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
assertEquals(STATE.INITED, historyServer.getServiceState()); MemoryTimelineStore.class, TimelineStore.class);
assertEquals(5, historyServer.getServices().size()); config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0");
ApplicationHistoryClientService historyService = try {
historyServer.getClientService(); historyServer.init(config);
assertNotNull(historyServer.getClientService()); assertEquals(STATE.INITED, historyServer.getServiceState());
assertEquals(STATE.INITED, historyService.getServiceState()); assertEquals(5, historyServer.getServices().size());
ApplicationHistoryClientService historyService =
historyServer.getClientService();
assertNotNull(historyServer.getClientService());
assertEquals(STATE.INITED, historyService.getServiceState());
historyServer.start(); historyServer.start();
assertEquals(STATE.STARTED, historyServer.getServiceState()); assertEquals(STATE.STARTED, historyServer.getServiceState());
assertEquals(STATE.STARTED, historyService.getServiceState()); assertEquals(STATE.STARTED, historyService.getServiceState());
historyServer.stop(); historyServer.stop();
assertEquals(STATE.STOPPED, historyServer.getServiceState()); assertEquals(STATE.STOPPED, historyServer.getServiceState());
} finally {
historyServer.stop();
}
} }
// test launch method // test launch method
@Test(timeout = 60000) @Test(timeout = 60000)
public void testLaunch() throws Exception { public void testLaunch() throws Exception {
ExitUtil.disableSystemExit(); ExitUtil.disableSystemExit();
ApplicationHistoryServer historyServer = null;
try { try {
// Not able to modify the config of this test case,
// but others have been customized to avoid conflicts
historyServer = historyServer =
ApplicationHistoryServer.launchAppHistoryServer(new String[0]); ApplicationHistoryServer.launchAppHistoryServer(new String[0]);
} catch (ExitUtil.ExitException e) { } catch (ExitUtil.ExitException e) {
assertEquals(0, e.status); assertEquals(0, e.status);
ExitUtil.resetFirstExitException(); ExitUtil.resetFirstExitException();
fail(); fail();
} finally {
if (historyServer != null) {
historyServer.stop();
}
} }
} }
@Test(timeout = 50000) @Test(timeout = 240000)
public void testFilteOverrides() throws Exception { public void testFilterOverrides() throws Exception {
HashMap<String, String> driver = new HashMap<String, String>(); HashMap<String, String> driver = new HashMap<String, String>();
driver.put("", TimelineAuthenticationFilterInitializer.class.getName()); driver.put("", TimelineAuthenticationFilterInitializer.class.getName());
@ -97,21 +110,21 @@ public class TestApplicationHistoryServer {
for (Map.Entry<String, String> entry : driver.entrySet()) { for (Map.Entry<String, String> entry : driver.entrySet()) {
String filterInitializer = entry.getKey(); String filterInitializer = entry.getKey();
String expectedValue = entry.getValue(); String expectedValue = entry.getValue();
historyServer = new ApplicationHistoryServer(); ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
Configuration config = new YarnConfiguration(); Configuration config = new YarnConfiguration();
config.set("hadoop.http.filter.initializers", filterInitializer); config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
historyServer.init(config); MemoryTimelineStore.class, TimelineStore.class);
historyServer.start(); config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0");
Configuration tmp = historyServer.getConfig(); try {
assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers")); config.set("hadoop.http.filter.initializers", filterInitializer);
historyServer.stop(); 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();
}
}
} }