http://git-wip-us.apache.org/repos/asf/ambari/blob/1427726a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java index 34bac2a..aecf979 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java @@ -351,6 +351,43 @@ public class UpgradeHelperTest { assertEquals(1, groups.get(2).items.size()); } + /** + * Test a Cluster Group that has parallelization enabled. + * On 4 hosts and batch size of 2, the stage will have 2 batches. + * @throws Exception + */ + @Test + public void testClusterGroupBatchSize() throws Exception { + Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1"); + + ServiceInfo si = ambariMetaInfo.getService("HDP", "2.1.1", "ZOOKEEPER"); + si.setDisplayName("Zk"); + ComponentInfo ci = si.getComponentByName("ZOOKEEPER_SERVER"); + ci.setDisplayName("ZooKeeper1 Server2"); + + assertTrue(upgrades.size() > 0); + assertTrue(upgrades.containsKey("upgrade_test_batch")); + UpgradePack upgrade = upgrades.get("upgrade_test_batch"); + assertNotNull(upgrade); + assertTrue(upgrade.getType() == UpgradeType.NON_ROLLING); + + makeCluster(); + + UpgradeContext context = new UpgradeContext(m_masterHostResolver, HDP_21, + HDP_21, UPGRADE_VERSION, Direction.UPGRADE, UpgradeType.ROLLING); + + List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgrade, context); + + assertEquals(3, groups.size()); + UpgradeGroupHolder group = groups.get(0); + assertEquals("ALL_HOST_OPS", group.name); + assertEquals("Set Version On All Hosts", group.title); + List<StageWrapper> stageWrappers = group.items; + assertEquals(2, stageWrappers.size()); + assertEquals("Update stack to 2.2.1.0-1234 on 2 hosts (Batch 1 of 2)", stageWrappers.get(0).getText()); + assertEquals("Update stack to 2.2.1.0-1234 on 2 hosts (Batch 2 of 2)", stageWrappers.get(1).getText()); + } + @Test public void testUpgradeServerActionOrchestration() throws Exception { Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
http://git-wip-us.apache.org/repos/asf/ambari/blob/1427726a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_batch.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_batch.xml b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_batch.xml new file mode 100644 index 0000000..1cebae7 --- /dev/null +++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_batch.xml @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<!-- + 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. +--> + + +<upgrade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <target>2.2.*.*</target> + <target-stack>HDP-2.2.3</target-stack> + <type>NON_ROLLING</type> + <prerequisite-checks> + </prerequisite-checks> + <order> + + <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts"> + <skippable>true</skippable> + <execute-stage title="Update stack to {{version}}"> + <!-- Test the batch size on a group of type CLUSTER --> + <parallel-scheduler> + <max-degree-of-parallelism>2</max-degree-of-parallelism> + </parallel-scheduler> + + <task xsi:type="execute"> + <script>scripts/ru_set_all.py</script> + <function>actionexecute</function> + </task> + </execute-stage> + </group> + + <group xsi:type="restart" name="ZOOKEEPER" title="Zookeeper"> + <service name="ZOOKEEPER"> + <service-check>false</service-check> + <component>ZOOKEEPER_SERVER</component> + </service> + </group> + + <group xsi:type="cluster" name="POST_CLUSTER" title="Finalize {{direction.text.proper}}"> + <skippable>true</skippable> + + <execute-stage title="Confirm Finalize"> + <direction>UPGRADE</direction> + <task xsi:type="manual"> + <message>Please confirm you are ready to finalize.</message> + </task> + </execute-stage> + + <execute-stage service="HDFS" component="NAMENODE" title="Execute HDFS Finalize"> + <task xsi:type="execute" hosts="master"> + <script>scripts/namenode.py</script> + <function>finalize_non_rolling_upgrade</function> + </task> + </execute-stage> + + <execute-stage title="Save Cluster State" service="" component=""> + <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.FinalizeUpgradeAction"> + </task> + </execute-stage> + </group> + </order> +</upgrade> \ No newline at end of file