SLIDER-377 tuning of some tests & making a couple of methods accessible (groovy was apparently bending the rules)
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/4fc0396e Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/4fc0396e Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/4fc0396e Branch: refs/heads/develop Commit: 4fc0396e8705b0e50bbc6bd9671c1b8b5dbb3a0a Parents: f2965d8 Author: Steve Loughran <ste...@apache.org> Authored: Thu Sep 4 18:19:01 2014 +0100 Committer: Steve Loughran <ste...@apache.org> Committed: Thu Sep 4 18:19:01 2014 +0100 ---------------------------------------------------------------------- .../org/apache/slider/client/SliderClient.java | 6 ++- .../agent/actions/TestActionVersion.groovy | 5 +-- .../common/tools/TestZKIntegration.groovy | 44 ++++++++++---------- .../slider/providers/agent/AgentTestBase.groovy | 2 +- .../slider/test/YarnMiniClusterTestBase.groovy | 27 ++++++------ 5 files changed, 43 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4fc0396e/slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java index f4040c4..ef6448d 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -355,7 +355,8 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe /** * Delete the zookeeper node associated with the calling user and the cluster **/ - protected boolean deleteZookeeperNode(String clusterName) throws YarnException, IOException { + @VisibleForTesting + public boolean deleteZookeeperNode(String clusterName) throws YarnException, IOException { String user = getUsername(); String zkPath = ZKIntegration.mkClusterPath(user, clusterName); Exception e = null; @@ -391,7 +392,8 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe /** * Create the zookeeper node associated with the calling user and the cluster */ - protected String createZookeeperNode(String clusterName, Boolean nameOnly) throws YarnException, IOException { + @VisibleForTesting + public String createZookeeperNode(String clusterName, Boolean nameOnly) throws YarnException, IOException { String user = getUsername(); String zkPath = ZKIntegration.mkClusterPath(user, clusterName); if(nameOnly) { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4fc0396e/slider-core/src/test/groovy/org/apache/slider/agent/actions/TestActionVersion.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/actions/TestActionVersion.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/actions/TestActionVersion.groovy index 1d50b71..7a2820f 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/actions/TestActionVersion.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/actions/TestActionVersion.groovy @@ -20,10 +20,9 @@ package org.apache.slider.agent.actions import groovy.util.logging.Slf4j import org.apache.slider.common.params.SliderActions -import org.apache.slider.test.YarnMiniClusterTestBase +import org.apache.slider.test.SliderTestBase import org.apache.hadoop.yarn.conf.YarnConfiguration import org.apache.slider.core.main.ServiceLauncher -import org.junit.Before import org.junit.Test /** @@ -31,7 +30,7 @@ import org.junit.Test */ @Slf4j -class TestActionVersion extends YarnMiniClusterTestBase { +class TestActionVersion extends SliderTestBase { @Test public void testVersion() throws Throwable { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4fc0396e/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy index fe3bef7..c13af78 100644 --- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy @@ -18,6 +18,7 @@ package org.apache.slider.common.tools +import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import org.apache.hadoop.conf.Configuration import org.apache.slider.client.SliderClient @@ -31,12 +32,16 @@ import org.junit.Before import org.junit.Test @Slf4j - +@CompileStatic class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTests { + + // as the static compiler doesn't resolve consistently + public static final String USER = KeysForTests.USERNAME + @Before void createCluster() { - Configuration conf = getConfiguration() + Configuration conf = configuration createMicroZKCluster(conf) } @@ -44,7 +49,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest public void testIntegrationCreate() throws Throwable { assertHasZKCluster() ZKIntegration zki = createZKIntegrationInstance(ZKBinding, "cluster1", true, false, 5000) - String userPath = ZKIntegration.mkSliderUserPath(USERNAME) + String userPath = ZKIntegration.mkSliderUserPath(USER) Stat stat = zki.stat(userPath) assert stat != null log.info("User path $userPath has stat $stat") @@ -55,7 +60,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest assertHasZKCluster() ZKIntegration zki = createZKIntegrationInstance(ZKBinding, "", true, false, 5000) - String userPath = ZKIntegration.mkSliderUserPath(USERNAME) + String userPath = ZKIntegration.mkSliderUserPath(USER) List<String> clusters = zki.clusters assert clusters.empty } @@ -65,7 +70,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest assertHasZKCluster() ZKIntegration zki = createZKIntegrationInstance(ZKBinding, "", true, false, 5000) - String userPath = ZKIntegration.mkSliderUserPath(USERNAME) + String userPath = ZKIntegration.mkSliderUserPath(USER) String fullPath = zki.createPath(userPath, "/cluster-", ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL) @@ -78,7 +83,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest @Test public void testListUserClustersWithTwoCluster() throws Throwable { ZKIntegration zki = createZKIntegrationInstance(ZKBinding, "", true, false, 5000) - String userPath = ZKIntegration.mkSliderUserPath(USERNAME) + String userPath = ZKIntegration.mkSliderUserPath(USER) String c1 = createEphemeralChild(zki, userPath) log.info("Ephemeral path $c1") String c2 = createEphemeralChild(zki, userPath) @@ -94,25 +99,24 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest MockSliderClient client = new MockSliderClient() String path = client.createZookeeperNode("cl1", true) - ZKIntegration zki = client.getLastZKIntegration() + ZKIntegration zki = client.lastZKIntegration - String zkPath = ZKIntegration.mkClusterPath(USERNAME, "cl1") - assert zkPath == "/services/slider/users/" + USERNAME + "/cl1", "zkPath must be as expected" + String zkPath = ZKIntegration.mkClusterPath(USER, "cl1") + assert zkPath == "/services/slider/users/" + USER + "/cl1", "zkPath must be as expected" assert path == zkPath assert zki == null, "ZKIntegration should be null." zki = createZKIntegrationInstance(getZKBinding(), "cl1", true, false, 5000); - assert false == zki.exists(zkPath), "zkPath should not exist" + assert !zki.exists(zkPath) path = client.createZookeeperNode("cl1", false) - zki = client.getLastZKIntegration() - assert zkPath == "/services/slider/users/" + USERNAME + "/cl1", "zkPath must be as expected" + zki = client.lastZKIntegration + assert zkPath == "/services/slider/users/" + USER + "/cl1", "zkPath must be as expected" assert path == zkPath - assert true == zki.exists(zkPath), "zkPath must exist" + assert zki.exists(zkPath) zki.createPath(zkPath, "/cn", ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT) - assert true == zki.exists(zkPath + "/cn"), "zkPath with child node must exist" + assert zki.exists(zkPath + "/cn") client.deleteZookeeperNode("cl1") - assert false == zki.exists(zkPath), "zkPath must not exist" - + assert !zki.exists(zkPath) } public String createEphemeralChild(ZKIntegration zki, String userPath) { @@ -126,19 +130,17 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest @Override public String getUsername() { - return USERNAME + return USER } @Override protected ZKIntegration getZkClient(String clusterName, String user) { - zki = createZKIntegrationInstance(getZKBinding(), "cl1", true, false, 5000) - return zki; + createZKIntegrationInstance(ZKBinding, "cl1", true, false, 5000) } @Override public synchronized Configuration getConfig() { - Configuration conf = new Configuration(); - return conf; + new Configuration(); } public ZKIntegration getLastZKIntegration() { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4fc0396e/slider-core/src/test/groovy/org/apache/slider/providers/agent/AgentTestBase.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/AgentTestBase.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/AgentTestBase.groovy index 2953381..ff67a71 100644 --- a/slider-core/src/test/groovy/org/apache/slider/providers/agent/AgentTestBase.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/AgentTestBase.groovy @@ -53,7 +53,7 @@ public abstract class AgentTestBase extends YarnZKMiniClusterTestBase { * Server side test: validate system env before launch */ @BeforeClass - public static void checkSystem() { + public static void checkServerEnv() { SliderUtils.validateSliderServerEnvironment(null) } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4fc0396e/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 f1fd6de..7ffa64a 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 @@ -49,11 +49,8 @@ import org.apache.slider.core.main.ServiceLauncher import org.apache.slider.core.main.ServiceLauncherBaseTest import org.apache.slider.server.appmaster.SliderAppMaster import org.junit.After -import org.junit.Assert -import org.junit.Before import org.junit.BeforeClass import org.junit.Rule -import org.junit.rules.TestName import org.junit.rules.Timeout import static org.apache.slider.test.KeysForTests.* @@ -129,17 +126,14 @@ public abstract class YarnMiniClusterTestBase extends ServiceLauncherBaseTest { KEY_TEST_TIMEOUT, DEFAULT_TEST_TIMEOUT_SECONDS * 1000) ) + + /** + * Clent side test: validate system env before launch + */ @BeforeClass - public static void checkWindowsSupport() { - if (Shell.WINDOWS) { -// assertNotNull("winutils.exe not found", Shell.WINUTILS) - if (!Shell.WINUTILS) { - log.error("winutils.exe not found") - } - def lib = System.getProperty("java.library.path") - log.debug("java.library.path = ${lib}") - } - } + public static void checkClientEnv() { + SliderUtils.validateSliderClientEnvironment(null) + } protected String buildClustername(String clustername) { return clustername ?: createClusterName() @@ -245,11 +239,16 @@ public abstract class YarnMiniClusterTestBase extends ServiceLauncherBaseTest { int numLocalDirs, int numLogDirs, boolean startHDFS) { + conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 64); conf.set(YarnConfiguration.RM_SCHEDULER, FIFO_SCHEDULER); SliderUtils.patchConfiguration(conf) name = buildClustername(name) - miniCluster = new MiniYARNCluster(name, noOfNodeManagers, numLocalDirs, numLogDirs) + miniCluster = new MiniYARNCluster( + name, + noOfNodeManagers, + numLocalDirs, + numLogDirs) miniCluster.init(conf) miniCluster.start(); if (startHDFS) {