hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1490120 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java src/test/java/org/apache/hadoop/util/TestShell.java
Date Thu, 06 Jun 2013 04:02:25 GMT
Author: suresh
Date: Thu Jun  6 04:02:24 2013
New Revision: 1490120

URL: http://svn.apache.org/r1490120
Log:
HADOOP-9526. TestShellCommandFencer and TestShell fail on Windows. Contributed by Arpit Agarwal.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1490120&r1=1490119&r2=1490120&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Thu Jun  6 04:02:24
2013
@@ -746,6 +746,9 @@ Release 2.1.0-beta - UNRELEASED
     HADOOP-9131. Turn off TestLocalFileSystem#testListStatusWithColons on
     Windows. (Chris Nauroth via suresh)
 
+    HADOOP-9526. TestShellCommandFencer and TestShell fail on Windows.
+    (Arpit Agarwal via suresh)
+
 Release 2.0.5-alpha - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java?rev=1490120&r1=1490119&r2=1490120&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
Thu Jun  6 04:02:24 2013
@@ -23,6 +23,7 @@ import java.net.InetSocketAddress;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
+import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.StringUtils;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -110,9 +111,9 @@ public class TestShellCommandFencer {
    */
   @Test
   public void testStderrLogging() {
-    assertTrue(fencer.tryFence(TEST_TARGET, "echo hello >&2"));
+    assertTrue(fencer.tryFence(TEST_TARGET, "echo hello>&2"));
     Mockito.verify(ShellCommandFencer.LOG).warn(
-        Mockito.endsWith("echo hello >&2: hello"));
+        Mockito.endsWith("echo hello>&2: hello"));
   }
 
   /**
@@ -121,9 +122,15 @@ public class TestShellCommandFencer {
    */
   @Test
   public void testConfAsEnvironment() {
-    fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests");
-    Mockito.verify(ShellCommandFencer.LOG).info(
-        Mockito.endsWith("echo $in...ing_tests: yessir"));
+    if (!Shell.WINDOWS) {
+      fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests");
+      Mockito.verify(ShellCommandFencer.LOG).info(
+          Mockito.endsWith("echo $in...ing_tests: yessir"));
+    } else {
+      fencer.tryFence(TEST_TARGET, "echo %in_fencing_tests%");
+      Mockito.verify(ShellCommandFencer.LOG).info(
+          Mockito.endsWith("echo %in...ng_tests%: yessir"));
+    }
   }
   
   /**
@@ -132,9 +139,15 @@ public class TestShellCommandFencer {
    */
   @Test
   public void testTargetAsEnvironment() {
-    fencer.tryFence(TEST_TARGET, "echo $target_host $target_port $target_address");
-    Mockito.verify(ShellCommandFencer.LOG).info(
-        Mockito.endsWith("echo $ta...t_address: host 1234 host:1234"));
+    if (!Shell.WINDOWS) {
+      fencer.tryFence(TEST_TARGET, "echo $target_host $target_port $target_address");
+      Mockito.verify(ShellCommandFencer.LOG).info(
+          Mockito.endsWith("echo $ta...t_address: host 1234 host:1234"));
+    } else {
+      fencer.tryFence(TEST_TARGET, "echo %target_host% %target_port% %target_address%");
+      Mockito.verify(ShellCommandFencer.LOG).info(
+          Mockito.endsWith("echo %ta..._address%: host 1234 host:1234"));
+    }
   }
 
 

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java?rev=1490120&r1=1490119&r2=1490120&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java
Thu Jun  6 04:02:24 2013
@@ -41,7 +41,12 @@ public class TestShell extends TestCase 
 
     @Override
     protected String[] getExecString() {
-      return new String[] {"echo", "hello"};
+      // There is no /bin/echo equivalent on Windows so just launch it as a
+      // shell built-in.
+      //
+      return Shell.WINDOWS ?
+          (new String[] {"cmd.exe", "/c", "echo", "hello"}) :
+          (new String[] {"echo", "hello"});
     }
 
     @Override



Mime
View raw message