HADOOP-15699. Fix some of testContainerManager failures in Windows. Contributed by Botong Huang.

This commit is contained in:
Giovanni Matteo Fumarola 2018-08-27 12:25:46 -07:00 committed by Giovanni Matteo Fumarola
parent 548a595027
commit d4a3be9591
1 changed files with 6 additions and 12 deletions

View File

@ -321,9 +321,8 @@ public class TestContainerManager extends BaseContainerManagerTest {
@Test (timeout = 10000L) @Test (timeout = 10000L)
public void testAuxPathHandler() throws Exception { public void testAuxPathHandler() throws Exception {
File testDir = GenericTestUtils.getTestDir(GenericTestUtils.getTestDir( File testDir = GenericTestUtils
TestContainerManager.class.getSimpleName() + "LocDir"). .getTestDir(TestContainerManager.class.getSimpleName() + "LocDir");
getAbsolutePath());
testDir.mkdirs(); testDir.mkdirs();
File testFile = new File(testDir, "test"); File testFile = new File(testDir, "test");
testFile.createNewFile(); testFile.createNewFile();
@ -1978,15 +1977,11 @@ public class TestContainerManager extends BaseContainerManagerTest {
Signal signal = ContainerLaunch.translateCommandToSignal(command); Signal signal = ContainerLaunch.translateCommandToSignal(command);
containerManager.start(); containerManager.start();
File scriptFile = new File(tmpDir, "scriptFile.sh"); File scriptFile = Shell.appendScriptExtension(tmpDir, "scriptFile");
PrintWriter fileWriter = new PrintWriter(scriptFile); PrintWriter fileWriter = new PrintWriter(scriptFile);
File processStartFile = File processStartFile =
new File(tmpDir, "start_file.txt").getAbsoluteFile(); new File(tmpDir, "start_file.txt").getAbsoluteFile();
fileWriter.write("\numask 0"); // So that start file is readable by the test writeScriptFile(fileWriter, "Hello world!", processStartFile, null, false);
fileWriter.write("\necho Hello World! > " + processStartFile);
fileWriter.write("\necho $$ >> " + processStartFile);
fileWriter.write("\nexec sleep 1000s");
fileWriter.close();
ContainerLaunchContext containerLaunchContext = ContainerLaunchContext containerLaunchContext =
recordFactory.newRecordInstance(ContainerLaunchContext.class); recordFactory.newRecordInstance(ContainerLaunchContext.class);
@ -2009,9 +2004,8 @@ public class TestContainerManager extends BaseContainerManagerTest {
new HashMap<String, LocalResource>(); new HashMap<String, LocalResource>();
localResources.put(destinationFile, rsrc_alpha); localResources.put(destinationFile, rsrc_alpha);
containerLaunchContext.setLocalResources(localResources); containerLaunchContext.setLocalResources(localResources);
List<String> commands = new ArrayList<>(); List<String> commands =
commands.add("/bin/bash"); Arrays.asList(Shell.getRunScriptCommand(scriptFile));
commands.add(scriptFile.getAbsolutePath());
containerLaunchContext.setCommands(commands); containerLaunchContext.setCommands(commands);
StartContainerRequest scRequest = StartContainerRequest scRequest =
StartContainerRequest.newInstance( StartContainerRequest.newInstance(