Search in sources :

Example 21 with MockAppContext

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

the class TestAMWebApp method testCountersView.

@Test
public void testCountersView() {
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = getJobParams(appContext);
    WebAppTests.testPage(CountersPage.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 22 with MockAppContext

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

the class TestHSWebApp method testAttemptsWithJobView.

@Test
public void testAttemptsWithJobView() {
    LOG.info("HsAttemptsPage with data");
    MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
    JobId id = ctx.getAllJobs().keySet().iterator().next();
    Map<String, String> params = new HashMap<String, String>();
    params.put(JOB_ID, id.toString());
    params.put(TASK_TYPE, "m");
    params.put(ATTEMPT_STATE, "SUCCESSFUL");
    WebAppTests.testPage(HsAttemptsPage.class, AppContext.class, ctx, params);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) HashMap(java.util.HashMap) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) Test(org.junit.Test)

Example 23 with MockAppContext

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

the class TestHSWebApp method testTasksViewNaturalSortType.

@Test
public void testTasksViewNaturalSortType() {
    LOG.info("HsTasksPage");
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
    Injector testPage = WebAppTests.testPage(HsTasksPage.class, AppContext.class, appContext, params);
    View viewInstance = testPage.getInstance(HsTasksPage.class);
    Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
    String appTableColumnsMeta = moreParams.get("ui.dataTables.selector.init");
    Assert.assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) View(org.apache.hadoop.yarn.webapp.View) Test(org.junit.Test)

Example 24 with MockAppContext

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

the class TestHSWebApp method testJobCounterViewForKilledJob.

@Test
public void testJobCounterViewForKilledJob() {
    LOG.info("JobCounterViewForKilledJob");
    AppContext appContext = new MockAppContext(0, 1, 1, 1, true);
    Map<String, String> params = TestAMWebApp.getJobParams(appContext);
    WebAppTests.testPage(HsCountersPage.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 25 with MockAppContext

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

the class TestHSWebApp method testLogsViewSingle.

@Test
public void testLogsViewSingle() throws IOException {
    LOG.info("HsLogsPage with params for single log and data limits");
    MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = new HashMap<String, String>();
    final Configuration conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
    params.put("start", "-2048");
    params.put("end", "-1024");
    params.put(CONTAINER_LOG_TYPE, "syslog");
    params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1).toString());
    params.put(NM_NODENAME, NodeId.newInstance(MockJobs.NM_HOST, MockJobs.NM_PORT).toString());
    params.put(ENTITY_STRING, "container_10_0001_01_000001");
    params.put(APP_OWNER, "owner");
    Injector injector = WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, ctx, params, new AbstractModule() {

        @Override
        protected void configure() {
            bind(Configuration.class).toInstance(conf);
        }
    });
    PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
    verify(spyPw).write("Logs not available for container_10_0001_01_000001." + " Aggregation may not be complete, " + "Check back later or try the nodemanager at " + MockJobs.NM_HOST + ":" + MockJobs.NM_PORT);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HashMap(java.util.HashMap) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Injector(com.google.inject.Injector) AbstractModule(com.google.inject.AbstractModule) PrintWriter(java.io.PrintWriter) 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