Java Code Examples for org.apache.hadoop.yarn.webapp.view.HtmlBlock#Block

The following examples show how to use org.apache.hadoop.yarn.webapp.view.HtmlBlock#Block . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAggregatedLogsBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Bad user. User 'owner' is trying to read logs without access
 */
@Test
public void testAccessDenied() 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, "owner", "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("User [owner] is not authorized to view the logs for entity"));

}
 
Example 2
Source File: TestAggregatedLogsBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));

}
 
Example 3
Source File: TestAggregatedLogsBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * All ok and the AggregatedLogsBlockFor should aggregate logs and show it.
 * 
 * @throws Exception
 */
@Test
public void testAggregatedLogsBlock() 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, "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("test log1"));
  assertTrue(out.contains("test log2"));
  assertTrue(out.contains("test log3"));

}
 
Example 4
Source File: TestAggregatedLogsBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));

}
 
Example 5
Source File: TestAggregatedLogsBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Bad user. User 'owner' is trying to read logs without access
 */
@Test
public void testAccessDenied() 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, "owner", "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("User [owner] is not authorized to view the logs for entity"));

}
 
Example 6
Source File: TestAggregatedLogsBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));

}
 
Example 7
Source File: TestAggregatedLogsBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * All ok and the AggregatedLogsBlockFor should aggregate logs and show it.
 * 
 * @throws Exception
 */
@Test
public void testAggregatedLogsBlock() 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, "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("test log1"));
  assertTrue(out.contains("test log2"));
  assertTrue(out.contains("test log3"));

}
 
Example 8
Source File: TestAggregatedLogsBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));

}