Search in sources :

Example 11 with BlockForTest

use of org.apache.hadoop.yarn.webapp.view.BlockForTest in project hadoop by apache.

the class TestBlocks method testHsTasksBlock.

/**
   * test HsTasksBlock's rendering.
   */
@Test
public void testHsTasksBlock() {
    Task task = getTask(0);
    Map<TaskId, Task> tasks = new HashMap<TaskId, Task>();
    tasks.put(task.getID(), task);
    AppContext ctx = mock(AppContext.class);
    AppForTest app = new AppForTest(ctx);
    Job job = mock(Job.class);
    when(job.getTasks()).thenReturn(tasks);
    app.setJob(job);
    HsTasksBlockForTest block = new HsTasksBlockForTest(app);
    block.addParameter(AMParams.TASK_TYPE, "r");
    PrintWriter pWriter = new PrintWriter(data);
    Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);
    block.render(html);
    pWriter.flush();
    // should be printed information about task
    assertTrue(data.toString().contains("task_0_0001_r_000000"));
    assertTrue(data.toString().contains("SUCCEEDED"));
    assertTrue(data.toString().contains("100001"));
    assertTrue(data.toString().contains("100011"));
    assertTrue(data.toString().contains(""));
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) HashMap(java.util.HashMap) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) HtmlBlock(org.apache.hadoop.yarn.webapp.view.HtmlBlock) Block(org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block) AttemptsBlock(org.apache.hadoop.mapreduce.v2.hs.webapp.HsTaskPage.AttemptsBlock) AppForTest(org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) PrintWriter(java.io.PrintWriter) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) Test(org.junit.Test) AppForTest(org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest)

Example 12 with BlockForTest

use of org.apache.hadoop.yarn.webapp.view.BlockForTest in project hadoop by apache.

the class TestHsJobBlock method createBlockToCreateTo.

private static HtmlBlock.Block createBlockToCreateTo(OutputStream outputStream) {
    PrintWriter printWriter = new PrintWriter(outputStream);
    HtmlBlock html = new HtmlBlockForTest();
    return new BlockForTest(html, printWriter, 10, false) {

        @Override
        protected void subView(Class<? extends SubView> cls) {
        }
    };
}
Also used : HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) HtmlBlock(org.apache.hadoop.yarn.webapp.view.HtmlBlock) SubView(org.apache.hadoop.yarn.webapp.SubView) PrintWriter(java.io.PrintWriter) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest)

Example 13 with BlockForTest

use of org.apache.hadoop.yarn.webapp.view.BlockForTest in project hadoop by apache.

the class TestAggregatedLogsBlock method testNoLogs.

/**
   * Log files was deleted.
   * @throws Exception
   */
@Test
public void testNoLogs() throws Exception {
    FileUtil.fullyDelete(new File("target/logs"));
    Configuration configuration = getConfiguration();
    File f = new File("target/logs/logs/application_0_0001/container_0_0001_01_000001");
    if (!f.exists()) {
        assertTrue(f.mkdirs());
    }
    writeLog(configuration, "admin");
    AggregatedLogsBlockForTest aggregatedBlock = getAggregatedLogsBlockForTest(configuration, "admin", "container_0_0001_01_000001");
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter(data);
    HtmlBlock html = new HtmlBlockForTest();
    HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
    aggregatedBlock.render(block);
    block.getWriter().flush();
    String out = data.toString();
    assertTrue(out.contains("No logs available for container container_0_0001_01_000001"));
}
Also used : HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HtmlBlock(org.apache.hadoop.yarn.webapp.view.HtmlBlock) File(java.io.File) PrintWriter(java.io.PrintWriter) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) Test(org.junit.Test)

Example 14 with BlockForTest

use of org.apache.hadoop.yarn.webapp.view.BlockForTest in project hadoop by apache.

the class TestAggregatedLogsBlock method testBadLogs.

/**
   * try to read bad logs
   * 
   * @throws Exception
   */
@Test
public void testBadLogs() throws Exception {
    FileUtil.fullyDelete(new File("target/logs"));
    Configuration configuration = getConfiguration();
    writeLogs("target/logs/logs/application_0_0001/container_0_0001_01_000001");
    writeLog(configuration, "owner");
    AggregatedLogsBlockForTest aggregatedBlock = getAggregatedLogsBlockForTest(configuration, "admin", "container_0_0001_01_000001");
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter(data);
    HtmlBlock html = new HtmlBlockForTest();
    HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
    aggregatedBlock.render(block);
    block.getWriter().flush();
    String out = data.toString();
    assertTrue(out.contains("Logs not available for entity. Aggregation may not be complete, Check back later or try the nodemanager at localhost:1234"));
}
Also used : HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HtmlBlock(org.apache.hadoop.yarn.webapp.view.HtmlBlock) File(java.io.File) PrintWriter(java.io.PrintWriter) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) AggregatedLogsBlockForTest(org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) Test(org.junit.Test)

Aggregations

PrintWriter (java.io.PrintWriter)14 BlockForTest (org.apache.hadoop.yarn.webapp.view.BlockForTest)14 HtmlBlock (org.apache.hadoop.yarn.webapp.view.HtmlBlock)14 Test (org.junit.Test)13 Configuration (org.apache.hadoop.conf.Configuration)8 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)7 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)7 Block (org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block)7 HtmlBlockForTest (org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 File (java.io.File)6 HashMap (java.util.HashMap)6 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)6 AggregatedLogsBlockForTest (org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest)6 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)5 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)5 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)4 FewAttemptsBlock (org.apache.hadoop.mapreduce.v2.app.webapp.AttemptsPage.FewAttemptsBlock)4 TaskReport (org.apache.hadoop.mapreduce.v2.api.records.TaskReport)3 JobIdPBImpl (org.apache.hadoop.mapreduce.v2.api.records.impl.pb.JobIdPBImpl)3