Repository: incubator-slider Updated Branches: refs/heads/releases/slider-0.60 16be5ef63 -> ad4697575
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/ad469757 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/ad469757 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/ad469757 Branch: refs/heads/releases/slider-0.60 Commit: ad4697575ff721b19313427a40c6aebe641e4dea Parents: 16be5ef Author: Steve Loughran <[email protected]> Authored: Sat Nov 8 22:26:35 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Sat Nov 8 22:46:09 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/ad469757/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/ad469757/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)
