From 55865f42c43c8e8c6282952722a06f2a58f0c264 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Tue, 9 Apr 2013 03:26:38 +0000 Subject: [PATCH] YARN-557. Fix TestUnmanagedAMLauncher failure on Windows. Contributed by Chris Nauroth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1465869 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/yarn/api/ApplicationConstants.java | 2 +- .../applications/distributedshell/ApplicationMaster.java | 2 +- .../unmanagedamlauncher/TestUnmanagedAMLauncher.java | 8 +++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 0c80ff4ed1..5377f98325 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -25,6 +25,9 @@ Trunk - Unreleased YARN-491. TestContainerLogsPage fails on Windows. (Chris Nauroth via hitesh) + YARN-557. Fix TestUnmanagedAMLauncher failure on Windows. (Chris Nauroth via + vinodkv) + BREAKDOWN OF HADOOP-8562 SUBTASKS YARN-158. Yarn creating package-info.java must not depend on sh. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationConstants.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationConstants.java index bc016d8897..02b15c4dac 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationConstants.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationConstants.java @@ -103,7 +103,7 @@ public enum Environment { * $USER * Final, non-modifiable. */ - USER("USER"), + USER(Shell.WINDOWS ? "USERNAME": "USER"), /** * $LOGNAME diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java index 2bd33c762e..55cc46814e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java @@ -683,7 +683,7 @@ public void run() { ctx.setResource(container.getResource()); String jobUserName = System.getenv(ApplicationConstants.Environment.USER - .name()); + .key()); ctx.setUser(jobUserName); LOG.info("Setting user in ContainerLaunchContext to: " + jobUserName); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/test/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/TestUnmanagedAMLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/test/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/TestUnmanagedAMLauncher.java index 43fec24afc..6ab474d43b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/test/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/TestUnmanagedAMLauncher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/test/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/TestUnmanagedAMLauncher.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.util.Shell; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.MiniYARNCluster; import org.junit.AfterClass; @@ -50,7 +51,7 @@ public static void setup() throws InterruptedException, IOException { conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 128); if (yarnCluster == null) { yarnCluster = new MiniYARNCluster( - TestUnmanagedAMLauncher.class.getName(), 1, 1, 1); + TestUnmanagedAMLauncher.class.getSimpleName(), 1, 1, 1); yarnCluster.init(conf); yarnCluster.start(); URL url = Thread.currentThread().getContextClassLoader() @@ -93,7 +94,7 @@ private static String getTestRuntimeClasspath() { return envClassPath; } - @Test(timeout=10000) + @Test(timeout=30000) public void testDSShell() throws Exception { String classpath = getTestRuntimeClasspath(); String javaHome = System.getenv("JAVA_HOME"); @@ -112,7 +113,8 @@ public void testDSShell() throws Exception { javaHome + "/bin/java -Xmx512m " + "org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster " - + "--container_memory 128 --num_containers 1 --priority 0 --shell_command ls" }; + + "--container_memory 128 --num_containers 1 --priority 0 " + + "--shell_command " + (Shell.WINDOWS ? "dir" : "ls") }; LOG.info("Initializing Launcher"); UnmanagedAMLauncher launcher = new UnmanagedAMLauncher(new Configuration(