SLIDER-622 stricter tests for native libraries: perform an operation that would fail without it
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 @@
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 @@
public void testValidatePythonEnv() throws Throwable {
SliderUtils.validatePythonEnv(log)
}
-
+
+ @Test
+ public void testNativeLibs() throws Throwable {
+ assertNativeLibrariesPresent()
+ }
}
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.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 @@
* 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 @@
* 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)
+ }
}
/**