Repository: hadoop Updated Branches: refs/heads/branch-2 48b294c58 -> 628c78287
Tests in mapreduce-client-app are writing outside of target. Contributed by Akira AJISAKA. (cherry picked from commit 15d577bfbb3f18fc95251d22378b53aa4210115f) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/628c7828 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/628c7828 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/628c7828 Branch: refs/heads/branch-2 Commit: 628c782870c5c1e6fd5f89e342ae1a2d74b2338d Parents: 48b294c Author: Junping Du <junping...@apache.org> Authored: Wed Nov 25 09:15:26 2015 -0800 Committer: Junping Du <junping...@apache.org> Committed: Wed Nov 25 09:16:22 2015 -0800 ---------------------------------------------------------------------- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../mapreduce/v2/app/TestMRAppMaster.java | 24 +++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/628c7828/hadoop-mapreduce-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 8046e88..1999126 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -355,6 +355,9 @@ Release 2.8.0 - UNRELEASED MAPREDUCE-6553. Replace '\u2b05' with '<-' in rendering job configuration. (Gabor Liptak via aajisaka) + MAPREDUCE-6557. Tests in mapreduce-client-app are writing outside of + target. (Akira AJISAKA via junping_du) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/628c7828/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java index 9e0dafc..78a6178 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java @@ -87,6 +87,7 @@ import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -95,11 +96,13 @@ import org.mockito.Mockito; public class TestMRAppMaster { private static final Log LOG = LogFactory.getLog(TestMRAppMaster.class); - static String stagingDir = "staging/"; + private static final Path TEST_ROOT_DIR = + new Path(System.getProperty("test.build.data", "target/test-dir")); + private static final Path testDir = new Path(TEST_ROOT_DIR, + TestMRAppMaster.class.getName() + "-tmpDir"); + static String stagingDir = new Path(testDir, "staging").toString(); private static FileContext localFS = null; - private static final File testDir = new File("target", - TestMRAppMaster.class.getName() + "-tmpDir").getAbsoluteFile(); - + @BeforeClass public static void setup() throws AccessControlException, FileNotFoundException, IllegalArgumentException, IOException { @@ -108,12 +111,12 @@ public class TestMRAppMaster { File dir = new File(stagingDir); stagingDir = dir.getAbsolutePath(); localFS = FileContext.getLocalFSFileContext(); - localFS.delete(new Path(testDir.getAbsolutePath()), true); - testDir.mkdir(); + localFS.delete(testDir, true); + new File(testDir.toString()).mkdir(); } @Before - public void cleanup() throws IOException { + public void prepare() throws IOException { File dir = new File(stagingDir); if(dir.exists()) { FileUtils.deleteDirectory(dir); @@ -121,6 +124,11 @@ public class TestMRAppMaster { dir.mkdirs(); } + @AfterClass + public static void cleanup() throws IOException { + localFS.delete(testDir, true); + } + @Test public void testMRAppMasterForDifferentUser() throws IOException, InterruptedException { @@ -425,7 +433,7 @@ public class TestMRAppMaster { JobConf conf = new JobConf(); - Path tokenFilePath = new Path(testDir.getAbsolutePath(), "tokens-file"); + Path tokenFilePath = new Path(testDir, "tokens-file"); Map<String, String> newEnv = new HashMap<String, String>(); newEnv.put(UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION, tokenFilePath .toUri().getPath());