SLIDER-353 killJavaProcesses doesn't work on windows: testcase

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

Branch: refs/heads/feature/SLIDER-149_Support_a_YARN_service_registry
Commit: 73389fd57e36e2f5987161594c343009a618cebe
Parents: d8f8771
Author: Steve Loughran <ste...@apache.org>
Authored: Mon Aug 25 12:30:37 2014 +0100
Committer: Steve Loughran <ste...@apache.org>
Committed: Mon Aug 25 12:30:37 2014 +0100

----------------------------------------------------------------------
 .../common/tools/TestWindowsSupport.groovy      |  6 ++++
 .../apache/slider/test/SliderTestUtils.groovy   | 29 ++++++++++++++++++++
 .../slider/test/YarnMiniClusterTestBase.groovy  | 23 ----------------
 3 files changed, 35 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
index d11aa55..7f5edf3 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -103,4 +103,10 @@ class TestWindowsSupport extends SliderTestUtils {
     }
     
   }
+
+  @Test
+  public void testEmitKillCommand() throws Throwable {
+    killJavaProcesses("regionserver", 9)
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy 
b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 3fc3e55..0a1354b 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration
 import org.apache.hadoop.fs.FileStatus
 import org.apache.hadoop.fs.FileSystem as HadoopFS
 import org.apache.hadoop.fs.Path
+import org.apache.hadoop.util.Shell
 import org.apache.hadoop.yarn.api.records.ApplicationReport
 import org.apache.hadoop.yarn.conf.YarnConfiguration
 import org.apache.slider.api.ClusterDescription
@@ -737,4 +738,32 @@ class SliderTestUtils extends Assert {
       log.info "$key -- ${config.description}"
     }
   }
+
+  /**
+   * Kill any java process with the given grep pattern
+   * @param grepString string to grep for
+   */
+  public void killJavaProcesses(String grepString, int signal) {
+
+    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows 
support ")
+    
+    GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | 
xargs kill $signal"
+    log.info("Bash command = $bashCommand" )
+    Process bash = ["bash", "-c", bashCommand].execute()
+    bash.waitFor()
+
+    log.info(bash.in.text)
+    log.error(bash.err.text)
+  }
+
+  /**
+   * Kill all processes which match one of the list of grepstrings
+   * @param greps
+   * @param signal
+   */
+  public void killJavaProcesses(List<String> greps, int signal) {
+    for (String grep : greps) {
+      killJavaProcesses(grep,signal)
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
index 09c56a5..5a091bf 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
@@ -322,29 +322,6 @@ public abstract class YarnMiniClusterTestBase extends 
ServiceLauncherBaseTest {
   }
 
   /**
-   * Kill any java process with the given grep pattern
-   * @param grepString string to grep for
-   */
-  public void killJavaProcesses(String grepString, int signal) {
-
-    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows 
support ")
-    
-    GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | 
xargs kill $signal"
-    log.info("Bash command = $bashCommand" )
-    Process bash = ["bash", "-c", bashCommand].execute()
-    bash.waitFor()
-
-    log.info(bash.in.text)
-    log.error(bash.err.text)
-  }
-
-  public void killJavaProcesses(List<String> greps, int signal) {
-    for (String grep : greps) {
-      killJavaProcesses(grep,signal)
-    }
-  }
-
-  /**
    * List any java process with the given grep pattern
    * @param grepString string to grep for
    */

Reply via email to