SLIDER-622 stricter tests for native libraries: perform an operation that would fail without it
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/0bb96fed Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/0bb96fed Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/0bb96fed Branch: refs/heads/releases/slider-0.60 Commit: 0bb96fedfceac0ec7c5235f67ff74d1c3885bf8e Parents: a036ec1 Author: Steve Loughran <[email protected]> Authored: Sun Nov 9 18:34:31 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Mon Nov 10 00:15:47 2014 +0000 ---------------------------------------------------------------------- .../tools/TestExecutionEnvironment.groovy | 12 ++++++++- .../apache/slider/test/SliderTestUtils.groovy | 27 +++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/0bb96fed/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy index 7ca6c49..ad78c0e 100644 --- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy @@ -31,6 +31,12 @@ class TestExecutionEnvironment extends SliderTestBase { public void testClientEnv() throws Throwable { SliderUtils.validateSliderClientEnvironment(log) } + + @Test + public void testWinutils() throws Throwable { + SliderUtils.maybeVerifyWinUtilsValid(log); + + } @Test public void testServerEnv() throws Throwable { @@ -46,5 +52,9 @@ class TestExecutionEnvironment extends SliderTestBase { public void testValidatePythonEnv() throws Throwable { SliderUtils.validatePythonEnv(log) } - + + @Test + public void testNativeLibs() throws Throwable { + assertNativeLibrariesPresent() + } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/0bb96fed/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 c748600..6e63da9 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 @@ -27,6 +27,7 @@ import org.apache.commons.httpclient.methods.GetMethod 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.FileUtil import org.apache.hadoop.fs.Path import org.apache.hadoop.io.nativeio.NativeIO import org.apache.hadoop.util.Shell @@ -195,24 +196,31 @@ class SliderTestUtils extends Assert { * on windows they must be present * @return true if all is well */ - public static boolean areRequiredLibrariesAvailable() { + public static String checkForRequiredLibraries() { if (!Shell.WINDOWS) { - return true; + return ""; } + StringBuilder errorText = new StringBuilder("") boolean available = true; if (!NativeIO.available) { - log.warn("No native IO library") - available = false; + errorText.append("No native IO library. ") } try { def path = Shell.getQualifiedBinPath("winutils.exe"); log.debug("winutils is at $path") } catch (IOException e) { + errorText.append("No WINUTILS.EXE. ") log.warn("No winutils: $e", e) - available = false; } - return available; + try { + File target = new File("target") + FileUtil.canRead(target) + } catch (UnsatisfiedLinkError e) { + log.warn("Failing to link to native IO methods: $e", e) + errorText.append("No native IO methods") + } + return errorText.toString(); } /** @@ -220,9 +228,10 @@ class SliderTestUtils extends Assert { * on windows they must be present */ public static void assertNativeLibrariesPresent() { - assertTrue("Required Native libraries and executables are not present." + - "Check your HADOOP_HOME and PATH environment variables", - areRequiredLibrariesAvailable()) + String errorText = checkForRequiredLibraries() + if (errorText != null) { + fail(errorText) + } } /**
