You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by te...@apache.org on 2014/07/15 23:12:13 UTC
git commit: SLIDER-233 Add tests for instance definition update
Repository: incubator-slider
Updated Branches:
refs/heads/develop 29f0ccae6 -> 0b3d7813f
SLIDER-233 Add tests for instance definition update
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/0b3d7813
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/0b3d7813
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/0b3d7813
Branch: refs/heads/develop
Commit: 0b3d7813ffd2bd4ef7ae55427d5d84516820dca2
Parents: 29f0cca
Author: tedyu <yu...@gmail.com>
Authored: Tue Jul 15 14:11:50 2014 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Tue Jul 15 14:11:50 2014 -0700
----------------------------------------------------------------------
.../slider/providers/agent/AgentTestBase.groovy | 30 +++++++
.../providers/agent/TestBuildBasicAgent.groovy | 91 ++++++++++++++++++++
2 files changed, 121 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/0b3d7813/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 9b4c377..6dee64f 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
@@ -140,6 +140,36 @@ public abstract class AgentTestBase extends YarnZKMiniClusterTestBase {
clusterOps)
}
+ /**
+ * Update an agent cluster
+ * @param clustername
+ * @param roles
+ * @param extraArgs
+ * @param deleteExistingData
+ * @return the cluster launcher
+ */
+ public ServiceLauncher<SliderClient> updateAgentCluster(
+ String clustername,
+ Map<String, Integer> roles,
+ List<String> extraArgs,
+ boolean deleteExistingData) {
+
+ YarnConfiguration conf = testConfiguration
+
+ def clusterOps = [
+ :
+ ]
+
+ return createOrBuildCluster(
+ SliderActions.ACTION_UPDATE,
+ clustername,
+ roles,
+ extraArgs,
+ deleteExistingData,
+ false,
+ clusterOps)
+ }
+
public String getApplicationHome() {
return "/"
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/0b3d7813/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestBuildBasicAgent.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestBuildBasicAgent.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestBuildBasicAgent.groovy
index 421920f..683a787 100644
--- a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestBuildBasicAgent.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestBuildBasicAgent.groovy
@@ -223,7 +223,98 @@ class TestBuildBasicAgent extends AgentTestBase {
true, false,
false)
}
+ @Test
+ public void testUpdate() throws Throwable {
+
+ def clustername = "test_update_basic_agent"
+ createMiniCluster(
+ clustername,
+ configuration,
+ 1,
+ 1,
+ 1,
+ true,
+ false)
+
+ def master = "hbase-master"
+ def rs = "hbase-rs"
+ ServiceLauncher<SliderClient> launcher = buildAgentCluster(clustername,
+ [
+ (ROLE_NODE): 5,
+ (master): 1,
+ (rs): 5
+ ],
+ [
+ ARG_OPTION, CONTROLLER_URL, "http://localhost",
+ ARG_OPTION, PACKAGE_PATH, ".",
+ ARG_OPTION, APP_DEF, "file://" + getAppDef().absolutePath,
+ ARG_OPTION, AGENT_CONF, "file://" + getAgentConf().absolutePath,
+ ARG_COMP_OPT, master, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_COMP_OPT, rs, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_RES_COMP_OPT, master, ResourceKeys.COMPONENT_PRIORITY, "2",
+ ARG_RES_COMP_OPT, rs, ResourceKeys.COMPONENT_PRIORITY, "3",
+ ARG_COMP_OPT, master, SERVICE_NAME, "HBASE",
+ ARG_COMP_OPT, rs, SERVICE_NAME, "HBASE",
+ ARG_COMP_OPT, master, AgentKeys.APP_HOME, "/share/hbase/hbase-0.96.1-hadoop2",
+ ARG_COMP_OPT, rs, AgentKeys.APP_HOME, "/share/hbase/hbase-0.96.1-hadoop2",
+ ARG_COMP_OPT, ROLE_NODE, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_RES_COMP_OPT, ROLE_NODE, ResourceKeys.COMPONENT_PRIORITY, "1",
+ ],
+ true, false,
+ false)
+ def instanceD = launcher.service.loadPersistedClusterDescription(
+ clustername)
+ dumpClusterDescription("$clustername:", instanceD)
+ def resource = instanceD.getResourceOperations()
+
+ def agentComponent = resource.getMandatoryComponent(ROLE_NODE)
+ agentComponent.getMandatoryOption(ResourceKeys.COMPONENT_PRIORITY)
+ def masterC = resource.getMandatoryComponent(master)
+ assert "2" == masterC.getMandatoryOption(ResourceKeys.COMPONENT_PRIORITY)
+
+ def rscomponent = resource.getMandatoryComponent(rs)
+ assert "5" == rscomponent.getMandatoryOption(ResourceKeys.COMPONENT_INSTANCES)
+
+ // change master priority and rs instances through update action
+ ServiceLauncher<SliderClient> launcher2 = updateAgentCluster(clustername,
+ [
+ (ROLE_NODE): 5,
+ (master): 1,
+ (rs): 6
+ ],
+ [
+ ARG_OPTION, CONTROLLER_URL, "http://localhost",
+ ARG_OPTION, PACKAGE_PATH, ".",
+ ARG_OPTION, APP_DEF, "file://" + getAppDef().absolutePath,
+ ARG_OPTION, AGENT_CONF, "file://" + getAgentConf().absolutePath,
+ ARG_COMP_OPT, master, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_COMP_OPT, rs, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_RES_COMP_OPT, master, ResourceKeys.COMPONENT_PRIORITY, "4",
+ ARG_RES_COMP_OPT, rs, ResourceKeys.COMPONENT_PRIORITY, "3",
+ ARG_COMP_OPT, master, SERVICE_NAME, "HBASE",
+ ARG_COMP_OPT, rs, SERVICE_NAME, "HBASE",
+ ARG_COMP_OPT, master, AgentKeys.APP_HOME, "/share/hbase/hbase-0.96.1-hadoop2",
+ ARG_COMP_OPT, rs, AgentKeys.APP_HOME, "/share/hbase/hbase-0.96.1-hadoop2",
+ ARG_COMP_OPT, ROLE_NODE, SCRIPT_PATH, "agent/scripts/agent.py",
+ ARG_RES_COMP_OPT, ROLE_NODE, ResourceKeys.COMPONENT_PRIORITY, "1",
+ ],
+ true)
+ def instanceDef = launcher.service.loadPersistedClusterDescription(
+ clustername)
+ dumpClusterDescription("$clustername:", instanceDef)
+ def resource2 = instanceDef.getResourceOperations()
+
+ def agentComponent2 = resource2.getMandatoryComponent(ROLE_NODE)
+ agentComponent2.getMandatoryOption(ResourceKeys.COMPONENT_PRIORITY)
+
+ def masterC2 = resource2.getMandatoryComponent(master)
+ assert "4" == masterC2.getMandatoryOption(ResourceKeys.COMPONENT_PRIORITY)
+
+ def rscomponent2 = resource2.getMandatoryComponent(rs)
+ assert "6" == rscomponent2.getMandatoryOption(ResourceKeys.COMPONENT_INSTANCES)
+ }
+
public AggregateConf loadInstanceDefinition(String name) {
def cluster4
def sliderFS = createSliderFileSystem()