You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/02 15:25:23 UTC

[11/50] git commit: SLIDER-581 ensure that exit codes come back on funtests on windows

SLIDER-581 ensure that exit codes come back on funtests on windows


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2d953fff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2d953fff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2d953fff

Branch: refs/heads/feature/SLIDER-531-registry-enhancements
Commit: 2d953fff1f3d65dc19e4d0fb41ea9fd394de00d5
Parents: 05cf898
Author: Steve Loughran <st...@apache.org>
Authored: Thu Oct 30 14:23:34 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Thu Oct 30 14:23:34 2014 +0000

----------------------------------------------------------------------
 .../slider/funtest/framework/SliderShell.groovy | 15 +++++--
 .../funtest/commands/CommandExitCodesIT.groovy  | 43 ++++++++++++++++++++
 .../funtest/commands/ListCommandIT.groovy       |  2 +-
 .../commands/UnknownClusterOperationsIT.groovy  |  2 -
 4 files changed, 55 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2d953fff/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy
index 15bf339..c101cfa 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy
@@ -240,18 +240,25 @@ class SliderShell extends Shell {
    * @return Shell object for chaining
    */
   Shell exec(Object... args) {
-    def proc = "$shell".execute()
+    Process proc = "$shell".execute()
     script = args.join("\n")
     LOG.debug("${shell} << __EOT__\n${script}\n__EOT__");
+    ByteArrayOutputStream baosErr = new ByteArrayOutputStream(4096);
+    ByteArrayOutputStream baosOut = new ByteArrayOutputStream(4096);
+    proc.consumeProcessOutput(baosOut, baosErr)
 
     Thread.start {
       def writer = new PrintWriter(new BufferedOutputStream(proc.out))
       writer.println(script)
+      writer.flush()
+      if (org.apache.hadoop.util.Shell.WINDOWS) {
+        // Ensure the errorlevel returned by last call is set for the invoking shell
+        writer.println("@echo ERRORLEVEL=%ERRORLEVEL%")
+        writer.println("@exit %ERRORLEVEL%")
+        writer.flush()
+      }
       writer.close()
     }
-    ByteArrayOutputStream baosErr = new ByteArrayOutputStream(4096);
-    ByteArrayOutputStream baosOut = new ByteArrayOutputStream(4096);
-    proc.consumeProcessOutput(baosOut, baosErr)
 
     proc.waitFor()
     ret = proc.exitValue()

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2d953fff/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/CommandExitCodesIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/CommandExitCodesIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/CommandExitCodesIT.groovy
new file mode 100644
index 0000000..c49c738
--- /dev/null
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/CommandExitCodesIT.groovy
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.funtest.commands
+
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+import org.apache.slider.common.SliderExitCodes
+import org.apache.slider.core.main.LauncherExitCodes
+import org.apache.slider.funtest.framework.CommandTestBase
+import org.junit.Test
+
+@CompileStatic
+@Slf4j
+public class CommandExitCodesIT extends CommandTestBase {
+
+  @Test
+  public void testHelp() throws Throwable {
+    slider(0, ["help"])
+  }
+
+  @Test
+  public void testStopWithoutCluster() throws Throwable {
+    slider(LauncherExitCodes.EXIT_COMMAND_ARGUMENT_ERROR, ["stop"])
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2d953fff/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/ListCommandIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/ListCommandIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/ListCommandIT.groovy
index 7ba7fc0..c65280a 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/ListCommandIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/ListCommandIT.groovy
@@ -36,7 +36,7 @@ public class ListCommandIT extends CommandTestBase {
   @Test
   public void testListAllLive() throws Throwable {
     def shell = list("--live")
-    assert shell.ret == 0 || shell.ret ==1
+    assert shell.ret == 0 || shell.ret == 1
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2d953fff/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy
index 6eaf54a..5515894 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy
@@ -21,7 +21,6 @@ package org.apache.slider.funtest.commands
 import groovy.transform.CompileStatic
 import groovy.util.logging.Slf4j
 import org.apache.slider.common.SliderExitCodes
-import org.apache.slider.funtest.categories.FunctionalTests
 import org.apache.slider.common.params.Arguments
 import org.apache.slider.common.params.SliderActions
 import org.apache.slider.funtest.framework.CommandTestBase
@@ -33,7 +32,6 @@ import org.junit.Test
  */
 @CompileStatic
 @Slf4j
-@org.junit.experimental.categories.Category(FunctionalTests)
 public class UnknownClusterOperationsIT extends CommandTestBase {
 
   public static final String UNKNOWN = "unknown_cluster"