SLIDER-985 add minicluster test of AA placement
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/8c5065d9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/8c5065d9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/8c5065d9 Branch: refs/heads/feature/SLIDER-82-pass-3.1 Commit: 8c5065d92406b766953cc99369cc1b9af02d392d Parents: 178bd96 Author: Steve Loughran <[email protected]> Authored: Fri Nov 13 18:19:12 2015 +0000 Committer: Steve Loughran <[email protected]> Committed: Fri Nov 13 18:19:12 2015 +0000 ---------------------------------------------------------------------- .../slider/providers/PlacementPolicy.java | 2 +- .../providers/agent/TestAgentAAEcho.groovy | 99 ++++++++++++++++++++ .../slider/providers/agent/TestAgentEcho.groovy | 12 ++- slider-core/src/test/python/metainfo.xml | 2 +- 4 files changed, 109 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8c5065d9/slider-core/src/main/java/org/apache/slider/providers/PlacementPolicy.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/providers/PlacementPolicy.java b/slider-core/src/main/java/org/apache/slider/providers/PlacementPolicy.java index e0913a5..71d7566 100644 --- a/slider-core/src/main/java/org/apache/slider/providers/PlacementPolicy.java +++ b/slider-core/src/main/java/org/apache/slider/providers/PlacementPolicy.java @@ -46,7 +46,7 @@ public class PlacementPolicy { public static final int NO_DATA_LOCALITY = 2; /** - * Anti-affinity is mandatory. This is not supported in YARN + * Anti-affinity is mandatory. */ public static final int ANTI_AFFINITY_REQUIRED = 4; http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8c5065d9/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy new file mode 100644 index 0000000..0b89f47 --- /dev/null +++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.slider.providers.agent + +import groovy.transform.CompileStatic +import groovy.util.logging.Slf4j +import org.apache.slider.api.ResourceKeys +import org.apache.slider.client.SliderClient +import org.apache.slider.common.SliderXmlConfKeys +import org.apache.slider.core.main.ServiceLauncher +import org.apache.slider.providers.PlacementPolicy +import org.junit.Test + +import static org.apache.slider.common.params.Arguments.* +import static org.apache.slider.providers.agent.AgentKeys.* + +/** + * Tests an echo command + */ +@CompileStatic +@Slf4j +class TestAgentAAEcho extends TestAgentEcho { + + @Test + public void testEchoOperation() throws Throwable { + assumeValidServerEnv() + + String clustername = createMiniCluster("", + configuration, + 1, + 1, + 1, + true, + false) + + validatePaths() + + def echo = "echo" + Map<String, Integer> roles = [ + (echo): 2, + ]; + ServiceLauncher<SliderClient> launcher = buildAgentCluster(clustername, + roles, + [ + ARG_OPTION, PACKAGE_PATH, slider_core.absolutePath, + ARG_OPTION, APP_DEF, toURIArg(app_def_path), + ARG_OPTION, AGENT_CONF, toURIArg(agt_conf_path), + ARG_OPTION, AGENT_VERSION, toURIArg(agt_ver_path), + ARG_RES_COMP_OPT, echo, ResourceKeys.COMPONENT_PRIORITY, "1", + ARG_RES_COMP_OPT, echo, ResourceKeys.COMPONENT_PLACEMENT_POLICY, + "" + PlacementPolicy.ANTI_AFFINITY_REQUIRED, + ARG_COMP_OPT, echo, SCRIPT_PATH, echo_py, + ARG_COMP_OPT, echo, SERVICE_NAME, "Agent", + ARG_DEFINE, + SliderXmlConfKeys.KEY_SLIDER_AM_DEPENDENCY_CHECKS_DISABLED + "=false", + ARG_COMP_OPT, echo, TEST_RELAX_VERIFICATION, "true", + + ], + true, true, + true) + SliderClient sliderClient = launcher.service + + + def onlyOneEcho = [(echo): 1] + waitForRoleCount(sliderClient, onlyOneEcho, AGENT_CLUSTER_STARTUP_TIME) + //sleep a bit + sleep(5000) + //expect the role count to be the same + waitForRoleCount(sliderClient, onlyOneEcho, 1000) + + // flex size + // while running, ask for many more, expect them to still be outstanding + sleep(5000) + waitForRoleCount(sliderClient, onlyOneEcho, 1000) + sliderClient.flex(clustername, onlyOneEcho); + + // while running, flex it with no changes + sliderClient.flex(clustername, [(echo): 3]); + sleep(1000) + waitForRoleCount(sliderClient, onlyOneEcho, 1000) + + } +} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8c5065d9/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentEcho.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentEcho.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentEcho.groovy index 973114d..f14fc43 100644 --- a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentEcho.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentEcho.groovy @@ -79,10 +79,7 @@ class TestAgentEcho extends AgentTestBase { true, false) - assert echo_py_path.exists() - assert app_def_path.exists() - assert agt_ver_path.exists() - assert agt_conf_path.exists() + validatePaths() def role = "echo" Map<String, Integer> roles = [ @@ -128,4 +125,11 @@ class TestAgentEcho extends AgentTestBase { } } + + protected void validatePaths() { + assert echo_py_path.exists() + assert app_def_path.exists() + assert agt_ver_path.exists() + assert agt_conf_path.exists() + } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8c5065d9/slider-core/src/test/python/metainfo.xml ---------------------------------------------------------------------- diff --git a/slider-core/src/test/python/metainfo.xml b/slider-core/src/test/python/metainfo.xml index cf4afe1..2a8c9e0 100644 --- a/slider-core/src/test/python/metainfo.xml +++ b/slider-core/src/test/python/metainfo.xml @@ -51,7 +51,7 @@ <name>echo</name> <category>MASTER</category> <minInstanceCount>1</minInstanceCount> - <maxInstanceCount>2</maxInstanceCount> + <maxInstanceCount>200</maxInstanceCount> <commandScript> <script>echo.py</script> <scriptType>PYTHON</scriptType>
