private void writeSrcFile(Path srcFilePath, String fileName, long length) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); int ch = filler; for (int i = 0; i < length; i++) { osw.write(ch); } osw.close(); }
@Test public void testReadAcontainerLogs1() throws Exception { //Verify the output generated by readAContainerLogs(DataInputStream, Writer, logUploadedTime) testReadAcontainerLog(true); //Verify the output generated by readAContainerLogs(DataInputStream, Writer) testReadAcontainerLog(false); }
writeSrcFile(subDir, "logs", numChars); writeSrcFile(srcFilePath, "stderr", numChars); writeSrcFile(srcFilePath, "stdout", numChars);
@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
writeSrcFile(subDir, "logs", numChars); writeSrcFile(srcFilePath, "stderr", numChars); writeSrcFile(srcFilePath, "stdout", numChars);
@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
private void writeSrcFile(Path srcFilePath, String fileName, long length) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); int ch = filler; for (int i = 0; i < length; i++) { osw.write(ch); } osw.close(); }
writeSrcFile(subDir, "logs", numChars); writeSrcFile(srcFilePath, "stderr", numChars); writeSrcFile(srcFilePath, "stdout", numChars);
@Test public void testReadAcontainerLogs1() throws Exception { //Verify the output generated by readAContainerLogs(DataInputStream, Writer, logUploadedTime) testReadAcontainerLog(true); //Verify the output generated by readAContainerLogs(DataInputStream, Writer) testReadAcontainerLog(false); }
@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
private void writeSrcFile(Path srcFilePath, String fileName, String data) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); osw.write(data); osw.close(); }
String stdout = "stdout"; String stderr = "stderr"; writeSrcFile(srcFilePath1, stdout, data + testContainerId1.toString() + stdout); writeSrcFile(srcFilePath1, stderr, data + testContainerId1.toString() + stderr);
@Test public void testReadAcontainerLogs1() throws Exception { //Verify the output generated by readAContainerLogs(DataInputStream, Writer, logUploadedTime) testReadAcontainerLog(true); //Verify the output generated by readAContainerLogs(DataInputStream, Writer) testReadAcontainerLog(false); }
private void writeSrcFile(Path srcFilePath, String fileName, String data) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); osw.write(data); osw.close(); }
String stdout = "stdout"; String stderr = "stderr"; writeSrcFile(srcFilePath1, stdout, data + testContainerId1.toString() + stdout); writeSrcFile(srcFilePath1, stderr, data + testContainerId1.toString() + stderr);
private void writeSrcFile(Path srcFilePath, String fileName, String data) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); osw.write(data); osw.close(); }
String stdout = "stdout"; String stderr = "stderr"; writeSrcFile(srcFilePath1, stdout, data + testContainerId1.toString() + stdout); writeSrcFile(srcFilePath1, stderr, data + testContainerId1.toString() + stderr);
private void writeSrcFile(Path srcFilePath, String fileName, long length) throws IOException { OutputStreamWriter osw = getOutputStreamWriter(srcFilePath, fileName); int ch = filler; for (int i = 0; i < length; i++) { osw.write(ch); } osw.close(); }