Repository: ambari Updated Branches: refs/heads/branch-dev-patch-upgrade 2d60c5267 -> 75a91e35a
AMBARI-18473. Scope and Services need to be used for orchestration (ncole) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/75a91e35 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/75a91e35 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/75a91e35 Branch: refs/heads/branch-dev-patch-upgrade Commit: 75a91e35a4435e2ce85076dff4e35f580425a666 Parents: 2d60c52 Author: Nate Cole <[email protected]> Authored: Tue Sep 27 11:03:16 2016 -0400 Committer: Nate Cole <[email protected]> Committed: Wed Sep 28 13:28:48 2016 -0400 ---------------------------------------------------------------------- .../internal/UpgradeResourceProvider.java | 40 +++++++---- .../upgrades/AbstractUpgradeServerAction.java | 73 ++++++++++++++++++++ .../upgrades/ComponentVersionCheckAction.java | 2 +- .../upgrades/FinalizeUpgradeAction.java | 41 +++-------- .../ambari/server/state/UpgradeContext.java | 10 +++ .../state/stack/upgrade/ClusterGrouping.java | 34 +-------- .../ComponentVersionCheckActionTest.java | 69 +++++++++++++++++- 7 files changed, 193 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java index 15caa69..3d3773b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java @@ -36,6 +36,8 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.ambari.annotations.Experimental; +import org.apache.ambari.annotations.ExperimentalFeature; import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.Role; import org.apache.ambari.server.RoleCommand; @@ -194,11 +196,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider Arrays.asList(UPGRADE_REQUEST_ID, UPGRADE_CLUSTER_NAME)); private static final Set<String> PROPERTY_IDS = new HashSet<>(); - private static final String COMMAND_PARAM_VERSION = VERSION; - private static final String COMMAND_PARAM_CLUSTER_NAME = "clusterName"; - private static final String COMMAND_PARAM_DIRECTION = "upgrade_direction"; + public static final String COMMAND_PARAM_VERSION = VERSION; + public static final String COMMAND_PARAM_CLUSTER_NAME = "clusterName"; + public static final String COMMAND_PARAM_DIRECTION = "upgrade_direction"; private static final String COMMAND_PARAM_UPGRADE_PACK = "upgrade_pack"; - private static final String COMMAND_PARAM_REQUEST_ID = "request_id"; + public static final String COMMAND_PARAM_REQUEST_ID = "request_id"; // TODO AMBARI-12698, change this variable name since it is no longer always a restart. Possible values are rolling_upgrade or nonrolling_upgrade // This will involve changing Script.py @@ -207,19 +209,25 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider private static final String COMMAND_PARAM_STRUCT_OUT = "structured_out"; private static final String COMMAND_DOWNGRADE_FROM_VERSION = "downgrade_from_version"; + /** * The original "current" stack of the cluster before the upgrade started. * This is the same regardless of whether the current direction is * {@link Direction#UPGRADE} or {@link Direction#DOWNGRADE}. */ - private static final String COMMAND_PARAM_ORIGINAL_STACK = "original_stack"; + public static final String COMMAND_PARAM_ORIGINAL_STACK = "original_stack"; /** * The target upgrade stack before the upgrade started. This is the same * regardless of whether the current direction is {@link Direction#UPGRADE} or * {@link Direction#DOWNGRADE}. */ - private static final String COMMAND_PARAM_TARGET_STACK = "target_stack"; + public static final String COMMAND_PARAM_TARGET_STACK = "target_stack"; + + /** + * The list of supported services put on a command. + */ + public static final String COMMAND_PARAM_SUPPORTED_SERVICES = "supported_services"; private static final String DEFAULT_REASON_TEMPLATE = "Aborting upgrade %s"; @@ -813,6 +821,12 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider try { VersionDefinitionXml vdf = targetRepositoryVersion.getRepositoryXml(); supportedServices.addAll(vdf.getAvailableServiceNames()); + + // !!! better not be, but just in case + if (!supportedServices.isEmpty()) { + scope = UpgradeScope.PARTIAL; + } + } catch (Exception e) { String msg = String.format("Could not parse version definition for %s. Upgrade will not proceed.", version); LOG.error(msg, e); @@ -917,16 +931,17 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider // HDP 2.2 to 2.4 should start with HDP 2.2 and merge in HDP 2.3's config-upgrade.xml ConfigUpgradePack configUpgradePack = ConfigurationPackBuilder.build(pack, sourceStackId); - // TODO: for now, all service components are transitioned to upgrading state - // TODO: When performing patch upgrade, we should only target supported services/components - // from upgrade pack Set<Service> services = new HashSet<>(cluster.getServices().values()); + + @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES) Map<Service, Set<ServiceComponent>> targetComponents = new HashMap<>(); for (Service service: services) { - Set<ServiceComponent> serviceComponents = - new HashSet<>(service.getServiceComponents().values()); - targetComponents.put(service, serviceComponents); + if (ctx.isServiceSupported(service.getName())) { + Set<ServiceComponent> serviceComponents = new HashSet<>(service.getServiceComponents().values()); + targetComponents.put(service, serviceComponents); + } } + // TODO: is there any extreme case when we need to set component upgrade state back to NONE // from IN_PROGRESS (e.g. canceled downgrade) s_upgradeHelper.putComponentsToUpgradingState(version, targetComponents); @@ -1619,6 +1634,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider commandParams.put(COMMAND_PARAM_TARGET_STACK, context.getTargetStackId().getStackId()); commandParams.put(COMMAND_DOWNGRADE_FROM_VERSION, context.getDowngradeFromVersion()); commandParams.put(COMMAND_PARAM_UPGRADE_PACK, upgradePack.getName()); + commandParams.put(COMMAND_PARAM_SUPPORTED_SERVICES, StringUtils.join(context.getSupportedServices(), ',')); // Notice that this does not apply any params because the input does not specify a stage. // All of the other actions do use additional params. http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/AbstractUpgradeServerAction.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/AbstractUpgradeServerAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/AbstractUpgradeServerAction.java new file mode 100644 index 0000000..a0b3980 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/AbstractUpgradeServerAction.java @@ -0,0 +1,73 @@ +/** + * 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.ambari.server.serveraction.upgrades; + +import java.util.Collections; +import java.util.Set; + +import org.apache.ambari.server.controller.internal.UpgradeResourceProvider; +import org.apache.ambari.server.serveraction.AbstractServerAction; +import org.apache.ambari.server.state.Clusters; +import org.apache.ambari.server.state.stack.upgrade.Direction; +import org.apache.commons.lang.StringUtils; +import org.apache.hadoop.metrics2.sink.relocated.google.common.collect.Sets; + +import com.google.inject.Inject;; + +/** + * Abstract class that reads values from command params in a consistent way. + */ +public abstract class AbstractUpgradeServerAction extends AbstractServerAction { + + public static final String CLUSTER_NAME_KEY = UpgradeResourceProvider.COMMAND_PARAM_CLUSTER_NAME; + public static final String UPGRADE_DIRECTION_KEY = UpgradeResourceProvider.COMMAND_PARAM_DIRECTION; + public static final String VERSION_KEY = UpgradeResourceProvider.COMMAND_PARAM_VERSION; + protected static final String REQUEST_ID = UpgradeResourceProvider.COMMAND_PARAM_REQUEST_ID; + + /** + * The original "current" stack of the cluster before the upgrade started. + * This is the same regardless of whether the current direction is + * {@link Direction#UPGRADE} or {@link Direction#DOWNGRADE}. + */ + protected static final String ORIGINAL_STACK_KEY = UpgradeResourceProvider.COMMAND_PARAM_ORIGINAL_STACK; + + /** + * The target upgrade stack before the upgrade started. This is the same + * regardless of whether the current direction is {@link Direction#UPGRADE} or + * {@link Direction#DOWNGRADE}. + */ + protected static final String TARGET_STACK_KEY = UpgradeResourceProvider.COMMAND_PARAM_TARGET_STACK; + + protected static final String SUPPORTED_SERVICES_KEY = UpgradeResourceProvider.COMMAND_PARAM_SUPPORTED_SERVICES; + + @Inject + protected Clusters m_clusters; + + /** + * @return the set of supported services + */ + protected Set<String> getSupportedServices() { + String services = getCommandParameterValue(SUPPORTED_SERVICES_KEY); + if (StringUtils.isBlank(services)) { + return Collections.emptySet(); + } else { + return Sets.newHashSet(StringUtils.split(services, ',')); + } + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java index 7705c7d..52c0cf2 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java @@ -53,7 +53,7 @@ public class ComponentVersionCheckAction extends FinalizeUpgradeAction { StackId targetStackId = new StackId(commandParams.get(TARGET_STACK_KEY)); String clusterName = getExecutionCommand().getClusterName(); - Cluster cluster = clusters.getCluster(clusterName); + Cluster cluster = m_clusters.getCluster(clusterName); List<InfoTuple> errors = checkHostComponentVersions(cluster, version, targetStackId); http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java index a07d0e6..90a38b3 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java @@ -47,9 +47,7 @@ import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity; import org.apache.ambari.server.orm.entities.ServiceComponentHistoryEntity; import org.apache.ambari.server.orm.entities.StackEntity; import org.apache.ambari.server.orm.entities.UpgradeEntity; -import org.apache.ambari.server.serveraction.AbstractServerAction; import org.apache.ambari.server.state.Cluster; -import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.ComponentInfo; import org.apache.ambari.server.state.RepositoryVersionState; import org.apache.ambari.server.state.Service; @@ -57,7 +55,6 @@ import org.apache.ambari.server.state.ServiceComponent; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.state.UpgradeState; -import org.apache.ambari.server.state.stack.upgrade.Direction; import org.apache.ambari.server.state.svccomphost.ServiceComponentHostSummary; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.text.StrBuilder; @@ -67,35 +64,11 @@ import com.google.inject.Inject; /** * Action that represents finalizing the Upgrade by completing any database changes. */ -public class FinalizeUpgradeAction extends AbstractServerAction { +public class FinalizeUpgradeAction extends AbstractUpgradeServerAction { - public static final String CLUSTER_NAME_KEY = "cluster_name"; - public static final String UPGRADE_DIRECTION_KEY = "upgrade_direction"; - public static final String VERSION_KEY = "version"; - public static final String REQUEST_ID = "request_id"; public static final String PREVIOUS_UPGRADE_NOT_COMPLETED_MSG = "It is possible that a previous upgrade was not finalized. " + "For this reason, Ambari will not remove any configs. Please ensure that all database records are correct."; - /** - * The original "current" stack of the cluster before the upgrade started. - * This is the same regardless of whether the current direction is - * {@link Direction#UPGRADE} or {@link Direction#DOWNGRADE}. - */ - public static final String ORIGINAL_STACK_KEY = "original_stack"; - - /** - * The target upgrade stack before the upgrade started. This is the same - * regardless of whether the current direction is {@link Direction#UPGRADE} or - * {@link Direction#DOWNGRADE}. - */ - public static final String TARGET_STACK_KEY = "target_stack"; - - /** - * The Cluster that this ServerAction implementation is executing on - */ - @Inject - protected Clusters clusters; - @Inject private ClusterVersionDAO clusterVersionDAO; @@ -164,7 +137,7 @@ public class FinalizeUpgradeAction extends AbstractServerAction { try { outSB.append(MessageFormat.format("Begin finalizing the upgrade of cluster {0} to version {1}\n", clusterName, version)); - Cluster cluster = clusters.getCluster(clusterName); + Cluster cluster = m_clusters.getCluster(clusterName); StackId clusterDesiredStackId = cluster.getDesiredStackVersion(); StackId clusterCurrentStackId = cluster.getCurrentStackVersion(); @@ -353,7 +326,7 @@ public class FinalizeUpgradeAction extends AbstractServerAction { StringBuilder err = new StringBuilder(); try { - Cluster cluster = clusters.getCluster(clusterName); + Cluster cluster = m_clusters.getCluster(clusterName); StackId currentClusterStackId = cluster.getCurrentStackVersion(); // Safety check that the cluster's stack (from clusterstate's current_stack_id) is equivalent to the @@ -477,7 +450,15 @@ public class FinalizeUpgradeAction extends AbstractServerAction { ArrayList<InfoTuple> errors = new ArrayList<InfoTuple>(); + Set<String> supportedServices = getSupportedServices(); + for (Service service : cluster.getServices().values()) { + + // !!! if there are supported services for upgrade, and the cluster service is NOT in the list, skip + if (!supportedServices.isEmpty() && !supportedServices.contains(service.getName())) { + continue; + } + for (ServiceComponent serviceComponent : service.getServiceComponents().values()) { for (ServiceComponentHost serviceComponentHost : serviceComponent.getServiceComponentHosts().values()) { ComponentInfo componentInfo = ambariMetaInfo.getComponent(targetStackId.getStackName(), http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java index 2f616e7..36fcac5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java @@ -18,6 +18,7 @@ package org.apache.ambari.server.state; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -372,6 +373,15 @@ public class UpgradeContext { } /** + * @return the set of supported services, or an empty set if ALL services + * are supported + */ + @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES) + public Set<String> getSupportedServices() { + return Collections.unmodifiableSet(m_supported); + } + + /** * Gets if a service is supported. If there are no services marked for the context, * then ALL services are supported * @param serviceName the service name to check. http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java index 80bb26c..0c8c25e 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ClusterGrouping.java @@ -25,7 +25,6 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; @@ -44,10 +43,6 @@ import org.apache.ambari.server.state.UpgradeContext; import org.apache.ambari.server.state.stack.UpgradePack.ProcessingComponent; import org.apache.commons.lang.StringUtils; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - /** * Used to represent cluster-based operations. */ @@ -103,7 +98,6 @@ public class ClusterGrouping extends Grouping { @XmlElement(name="scope") public UpgradeScope scope = UpgradeScope.ANY; - } public class ClusterBuilder extends StageWrapperBuilder { @@ -235,6 +229,7 @@ public class ClusterGrouping extends Grouping { return null; } + // !!! FUTURE: check for component HostsType hosts = ctx.getResolver().getMasterAndHosts(service, component); @@ -288,35 +283,10 @@ public class ClusterGrouping extends Grouping { } /** - * Populates the manual task, mt, with information about the list of hosts. - * @param mt Manual Task - * @param hostToComponents Map from host name to list of components - */ - private void fillHostDetails(ManualTask mt, Map<String, List<String>> hostToComponents) { - JsonArray arr = new JsonArray(); - for (Entry<String, List<String>> entry : hostToComponents.entrySet()) { - JsonObject hostObj = new JsonObject(); - hostObj.addProperty("host", entry.getKey()); - - JsonArray componentArr = new JsonArray(); - for (String comp : entry.getValue()) { - componentArr.add(new JsonPrimitive(comp)); - } - hostObj.add("components", componentArr); - - arr.add(hostObj); - } - - JsonObject obj = new JsonObject(); - obj.add("unhealthy", arr); - - mt.structuredOut = obj.toString(); - } - - /** * Attempts to merge the given cluster groupings. This merges the execute stages * in an order specific manner. */ + @Override public void merge(Iterator<Grouping> iterator) throws AmbariException { if (executionStages == null) { executionStages = new ArrayList<ExecuteStage>(); http://git-wip-us.apache.org/repos/asf/ambari/blob/75a91e35/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java index 207b4c7..283c300 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java @@ -274,7 +274,6 @@ public class ComponentVersionCheckActionTest { assertNotNull(report); assertEquals(HostRoleStatus.COMPLETED.name(), report.getStatus()); assertEquals(0, report.getExitCode()); - } @Test @@ -351,6 +350,74 @@ public class ComponentVersionCheckActionTest { assertEquals(-1, report.getExitCode()); } + @Test + public void testMatchingPartialVersions() throws Exception { + StackId sourceStack = HDP_21_STACK; + StackId targetStack = HDP_21_STACK; + String sourceRepo = HDP_2_1_1_0; + String targetRepo = HDP_2_1_1_1; + + makeUpgradeCluster(sourceStack, sourceRepo, targetStack, targetRepo); + + Clusters clusters = m_injector.getInstance(Clusters.class); + + Host host = clusters.getHost("h1"); + Assert.assertNotNull(host); + host.setOsInfo("redhat6"); + + Cluster cluster = clusters.getCluster("c1"); + clusters.mapHostToCluster("h1", "c1"); + + Service service = installService(cluster, "HDFS"); + ServiceComponent sc = addServiceComponent(cluster, service, "NAMENODE"); + sc.setDesiredVersion(HDP_2_1_1_0); + + sc = addServiceComponent(cluster, service, "DATANODE"); + sc.setDesiredVersion(HDP_2_1_1_0); + + ServiceComponentHost sch = createNewServiceComponentHost(cluster, "HDFS", "NAMENODE", "h1"); + sch.setVersion(HDP_2_1_1_0); + sch = createNewServiceComponentHost(cluster, "HDFS", "DATANODE", "h1"); + sch.setVersion(HDP_2_1_1_0); + + service = installService(cluster, "ZOOKEEPER"); + sc = addServiceComponent(cluster, service, "ZOOKEEPER_SERVER"); + sc.setDesiredVersion(HDP_2_1_1_1); + + sch = createNewServiceComponentHost(cluster, "ZOOKEEPER", "ZOOKEEPER_SERVER", "h1"); + sch.setVersion(HDP_2_1_1_1); + + // Verify the repo before calling Finalize + AmbariMetaInfo metaInfo = m_injector.getInstance(AmbariMetaInfo.class); + + RepositoryInfo repo = metaInfo.getRepository(sourceStack.getStackName(), sourceStack.getStackVersion(), "redhat6", sourceStack.getStackId()); + assertEquals(HDP_211_CENTOS6_REPO_URL, repo.getBaseUrl()); + + // Finalize the upgrade + Map<String, String> commandParams = new HashMap<String, String>(); + commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade"); + commandParams.put(FinalizeUpgradeAction.VERSION_KEY, targetRepo); + commandParams.put(FinalizeUpgradeAction.SUPPORTED_SERVICES_KEY, "ZOOKEEPER"); + commandParams.put(FinalizeUpgradeAction.TARGET_STACK_KEY, "HDP-2.1.1"); + + ExecutionCommand executionCommand = new ExecutionCommand(); + executionCommand.setCommandParams(commandParams); + executionCommand.setClusterName("c1"); + + HostRoleCommand hostRoleCommand = hostRoleCommandFactory.create(null, null, null, null); + hostRoleCommand.setExecutionCommandWrapper(new ExecutionCommandWrapper(executionCommand)); + + ComponentVersionCheckAction action = m_injector.getInstance(ComponentVersionCheckAction.class); + action.setExecutionCommand(executionCommand); + action.setHostRoleCommand(hostRoleCommand); + + CommandReport report = action.execute(null); + assertNotNull(report); + assertEquals(HostRoleStatus.COMPLETED.name(), report.getStatus()); + assertEquals(0, report.getExitCode()); + + } + private ServiceComponentHost createNewServiceComponentHost(Cluster cluster, String svc, String svcComponent, String hostName) throws AmbariException { Assert.assertNotNull(cluster.getConfigGroups());
