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