You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/10 01:16:51 UTC

[4/9] incubator-slider git commit: SLIDER-622 stricter tests for native libraries: perform an operation that would fail without it

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/152c9cb1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/152c9cb1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/152c9cb1

Branch: refs/heads/develop
Commit: 152c9cb1ef6ec85cb5cf973908c3ef8a041ad8f0
Parents: 1890c42
Author: Steve Loughran <st...@apache.org>
Authored: Sun Nov 9 18:34:31 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Nov 10 00:09:17 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/152c9cb1/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/152c9cb1/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)
+    }
   }
 
   /**