YARN-2758. Update TestApplicationHistoryClientService to use the new generic history store. Contributed by Zhijie Shen

This commit is contained in:
Xuan 2014-10-28 13:28:42 -07:00
parent e226b5b40d
commit 69f79bee8b
2 changed files with 36 additions and 67 deletions

View File

@ -781,6 +781,9 @@ Release 2.6.0 - UNRELEASED
YARN-2279. Add UTs to cover timeline server authentication. YARN-2279. Add UTs to cover timeline server authentication.
(Zhijie Shen via xgong) (Zhijie Shen via xgong)
YARN-2758. Update TestApplicationHistoryClientService to use the new generic
history store. (Zhijie Shen via xgong)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -21,8 +21,6 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse;
@ -44,57 +42,48 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils; import org.apache.hadoop.yarn.server.timeline.TimelineDataManager;
import org.junit.After; import org.apache.hadoop.yarn.server.timeline.TimelineStore;
import org.junit.Before; import org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class TestApplicationHistoryClientService extends public class TestApplicationHistoryClientService {
ApplicationHistoryStoreTestUtils {
ApplicationHistoryServer historyServer = null; private static ApplicationHistoryClientService clientService;
String expectedLogUrl = null;
@Before @BeforeClass
public void setup() { public static void setup() throws Exception {
historyServer = new ApplicationHistoryServer(); Configuration conf = new YarnConfiguration();
Configuration config = new YarnConfiguration(); TimelineStore store =
expectedLogUrl = WebAppUtils.getHttpSchemePrefix(config) + TestApplicationHistoryManagerOnTimelineStore.createStore(2);
WebAppUtils.getAHSWebAppURLWithoutScheme(config) + TimelineACLsManager aclsManager = new TimelineACLsManager(conf);
"/applicationhistory/logs/localhost:0/container_0_0001_01_000001/" + TimelineDataManager dataManager =
"container_0_0001_01_000001/test user"; new TimelineDataManager(store, aclsManager);
config.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true); ApplicationACLsManager appAclsManager = new ApplicationACLsManager(conf);
config.setClass(YarnConfiguration.APPLICATION_HISTORY_STORE, ApplicationHistoryManagerOnTimelineStore historyManager =
MemoryApplicationHistoryStore.class, ApplicationHistoryStore.class); new ApplicationHistoryManagerOnTimelineStore(dataManager, appAclsManager);
historyServer.init(config); historyManager.init(conf);
historyServer.start(); historyManager.start();
store = clientService = new ApplicationHistoryClientService(historyManager);
((ApplicationHistoryManagerImpl) historyServer.getApplicationHistoryManager())
.getHistoryStore();
}
@After
public void tearDown() throws Exception {
historyServer.stop();
} }
@Test @Test
public void testApplicationReport() throws IOException, YarnException { public void testApplicationReport() throws IOException, YarnException {
ApplicationId appId = null; ApplicationId appId = null;
appId = ApplicationId.newInstance(0, 1); appId = ApplicationId.newInstance(0, 1);
writeApplicationStartData(appId);
writeApplicationFinishData(appId);
GetApplicationReportRequest request = GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(appId); GetApplicationReportRequest.newInstance(appId);
GetApplicationReportResponse response = GetApplicationReportResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getApplicationReport(request);
.getApplicationReport(request);
ApplicationReport appReport = response.getApplicationReport(); ApplicationReport appReport = response.getApplicationReport();
Assert.assertNotNull(appReport); Assert.assertNotNull(appReport);
Assert.assertEquals("application_0_0001", appReport.getApplicationId() Assert.assertEquals("application_0_0001", appReport.getApplicationId()
.toString()); .toString());
Assert.assertEquals("test type", appReport.getApplicationType().toString()); Assert.assertEquals("test app type",
appReport.getApplicationType().toString());
Assert.assertEquals("test queue", appReport.getQueue().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString());
} }
@ -102,15 +91,10 @@ public class TestApplicationHistoryClientService extends
public void testApplications() throws IOException, YarnException { public void testApplications() throws IOException, YarnException {
ApplicationId appId = null; ApplicationId appId = null;
appId = ApplicationId.newInstance(0, 1); appId = ApplicationId.newInstance(0, 1);
writeApplicationStartData(appId);
writeApplicationFinishData(appId);
ApplicationId appId1 = ApplicationId.newInstance(0, 2); ApplicationId appId1 = ApplicationId.newInstance(0, 2);
writeApplicationStartData(appId1);
writeApplicationFinishData(appId1);
GetApplicationsRequest request = GetApplicationsRequest.newInstance(); GetApplicationsRequest request = GetApplicationsRequest.newInstance();
GetApplicationsResponse response = GetApplicationsResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getApplications(request);
.getApplications(request);
List<ApplicationReport> appReport = response.getApplicationList(); List<ApplicationReport> appReport = response.getApplicationList();
Assert.assertNotNull(appReport); Assert.assertNotNull(appReport);
Assert.assertEquals(appId, appReport.get(0).getApplicationId()); Assert.assertEquals(appId, appReport.get(0).getApplicationId());
@ -122,13 +106,10 @@ public class TestApplicationHistoryClientService extends
ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptId.newInstance(appId, 1);
writeApplicationAttemptStartData(appAttemptId);
writeApplicationAttemptFinishData(appAttemptId);
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(appAttemptId); GetApplicationAttemptReportRequest.newInstance(appAttemptId);
GetApplicationAttemptReportResponse response = GetApplicationAttemptReportResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getApplicationAttemptReport(request);
.getApplicationAttemptReport(request);
ApplicationAttemptReport attemptReport = ApplicationAttemptReport attemptReport =
response.getApplicationAttemptReport(); response.getApplicationAttemptReport();
Assert.assertNotNull(attemptReport); Assert.assertNotNull(attemptReport);
@ -143,15 +124,10 @@ public class TestApplicationHistoryClientService extends
ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptId.newInstance(appId, 1);
ApplicationAttemptId appAttemptId1 = ApplicationAttemptId appAttemptId1 =
ApplicationAttemptId.newInstance(appId, 2); ApplicationAttemptId.newInstance(appId, 2);
writeApplicationAttemptStartData(appAttemptId);
writeApplicationAttemptFinishData(appAttemptId);
writeApplicationAttemptStartData(appAttemptId1);
writeApplicationAttemptFinishData(appAttemptId1);
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(appId); GetApplicationAttemptsRequest.newInstance(appId);
GetApplicationAttemptsResponse response = GetApplicationAttemptsResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getApplicationAttempts(request);
.getApplicationAttempts(request);
List<ApplicationAttemptReport> attemptReports = List<ApplicationAttemptReport> attemptReports =
response.getApplicationAttemptList(); response.getApplicationAttemptList();
Assert.assertNotNull(attemptReports); Assert.assertNotNull(attemptReports);
@ -164,42 +140,32 @@ public class TestApplicationHistoryClientService extends
@Test @Test
public void testContainerReport() throws IOException, YarnException { public void testContainerReport() throws IOException, YarnException {
ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationId appId = ApplicationId.newInstance(0, 1);
writeApplicationStartData(appId);
ApplicationAttemptId appAttemptId = ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
writeApplicationFinishData(appId);
GetContainerReportRequest request = GetContainerReportRequest request =
GetContainerReportRequest.newInstance(containerId); GetContainerReportRequest.newInstance(containerId);
GetContainerReportResponse response = GetContainerReportResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getContainerReport(request);
.getContainerReport(request);
ContainerReport container = response.getContainerReport(); ContainerReport container = response.getContainerReport();
Assert.assertNotNull(container); Assert.assertNotNull(container);
Assert.assertEquals(containerId, container.getContainerId()); Assert.assertEquals(containerId, container.getContainerId());
Assert.assertEquals(expectedLogUrl, container.getLogUrl()); Assert.assertEquals("http://0.0.0.0:8188/applicationhistory/logs/" +
"test host:100/container_0_0001_01_000001/" +
"container_0_0001_01_000001/user1", container.getLogUrl());
} }
@Test @Test
public void testContainers() throws IOException, YarnException { public void testContainers() throws IOException, YarnException {
ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationId appId = ApplicationId.newInstance(0, 1);
writeApplicationStartData(appId);
ApplicationAttemptId appAttemptId = ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
ContainerId containerId1 = ContainerId.newInstance(appAttemptId, 2); ContainerId containerId1 = ContainerId.newInstance(appAttemptId, 2);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
writeContainerStartData(containerId1);
writeContainerFinishData(containerId1);
writeApplicationFinishData(appId);
GetContainersRequest request = GetContainersRequest request =
GetContainersRequest.newInstance(appAttemptId); GetContainersRequest.newInstance(appAttemptId);
GetContainersResponse response = GetContainersResponse response =
historyServer.getClientService().getClientHandler() clientService.getClientHandler().getContainers(request);
.getContainers(request);
List<ContainerReport> containers = response.getContainerList(); List<ContainerReport> containers = response.getContainerList();
Assert.assertNotNull(containers); Assert.assertNotNull(containers);
Assert.assertEquals(containerId, containers.get(1).getContainerId()); Assert.assertEquals(containerId, containers.get(1).getContainerId());