From 6c8fc8f786287cd066de01684c909d1a0eb1cd75 Mon Sep 17 00:00:00 2001 From: Giovanni Matteo Fumarola Date: Fri, 7 Sep 2018 14:19:10 -0700 Subject: [PATCH] HADOOP-15731. TestDistributedShell fails on Windows. Contributed by Botong Huang. --- .../yarn/applications/distributedshell/Client.java | 4 +++- .../distributedshell/TestDistributedShell.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java index eedb5016e4f..50f5bdf7763 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java @@ -690,7 +690,9 @@ public class Client { // Set java executable command LOG.info("Setting up app master command"); - vargs.add(Environment.JAVA_HOME.$$() + "/bin/java"); + // Need extra quote here because JAVA_HOME might contain space on Windows, + // e.g. C:/Program Files/Java... + vargs.add("\"" + Environment.JAVA_HOME.$$() + "/bin/java\""); // Set Xmx based on am memory size vargs.add("-Xmx" + amMemory + "m"); // Set class name diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java index 70ec4db5aa2..8af6625ca97 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java @@ -757,6 +757,12 @@ public class TestDistributedShell { } + private String getSleepCommand(int sec) { + // Windows doesn't have a sleep command, ping -n does the trick + return Shell.WINDOWS ? "ping -n " + (sec + 1) + " 127.0.0.1 >nul" + : "sleep " + sec; + } + @Test public void testDSRestartWithPreviousRunningContainers() throws Exception { String[] args = { @@ -765,7 +771,7 @@ public class TestDistributedShell { "--num_containers", "1", "--shell_command", - "sleep 8", + getSleepCommand(8), "--master_memory", "512", "--container_memory", @@ -800,7 +806,7 @@ public class TestDistributedShell { "--num_containers", "1", "--shell_command", - "sleep 8", + getSleepCommand(8), "--master_memory", "512", "--container_memory", @@ -838,7 +844,7 @@ public class TestDistributedShell { "--num_containers", "1", "--shell_command", - "sleep 8", + getSleepCommand(8), "--master_memory", "512", "--container_memory",