SLIDER-622 scanning for the DLL on the path
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/81402edf Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/81402edf Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/81402edf Branch: refs/heads/develop Commit: 81402edfeeb4ac88ffa0c7ac82b71fc3bf952cbc Parents: 9b3fd8c Author: Steve Loughran <[email protected]> Authored: Mon Nov 10 20:38:30 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Mon Nov 10 20:38:30 2014 +0000 ---------------------------------------------------------------------- .../common/tools/TestWindowsSupport.groovy | 64 +++++++++++++++----- 1 file changed, 50 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/81402edf/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 cbd79a4..769233e 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 @@ -28,7 +28,6 @@ import org.apache.hadoop.fs.FileSystem as HadoopFS import org.apache.hadoop.service.ServiceStateException import org.apache.hadoop.util.Shell import org.apache.slider.providers.agent.AgentUtils -import org.apache.slider.test.SliderTestBase import org.apache.slider.test.YarnMiniClusterTestBase import org.junit.Test @@ -68,8 +67,8 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { @Test public void testPathHandling() throws Throwable { - assume(Shell.WINDOWS, "not windows") - + assumeWindows() + Path path = new Path(windowsFile); def uri = path.toUri() // assert "file" == uri.scheme @@ -95,14 +94,13 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { @Test public void testSliderFS() throws Throwable { - assume(Shell.WINDOWS, "not windows") + assumeWindows() SliderFileSystem sfs = new SliderFileSystem(new Configuration()) try { def metainfo = AgentUtils.getApplicationMetainfo(sfs, windowsFile) } catch (FileNotFoundException fnfe) { // expected } - } @@ -133,10 +131,14 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { } @Test public void testExecNonexistentBinary2() throws Throwable { - assume(Shell.WINDOWS, "not windows") + assumeWindows() assert !doesWindowsAppExist(["undefined-application", "--version"]) } + public assumeWindows() { + assume(Shell.WINDOWS, "not windows") + } + @Test public void testEmitKillCommand() throws Throwable { @@ -147,20 +149,20 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { @Test public void testHadoopHomeDefined() throws Throwable { - assume(Shell.WINDOWS, "not windows") + assumeWindows() def hadoopHome = Shell.hadoopHome log.info("HADOOP_HOME=$hadoopHome") } @Test public void testHasWinutils() throws Throwable { - assume(Shell.WINDOWS, "not windows") + assumeWindows() SliderUtils.maybeVerifyWinUtilsValid() } @Test public void testExecWinutils() throws Throwable { - assume(Shell.WINDOWS, "not windows") + assumeWindows() def winUtilsPath = Shell.winUtilsPath assert winUtilsPath File winUtils = new File(winUtilsPath) @@ -169,11 +171,45 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { exec(0, [winUtilsPath, "systeminfo"]) } - @Test public void testPath() throws Throwable { - String pathkey; - + String path = extractPath() + log.info("Path value = $path") + } + + @Test + public void testFindJavac() throws Throwable { + String name = Shell.WINDOWS ? "javac.exe" : "javac" + assert locateExecutable(name) + } + + @Test + public void testHadoopDLL() throws Throwable { + assumeWindows() + // split the path + File exepath = locateExecutable("HADOOP.DLL") + assert exepath + log.info "Hadoop DLL at: $exepath" + } + + public File locateExecutable(String exe) { + File exepath = null + String path = extractPath() + String[] dirs = path.split(System.getProperty("path.separator")); + dirs.each { String dirname -> + File dir = new File(dirname) + + File possible = new File(dir, exe) + if (possible.exists()) { + exepath = possible + } + } + return exepath + } + + public String extractPath() { + String pathkey = ""; + System.getenv().keySet().each { String it -> if (it.toLowerCase(Locale.ENGLISH).equals("path")) { pathkey = it; @@ -181,7 +217,7 @@ class TestWindowsSupport extends YarnMiniClusterTestBase { } assert pathkey log.info("Path env variable is $pathkey") - def pathval = System.getenv(pathkey) - log.info("Path value = $pathval") + def path = System.getenv(pathkey) + return path } }
