From d593976ffc3b90d56ed4802fb4e6ac62421b9772 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 17 Mar 2016 18:08:31 +0900 Subject: [PATCH] MAPREDUCE-6645. TestWordStats outputs logs under directories other than target/test-dir. Contributed by Gabor Liptak. (cherry picked from commit 80fa70c4e15f16b411cb3691df546499c6a19d4c) (cherry picked from commit 365d236175ad64c0155926713b74823e1e493bb7) --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/examples/TestWordStats.java | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index ab9f1fb5b92..befcd1ea1a2 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -58,6 +58,9 @@ Release 2.7.3 - UNRELEASED MAPREDUCE-6635. Unsafe long to int conversion in UncompressedSplitLineReader and IndexOutOfBoundsException. (Junping Du via vvasudev) + MAPREDUCE-6645. TestWordStats outputs logs under directories other than + target/test-dir. (Gabor Liptak via aajisaka) + Release 2.7.2 - 2016-01-25 INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestWordStats.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestWordStats.java index 56b358ef570..3f0ffd63f6d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestWordStats.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestWordStats.java @@ -31,15 +31,18 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.util.ToolRunner; +import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; public class TestWordStats { private final static String INPUT = "src/test/java/org/apache/hadoop/examples/pi/math"; - private final static String MEAN_OUTPUT = "build/data/mean_output"; - private final static String MEDIAN_OUTPUT = "build/data/median_output"; - private final static String STDDEV_OUTPUT = "build/data/stddev_output"; + private final static String BASEDIR = System.getProperty("test.build.data", + "target/test-dir"); + private final static String MEAN_OUTPUT = BASEDIR + "/mean_output"; + private final static String MEDIAN_OUTPUT = BASEDIR + "/median_output"; + private final static String STDDEV_OUTPUT = BASEDIR + "/stddev_output"; /** * Modified internal test class that is designed to read all the files in the @@ -286,4 +289,10 @@ public class TestWordStats { assertEquals(stddev, wr.read(INPUT), 0.0); } + @AfterClass public static void cleanup() throws Exception { + deleteDir(new File(MEAN_OUTPUT)); + deleteDir(new File(MEDIAN_OUTPUT)); + deleteDir(new File(STDDEV_OUTPUT)); + } + }