MAPREDUCE-6589. TestTaskLog outputs a log under directory other than target/test-dir. (aajisaka)
(cherry picked from commit 2a59d01503
)
This commit is contained in:
parent
1a06949126
commit
a8314505d0
|
@ -388,6 +388,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
MAPREDUCE-6419. JobHistoryServer doesn't sort properly based on Job ID when Job id's
|
MAPREDUCE-6419. JobHistoryServer doesn't sort properly based on Job ID when Job id's
|
||||||
exceed 9999. (Mohammad Shahid Khan via rohithsharmaks)
|
exceed 9999. (Mohammad Shahid Khan via rohithsharmaks)
|
||||||
|
|
||||||
|
MAPREDUCE-6589. TestTaskLog outputs a log under directory other than
|
||||||
|
target/test-dir. (aajisaka)
|
||||||
|
|
||||||
Release 2.7.3 - UNRELEASED
|
Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -27,9 +27,10 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.hadoop.fs.FileUtil;
|
||||||
import org.apache.hadoop.mapred.TaskLog.LogName;
|
import org.apache.hadoop.mapred.TaskLog.LogName;
|
||||||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +38,16 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class TestTaskLog {
|
public class TestTaskLog {
|
||||||
|
|
||||||
|
private static final String testDirName = TestTaskLog.class.getSimpleName();
|
||||||
|
private static final String testDir = System.getProperty("test.build.data",
|
||||||
|
"target" + File.separatorChar + "test-dir")
|
||||||
|
+ File.separatorChar + testDirName;
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void cleanup() {
|
||||||
|
FileUtil.fullyDelete(new File(testDir));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test TaskAttemptID
|
* test TaskAttemptID
|
||||||
*
|
*
|
||||||
|
@ -67,7 +78,7 @@ public class TestTaskLog {
|
||||||
indexFile.delete();
|
indexFile.delete();
|
||||||
indexFile.createNewFile();
|
indexFile.createNewFile();
|
||||||
|
|
||||||
TaskLog.syncLogs("location", taid, true);
|
TaskLog.syncLogs(testDir, taid, true);
|
||||||
|
|
||||||
assertTrue(indexFile.getAbsolutePath().endsWith(
|
assertTrue(indexFile.getAbsolutePath().endsWith(
|
||||||
"userlogs" + File.separatorChar + "job_job_0001"
|
"userlogs" + File.separatorChar + "job_job_0001"
|
||||||
|
@ -76,7 +87,7 @@ public class TestTaskLog {
|
||||||
|
|
||||||
f = TaskLog.getRealTaskLogFileLocation(taid, true, LogName.DEBUGOUT);
|
f = TaskLog.getRealTaskLogFileLocation(taid, true, LogName.DEBUGOUT);
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
assertTrue(f.getAbsolutePath().endsWith("location"
|
assertTrue(f.getAbsolutePath().endsWith(testDirName
|
||||||
+ File.separatorChar + "debugout"));
|
+ File.separatorChar + "debugout"));
|
||||||
FileUtils.copyFile(indexFile, f);
|
FileUtils.copyFile(indexFile, f);
|
||||||
}
|
}
|
||||||
|
@ -84,14 +95,13 @@ public class TestTaskLog {
|
||||||
assertTrue(TaskLog.obtainLogDirOwner(taid).length() > 0);
|
assertTrue(TaskLog.obtainLogDirOwner(taid).length() > 0);
|
||||||
// test TaskLog.Reader
|
// test TaskLog.Reader
|
||||||
assertTrue(readTaskLog(TaskLog.LogName.DEBUGOUT, taid, true).length() > 0);
|
assertTrue(readTaskLog(TaskLog.LogName.DEBUGOUT, taid, true).length() > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readTaskLog(TaskLog.LogName filter,
|
private String readTaskLog(TaskLog.LogName filter,
|
||||||
org.apache.hadoop.mapred.TaskAttemptID taskId, boolean isCleanup)
|
org.apache.hadoop.mapred.TaskAttemptID taskId, boolean isCleanup)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// string buffer to store task log
|
// string buffer to store task log
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuilder result = new StringBuilder();
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
// reads the whole tasklog into inputstream
|
// reads the whole tasklog into inputstream
|
||||||
|
|
Loading…
Reference in New Issue