Search in sources :

Example 11 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestHSWebApp method testTaskView.

@Test
public void testTaskView() {
    LOG.info("HsTaskPage");
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
    WebAppTests.testPage(HsTaskPage.class, AppContext.class, appContext, params);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Example 12 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestHSWebApp method testTasksView.

@Test
public void testTasksView() {
    LOG.info("HsTasksPage");
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
    WebAppTests.testPage(HsTasksPage.class, AppContext.class, appContext, params);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Example 13 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestHSWebApp method testLogsView1.

@Test
public void testLogsView1() throws IOException {
    LOG.info("HsLogsPage");
    Injector injector = WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, new MockAppContext(0, 1, 1, 1));
    PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
    verify(spyPw).write("Cannot get container logs without a ContainerId");
    verify(spyPw).write("Cannot get container logs without a NodeId");
    verify(spyPw).write("Cannot get container logs without an app owner");
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 14 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class JHEventHandlerForSigtermTest method mockAppContext.

private AppContext mockAppContext(Class<? extends AppContext> contextClass, ApplicationId appId, boolean isLastAMRetry) {
    JobId jobId = TypeConverter.toYarn(TypeConverter.fromYarn(appId));
    AppContext mockContext = mock(contextClass);
    Job mockJob = mockJob();
    when(mockContext.getJob(jobId)).thenReturn(mockJob);
    when(mockContext.getApplicationID()).thenReturn(appId);
    when(mockContext.isLastAMRetry()).thenReturn(isLastAMRetry);
    if (mockContext instanceof RunningAppContext) {
        when(((RunningAppContext) mockContext).getTimelineClient()).thenReturn(TimelineClient.createTimelineClient());
        when(((RunningAppContext) mockContext).getTimelineV2Client()).thenReturn(TimelineV2Client.createTimelineClient(ApplicationId.newInstance(0, 1)));
    }
    return mockContext;
}
Also used : RunningAppContext(org.apache.hadoop.mapreduce.v2.app.MRAppMaster.RunningAppContext) RunningAppContext(org.apache.hadoop.mapreduce.v2.app.MRAppMaster.RunningAppContext) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId)

Example 15 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testJobView.

@Test
public void testJobView() {
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = getJobParams(appContext);
    WebAppTests.testPage(JobPage.class, AppContext.class, appContext, params);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Aggregations

MockAppContext (org.apache.hadoop.mapreduce.v2.app.MockAppContext)25 Test (org.junit.Test)25 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)17 Injector (com.google.inject.Injector)8 PrintWriter (java.io.PrintWriter)4 HashMap (java.util.HashMap)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)3 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)2 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 View (org.apache.hadoop.yarn.webapp.View)2 AbstractModule (com.google.inject.AbstractModule)1 Configuration (org.apache.hadoop.conf.Configuration)1 MRApp (org.apache.hadoop.mapreduce.v2.app.MRApp)1 RunningAppContext (org.apache.hadoop.mapreduce.v2.app.MRAppMaster.RunningAppContext)1 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1