Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5E27218230 for ; Tue, 29 Dec 2015 16:35:36 +0000 (UTC) Received: (qmail 58038 invoked by uid 500); 29 Dec 2015 16:35:36 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 57974 invoked by uid 500); 29 Dec 2015 16:35:36 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 57961 invoked by uid 99); 29 Dec 2015 16:35:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2015 16:35:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 06FD8E04AC; Tue, 29 Dec 2015 16:35:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aajisaka@apache.org To: common-commits@hadoop.apache.org Message-Id: <9b21c327ec894804ae11d98fe1169e91@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: MAPREDUCE-6589. TestTaskLog outputs a log under directory other than target/test-dir. (aajisaka) Date: Tue, 29 Dec 2015 16:35:36 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2.8 7063d8d01 -> 2139458a9 MAPREDUCE-6589. TestTaskLog outputs a log under directory other than target/test-dir. (aajisaka) (cherry picked from commit 2a59d01503ed547bac15443fc273b5e04a2839d9) (cherry picked from commit a8314505d0c7fa4a3748bef4c156095bdfdd3fc0) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2139458a Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2139458a Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2139458a Branch: refs/heads/branch-2.8 Commit: 2139458a984d74db4a5df24e9ff0b982b4e4aa80 Parents: 7063d8d Author: Akira Ajisaka Authored: Wed Dec 30 01:33:47 2015 +0900 Committer: Akira Ajisaka Committed: Wed Dec 30 01:34:26 2015 +0900 ---------------------------------------------------------------------- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/mapred/TestTaskLog.java | 22 ++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/2139458a/hadoop-mapreduce-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index aaa898f..26ade9c 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -376,6 +376,9 @@ Release 2.8.0 - UNRELEASED MAPREDUCE-6419. JobHistoryServer doesn't sort properly based on Job ID when Job id's 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 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/2139458a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestTaskLog.java ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestTaskLog.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestTaskLog.java index ab4a342..ee3bd81 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestTaskLog.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestTaskLog.java @@ -27,9 +27,10 @@ import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.FileUtils; +import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.mapred.TaskLog.LogName; -import org.apache.hadoop.mapreduce.MRJobConfig; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.junit.AfterClass; import org.junit.Test; /** @@ -37,6 +38,16 @@ import org.junit.Test; */ 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 * @@ -67,7 +78,7 @@ public class TestTaskLog { indexFile.delete(); indexFile.createNewFile(); - TaskLog.syncLogs("location", taid, true); + TaskLog.syncLogs(testDir, taid, true); assertTrue(indexFile.getAbsolutePath().endsWith( "userlogs" + File.separatorChar + "job_job_0001" @@ -76,7 +87,7 @@ public class TestTaskLog { f = TaskLog.getRealTaskLogFileLocation(taid, true, LogName.DEBUGOUT); if (f != null) { - assertTrue(f.getAbsolutePath().endsWith("location" + assertTrue(f.getAbsolutePath().endsWith(testDirName + File.separatorChar + "debugout")); FileUtils.copyFile(indexFile, f); } @@ -84,14 +95,13 @@ public class TestTaskLog { assertTrue(TaskLog.obtainLogDirOwner(taid).length() > 0); // test TaskLog.Reader 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) throws IOException { // string buffer to store task log - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); int res; // reads the whole tasklog into inputstream