Repository: incubator-slider
Updated Branches:
  refs/heads/feature/SLIDER-622-windows [created] 023de3b42


SLIDER-622 explicit tests for native binaries before attempts to set up 
clusters fail


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/023de3b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/023de3b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/023de3b4

Branch: refs/heads/feature/SLIDER-622-windows
Commit: 023de3b42c42157bdcad86d2fd02826dcf498616
Parents: db16e03
Author: Steve Loughran <[email protected]>
Authored: Sat Nov 8 22:26:35 2014 +0000
Committer: Steve Loughran <[email protected]>
Committed: Sat Nov 8 22:29:49 2014 +0000

----------------------------------------------------------------------
 .../apache/slider/test/SliderTestUtils.groovy   | 36 ++++++++++++++++++++
 .../slider/test/YarnMiniClusterTestBase.groovy  |  4 ++-
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/023de3b4/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 e67145e..c748600 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
@@ -28,6 +28,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.Path
+import org.apache.hadoop.io.nativeio.NativeIO
 import org.apache.hadoop.util.Shell
 import org.apache.hadoop.yarn.api.records.ApplicationReport
 import org.apache.hadoop.yarn.conf.YarnConfiguration
@@ -190,6 +191,41 @@ class SliderTestUtils extends Assert {
   }
 
   /**
+   * Check for any needed libraries being present. On Unix none are needed;
+   * on windows they must be present
+   * @return true if all is well
+   */
+  public static boolean areRequiredLibrariesAvailable() {
+    
+    if (!Shell.WINDOWS) {
+      return true;
+    }
+    boolean available = true;
+    if (!NativeIO.available) {
+      log.warn("No native IO library")
+      available = false;
+    }
+    try {
+      def path = Shell.getQualifiedBinPath("winutils.exe");
+      log.debug("winutils is at $path")
+    } catch (IOException e) {
+      log.warn("No winutils: $e", e)
+      available = false;
+    }
+    return available;
+  }
+
+  /**
+   * Assert that any needed libraries being present. On Unix none are needed;
+   * 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())
+  }
+
+  /**
    * Wait for the cluster live; fail if it isn't within the (standard) timeout
    * @param sliderClient client
    * @return the app report of the live cluster

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/023de3b4/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
index 3241ec3..4d2cb3b 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
@@ -239,7 +239,7 @@ public abstract class YarnMiniClusterTestBase extends 
ServiceLauncherBaseTest {
                                    int numLocalDirs,
                                    int numLogDirs,
                                    boolean startHDFS) {
-   
+    assertNativeLibrariesPresent();
     conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 64);
     conf.set(YarnConfiguration.RM_SCHEDULER, FIFO_SCHEDULER);
     SliderUtils.patchConfiguration(conf)
@@ -275,6 +275,8 @@ public abstract class YarnMiniClusterTestBase extends 
ServiceLauncherBaseTest {
   public static MiniDFSCluster buildMiniHDFSCluster(
       String name,
       YarnConfiguration conf) {
+    assertNativeLibrariesPresent();
+
     File baseDir = new File("./target/hdfs/$name").absoluteFile;
     //use file: to rm it recursively
     FileUtil.fullyDelete(baseDir)

Reply via email to