Tests in mapreduce-client-app are writing outside of target. Contributed by Akira AJISAKA.

This commit is contained in:
Junping Du 2015-11-25 09:15:26 -08:00
parent 84d01ad7f4
commit 15d577bfbb
2 changed files with 19 additions and 8 deletions

View File

@ -647,6 +647,9 @@ Release 2.8.0 - UNRELEASED
MAPREDUCE-6553. Replace '\u2b05' with '<-' in rendering job configuration. MAPREDUCE-6553. Replace '\u2b05' with '<-' in rendering job configuration.
(Gabor Liptak via aajisaka) (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 Release 2.7.3 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -87,6 +87,7 @@ import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.LogManager; import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -95,11 +96,13 @@ import org.mockito.Mockito;
public class TestMRAppMaster { public class TestMRAppMaster {
private static final Log LOG = LogFactory.getLog(TestMRAppMaster.class); 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 FileContext localFS = null;
private static final File testDir = new File("target",
TestMRAppMaster.class.getName() + "-tmpDir").getAbsoluteFile();
@BeforeClass @BeforeClass
public static void setup() throws AccessControlException, public static void setup() throws AccessControlException,
FileNotFoundException, IllegalArgumentException, IOException { FileNotFoundException, IllegalArgumentException, IOException {
@ -108,12 +111,12 @@ public class TestMRAppMaster {
File dir = new File(stagingDir); File dir = new File(stagingDir);
stagingDir = dir.getAbsolutePath(); stagingDir = dir.getAbsolutePath();
localFS = FileContext.getLocalFSFileContext(); localFS = FileContext.getLocalFSFileContext();
localFS.delete(new Path(testDir.getAbsolutePath()), true); localFS.delete(testDir, true);
testDir.mkdir(); new File(testDir.toString()).mkdir();
} }
@Before @Before
public void cleanup() throws IOException { public void prepare() throws IOException {
File dir = new File(stagingDir); File dir = new File(stagingDir);
if(dir.exists()) { if(dir.exists()) {
FileUtils.deleteDirectory(dir); FileUtils.deleteDirectory(dir);
@ -121,6 +124,11 @@ public class TestMRAppMaster {
dir.mkdirs(); dir.mkdirs();
} }
@AfterClass
public static void cleanup() throws IOException {
localFS.delete(testDir, true);
}
@Test @Test
public void testMRAppMasterForDifferentUser() throws IOException, public void testMRAppMasterForDifferentUser() throws IOException,
InterruptedException { InterruptedException {
@ -427,7 +435,7 @@ public class TestMRAppMaster {
JobConf conf = new JobConf(); 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>(); Map<String, String> newEnv = new HashMap<String, String>();
newEnv.put(UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION, tokenFilePath newEnv.put(UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION, tokenFilePath
.toUri().getPath()); .toUri().getPath());