Search in sources :

Example 1 with RequestContext

use of org.apache.hadoop.yarn.webapp.Controller.RequestContext in project hadoop by apache.

the class TestBlocks method testHsController.

/**
   * test HsController
   */
@Test
public void testHsController() throws Exception {
    AppContext ctx = mock(AppContext.class);
    ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
    when(ctx.getApplicationID()).thenReturn(appId);
    AppForTest app = new AppForTest(ctx);
    Configuration config = new Configuration();
    RequestContext requestCtx = mock(RequestContext.class);
    HsControllerForTest controller = new HsControllerForTest(app, config, requestCtx);
    controller.index();
    assertEquals("JobHistory", controller.get(Params.TITLE, ""));
    assertEquals(HsJobPage.class, controller.jobPage());
    assertEquals(HsCountersPage.class, controller.countersPage());
    assertEquals(HsTasksPage.class, controller.tasksPage());
    assertEquals(HsTaskPage.class, controller.taskPage());
    assertEquals(HsAttemptsPage.class, controller.attemptsPage());
    controller.set(AMParams.JOB_ID, "job_01_01");
    controller.set(AMParams.TASK_ID, "task_01_01_m_01");
    controller.set(AMParams.TASK_TYPE, "m");
    controller.set(AMParams.ATTEMPT_STATE, "State");
    Job job = mock(Job.class);
    Task task = mock(Task.class);
    when(job.getTask(any(TaskId.class))).thenReturn(task);
    JobId jobID = MRApps.toJobID("job_01_01");
    when(ctx.getJob(jobID)).thenReturn(job);
    when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class))).thenReturn(true);
    controller.job();
    assertEquals(HsJobPage.class, controller.getClazz());
    controller.jobCounters();
    assertEquals(HsCountersPage.class, controller.getClazz());
    controller.taskCounters();
    assertEquals(HsCountersPage.class, controller.getClazz());
    controller.tasks();
    assertEquals(HsTasksPage.class, controller.getClazz());
    controller.task();
    assertEquals(HsTaskPage.class, controller.getClazz());
    controller.attempts();
    assertEquals(HsAttemptsPage.class, controller.getClazz());
    assertEquals(HsConfPage.class, controller.confPage());
    assertEquals(HsAboutPage.class, controller.aboutPage());
    controller.about();
    assertEquals(HsAboutPage.class, controller.getClazz());
    controller.logs();
    assertEquals(HsLogsPage.class, controller.getClazz());
    controller.nmlogs();
    assertEquals(AggregatedLogsPage.class, controller.getClazz());
    assertEquals(HsSingleCounterPage.class, controller.singleCounterPage());
    controller.singleJobCounter();
    assertEquals(HsSingleCounterPage.class, controller.getClazz());
    controller.singleTaskCounter();
    assertEquals(HsSingleCounterPage.class, controller.getClazz());
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) Configuration(org.apache.hadoop.conf.Configuration) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) RequestContext(org.apache.hadoop.yarn.webapp.Controller.RequestContext) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) AppForTest(org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobACL(org.apache.hadoop.mapreduce.JobACL) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) Test(org.junit.Test) AppForTest(org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 JobACL (org.apache.hadoop.mapreduce.JobACL)1 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)1 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)1 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)1 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)1 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)1 AppForTest (org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 RequestContext (org.apache.hadoop.yarn.webapp.Controller.RequestContext)1 BlockForTest (org.apache.hadoop.yarn.webapp.view.BlockForTest)1 Test (org.junit.Test)1