SLIDER-350 use gawk as awk implementation for windows; add checks for that and xargs on the command line
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/690793a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/690793a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/690793a4 Branch: refs/heads/feature/SLIDER-280_Restart_AM_fun_tests Commit: 690793a4f8a82a3b7395271803ae9af89eb2cdda Parents: 2e3c4c8 Author: Steve Loughran <[email protected]> Authored: Thu Sep 4 14:00:01 2014 +0100 Committer: Steve Loughran <[email protected]> Committed: Thu Sep 4 14:00:01 2014 +0100 ---------------------------------------------------------------------- .../common/tools/TestWindowsSupport.groovy | 38 ++++++++++++++++++-- .../apache/slider/test/SliderTestUtils.groovy | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/690793a4/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 84356ea..d18fe76 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 @@ -105,12 +105,33 @@ class TestWindowsSupport extends SliderTestBase { } + + @Test + public void testHasGawkInstalled() throws Throwable { + assume(Shell.WINDOWS, "not windows") + assert 0 == exec(["gawk", "--version"]) + } + + @Test + public void testHasXargsInstalled() throws Throwable { + assume(Shell.WINDOWS, "not windows") + assert 0 == exec(["xargs", "--version"]) + } + + @Test public void testEmitKillCommand() throws Throwable { killJavaProcesses("regionserver", 9) } @Test + public void testHadoopHomeDefined() throws Throwable { + assume(Shell.WINDOWS, "not windows") + def hadoopHome = Shell.hadoopHome + log.info("HADOOP_HOME=$hadoopHome") + } + + @Test public void testHasWinutils() throws Throwable { assume(Shell.WINDOWS, "not windows") SliderUtils.verifyWinUtilsValid() @@ -123,14 +144,27 @@ class TestWindowsSupport extends SliderTestBase { assert winUtilsPath File winUtils = new File(winUtilsPath) log.debug("Winutils is at $winUtils)") + + ForkedProcessService process = exec([winUtilsPath, "systeminfo"]) + assert 0 == process.exitCode + } + + + /** + * Exec a set of commands, wait a few seconds for it to finish. + * @param commands + * @return + */ + public ForkedProcessService exec(ArrayList<String> commands) { ForkedProcessService process; process = new ForkedProcessService( - methodName.methodName, + methodName.methodName, [:], - [winUtilsPath, "systeminfo"]); + commands); process.init(new Configuration()); EndOfServiceWaiter waiter = new EndOfServiceWaiter(process); process.start(); waiter.waitForServiceToStop(5000); + process } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/690793a4/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 58a76af..89f1a34 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 @@ -755,7 +755,7 @@ class SliderTestUtils extends Assert { /* "jps -l | grep "String" | awk "{print $1}" | xargs -n 1 taskkill /PID" */ - GString killCommand = "\"jps -l | grep \"${grepString}\" | awk \"{print \$1}\" | xargs -n 1 taskkill /PID\"" + GString killCommand = "\"jps -l | grep \"${grepString}\" | gawk \"{print \$1}\" | xargs -n 1 taskkill /PID\"" commandString = ["CMD", "/C", killCommand] } Process command = commandString.execute()
