YARN-1077. Fixed TestContainerLaunch test failure on Windows. Contributed by Chuan Liu.

svn merge --ignore-ancestry -c 1519333 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1519334 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-09-02 03:11:06 +00:00
parent b5ec50756d
commit 57220dd1d0
4 changed files with 16 additions and 12 deletions

View File

@ -127,6 +127,9 @@ Release 2.1.1-beta - UNRELEASED
YARN-1101. Active nodes can be decremented below 0 (Robert Parker YARN-1101. Active nodes can be decremented below 0 (Robert Parker
via tgraves) via tgraves)
YARN-1077. Fixed TestContainerLaunch test failure on Windows. (Chuan Liu via
vinodkv)
Release 2.1.0-beta - 2013-08-22 Release 2.1.0-beta - 2013-08-22
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -525,7 +525,8 @@ public class ContainerLaunch implements Callable<Integer> {
@Override @Override
public void env(String key, String value) { public void env(String key, String value) {
line("@set ", key, "=", value); line("@set ", key, "=", value,
"\nif %errorlevel% neq 0 exit /b %errorlevel%");
} }
@Override @Override

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.UnsupportedFileSystemException; import org.apache.hadoop.fs.UnsupportedFileSystemException;
import org.apache.hadoop.service.AbstractService; import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.event.Dispatcher;
import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.event.EventHandler;
@ -149,6 +150,7 @@ public class ContainersLauncher extends AbstractService
dispatcher.getEventHandler().handle( dispatcher.getEventHandler().handle(
new ContainerExitEvent(containerId, new ContainerExitEvent(containerId,
ContainerEventType.CONTAINER_KILLED_ON_REQUEST, ContainerEventType.CONTAINER_KILLED_ON_REQUEST,
Shell.WINDOWS ? ExitCode.FORCE_KILLED.getExitCode() :
ExitCode.TERMINATED.getExitCode(), ExitCode.TERMINATED.getExitCode(),
"Container terminated before launch.")); "Container terminated before launch."));
} }

View File

@ -240,15 +240,10 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
File shellFile = null; File shellFile = null;
try { try {
shellFile = Shell.appendScriptExtension(tmpDir, "hello"); shellFile = Shell.appendScriptExtension(tmpDir, "hello");
String timeoutCommand = Shell.WINDOWS ? "@echo \"hello\"" :
"echo \"hello\"";
PrintWriter writer = new PrintWriter(new FileOutputStream(shellFile));
FileUtil.setExecutable(shellFile, true);
writer.println(timeoutCommand);
writer.close();
Map<Path, List<String>> resources = Map<Path, List<String>> resources =
new HashMap<Path, List<String>>(); new HashMap<Path, List<String>>();
FileOutputStream fos = new FileOutputStream(shellFile); FileOutputStream fos = new FileOutputStream(shellFile);
FileUtil.setExecutable(shellFile, true);
Map<String, String> env = new HashMap<String, String>(); Map<String, String> env = new HashMap<String, String>();
// invalid env // invalid env
@ -270,7 +265,9 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
} catch(ExitCodeException e){ } catch(ExitCodeException e){
diagnostics = e.getMessage(); diagnostics = e.getMessage();
} }
Assert.assertTrue(diagnostics.contains("command not found")); Assert.assertTrue(diagnostics.contains(Shell.WINDOWS ?
"is not recognized as an internal or external command" :
"command not found"));
Assert.assertTrue(shexc.getExitCode() != 0); Assert.assertTrue(shexc.getExitCode() != 0);
} }
finally { finally {
@ -289,7 +286,8 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
try { try {
shellFile = Shell.appendScriptExtension(tmpDir, "hello"); shellFile = Shell.appendScriptExtension(tmpDir, "hello");
// echo "hello" to stdout and "error" to stderr and exit code with 2; // echo "hello" to stdout and "error" to stderr and exit code with 2;
String command = Shell.WINDOWS ? "@echo \"hello\"; @echo \"error\" 1>&2; exit 2;" : String command = Shell.WINDOWS ?
"@echo \"hello\" & @echo \"error\" 1>&2 & exit /b 2" :
"echo \"hello\"; echo \"error\" 1>&2; exit 2;"; "echo \"hello\"; echo \"error\" 1>&2; exit 2;";
PrintWriter writer = new PrintWriter(new FileOutputStream(shellFile)); PrintWriter writer = new PrintWriter(new FileOutputStream(shellFile));
FileUtil.setExecutable(shellFile, true); FileUtil.setExecutable(shellFile, true);
@ -297,7 +295,7 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
writer.close(); writer.close();
Map<Path, List<String>> resources = Map<Path, List<String>> resources =
new HashMap<Path, List<String>>(); new HashMap<Path, List<String>>();
FileOutputStream fos = new FileOutputStream(shellFile); FileOutputStream fos = new FileOutputStream(shellFile, true);
Map<String, String> env = new HashMap<String, String>(); Map<String, String> env = new HashMap<String, String>();
List<String> commands = new ArrayList<String>(); List<String> commands = new ArrayList<String>();