Search in sources :

Example 6 with AggregatedLogsBlockForTest

use of org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest 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 7 with AggregatedLogsBlockForTest

use of org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest 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

AggregatedLogsBlockForTest (org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 File (java.io.File)6 PrintWriter (java.io.PrintWriter)6 Configuration (org.apache.hadoop.conf.Configuration)6 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)6 BlockForTest (org.apache.hadoop.yarn.webapp.view.BlockForTest)6 HtmlBlock (org.apache.hadoop.yarn.webapp.view.HtmlBlock)6 HtmlBlockForTest (org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest)6 Test (org.junit.Test)6 URL (java.net.URL)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1