AMBARI-22194 - Prevent Patch Upgrades With Known Service Incompatibilities 
(jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c19f363c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c19f363c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c19f363c

Branch: refs/heads/branch-feature-AMBARI-22008
Commit: c19f363c877776623fd42d285717e6e95b9036ad
Parents: 8ec33db
Author: Jonathan Hurley <jhur...@hortonworks.com>
Authored: Tue Oct 10 15:42:30 2017 -0400
Committer: Jonathan Hurley <jhur...@hortonworks.com>
Committed: Wed Oct 11 09:08:27 2017 -0400

----------------------------------------------------------------------
 .../server/checks/AbstractCheckDescriptor.java  |  81 +++++++++++--
 .../ambari/server/checks/CheckDescription.java  |   8 ++
 .../RequiredServicesInRepositoryCheck.java      |  91 +++++++++++++++
 .../ambari/server/checks/UpgradeCheck.java      |  11 ++
 .../ClusterStackVersionResourceProvider.java    |  26 +++++
 .../ambari/server/state/RepositoryType.java     |  18 +++
 .../server/state/repository/StackPackage.java   |  69 +++++++++++
 .../state/repository/VersionDefinitionXml.java  |  87 ++++++++++++++
 .../HDP/2.0.6/properties/stack_packages.json    |   6 +-
 .../checks/AbstractCheckDescriptorTest.java     |   3 +
 .../checks/AutoStartDisabledCheckTest.java      |  12 +-
 .../checks/ClientRetryPropertyCheckTest.java    |   2 +
 .../checks/ComponentExistsInRepoCheckTest.java  |   2 +
 .../checks/ComponentsInstallationCheckTest.java |   3 +
 .../checks/ConfigurationMergeCheckTest.java     |   2 +
 .../checks/DruidHighAvailabilityCheckTest.java  |   2 +
 .../checks/HiveMultipleMetastoreCheckTest.java  |   3 +
 .../checks/HiveNotRollingWarningTest.java       |   3 +
 .../server/checks/HostsHeartbeatCheckTest.java  |   2 +
 .../checks/HostsMasterMaintenanceCheckTest.java |   5 +-
 .../checks/HostsRepositoryVersionCheckTest.java |   2 +
 .../server/checks/InstallPackagesCheckTest.java |   2 +
 .../server/checks/KafkaKerberosCheckTest.java   |   2 +
 ...duce2JobHistoryStatePreservingCheckTest.java |   2 +
 .../server/checks/RangerAuditDbCheckTest.java   |   3 +
 .../server/checks/RangerPasswordCheckTest.java  |   3 +
 .../server/checks/RangerSSLConfigCheckTest.java |   3 +
 .../RequiredServicesInRepositoryCheckTest.java  | 116 +++++++++++++++++++
 .../SecondaryNamenodeDeletedCheckTest.java      |   3 +
 .../ServicesMaintenanceModeCheckTest.java       |   2 +
 ...vicesMapReduceDistributedCacheCheckTest.java |   3 +
 ...rvicesNamenodeHighAvailabilityCheckTest.java |   3 +
 .../ServicesNamenodeTruncateCheckTest.java      |   2 +
 .../ServicesTezDistributedCacheCheckTest.java   |   3 +
 .../server/checks/ServicesUpCheckTest.java      |   2 +
 .../ServicesYarnWorkPreservingCheckTest.java    |   2 +
 .../server/checks/StormShutdownWarningTest.java |   3 +
 .../ambari/server/state/CheckHelperTest.java    |   7 ++
 38 files changed, 588 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
index 6726d30..478489d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
@@ -35,6 +35,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -44,11 +45,11 @@ import 
org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.ambari.server.state.stack.UpgradePack;
 import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
 import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Lists;
+import com.google.gson.Gson;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
@@ -57,8 +58,6 @@ import com.google.inject.Provider;
  */
 public abstract class AbstractCheckDescriptor {
 
-  private static final Logger LOG = 
LoggerFactory.getLogger(AbstractCheckDescriptor.class);
-
   protected static final String DEFAULT = "default";
 
   @Inject
@@ -82,6 +81,9 @@ public abstract class AbstractCheckDescriptor {
   @Inject
   Configuration config;
 
+  @Inject
+  Gson gson;
+
   private CheckDescription m_description;
 
   /**
@@ -128,7 +130,7 @@ public abstract class AbstractCheckDescriptor {
    */
   public final boolean isApplicable(PrereqCheckRequest request) throws 
AmbariException {
     List<CheckQualification> qualifications = Lists.newArrayList(
-        new ServiceQualification());
+        new ServiceQualification(), new 
OrchestrationQualification(getClass()));
 
     // add any others from the concrete check
     qualifications.addAll(getQualifications());
@@ -302,6 +304,27 @@ public abstract class AbstractCheckDescriptor {
   }
 
   /**
+   * Gets a de-serialized {@link VersionDefinitionXml} from the repository for
+   * this upgrade.
+   *
+   * @param request
+   *          the upgrade check request.
+   * @return the VDF XML
+   * @throws AmbariException
+   */
+  final VersionDefinitionXml getVersionDefinitionXml(PrereqCheckRequest 
request) throws AmbariException {
+    RepositoryVersionEntity repositoryVersion = 
request.getTargetRepositoryVersion();
+
+    try {
+      VersionDefinitionXml vdf = repositoryVersion.getRepositoryXml();
+      return vdf;
+    } catch (Exception exception) {
+      throw new AmbariException("Unable to run upgrade checks because of an 
invalid VDF",
+          exception);
+    }
+  }
+
+  /**
    * Gets the services participating in the upgrade from the VDF.
    *
    * @param request
@@ -311,12 +334,11 @@ public abstract class AbstractCheckDescriptor {
    */
   final Set<String> getServicesInUpgrade(PrereqCheckRequest request) throws 
AmbariException {
     final Cluster cluster = 
clustersProvider.get().getCluster(request.getClusterName());
-    RepositoryVersionEntity repositoryVersion = 
request.getTargetRepositoryVersion();
 
     // the check is scoped to some services, so determine if any of those
     // services are included in this upgrade
     try {
-      VersionDefinitionXml vdf = repositoryVersion.getRepositoryXml();
+      VersionDefinitionXml vdf = getVersionDefinitionXml(request);
       ClusterVersionSummary clusterVersionSummary = 
vdf.getClusterSummary(cluster);
       return clusterVersionSummary.getAvailableServiceNames();
     } catch (Exception exception) {
@@ -403,4 +425,47 @@ public abstract class AbstractCheckDescriptor {
       return true;
     }
   }
-}
\ No newline at end of file
+
+  /**
+   * The {@link OrchestrationQualification} class is used to determine if the
+   * check is required to run based on the {@link RepositoryType}.
+   */
+  final class OrchestrationQualification implements CheckQualification {
+
+    private final Class<? extends AbstractCheckDescriptor> m_checkClass;
+
+    /**
+     * Constructor.
+     *
+     * @param checkClass
+     *          the class of the check which is being considered for
+     *          applicability.
+     */
+    public OrchestrationQualification(Class<? extends AbstractCheckDescriptor> 
checkClass) {
+      m_checkClass = checkClass;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isApplicable(PrereqCheckRequest request) throws 
AmbariException {
+      RepositoryVersionEntity repositoryVersion = 
request.getTargetRepositoryVersion();
+      RepositoryType repositoryType = repositoryVersion.getType();
+
+      UpgradeCheck annotation = m_checkClass.getAnnotation(UpgradeCheck.class);
+      if (null == annotation) {
+        return true;
+      }
+
+      RepositoryType[] repositoryTypes = annotation.orchestration();
+
+      if (ArrayUtils.isEmpty(repositoryTypes)
+          || ArrayUtils.contains(repositoryTypes, repositoryType)) {
+        return true;
+      }
+
+      return false;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
index c4d0820..3caac14 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
@@ -352,6 +352,14 @@ public class CheckDescription {
           )
           .build()
   );
+  
+  public static CheckDescription VALID_SERVICES_INCLUDED_IN_REPOSITORY = new 
CheckDescription("VALID_SERVICES_INCLUDED_IN_REPOSITORY",
+      PrereqCheckType.CLUSTER,
+      "The repository is missing services which are required",
+      new ImmutableMap.Builder<String, String>()
+        .put(AbstractCheckDescriptor.DEFAULT,
+            "The following services are included in the upgrade but the 
repository is missing their dependencies:\n%s").build());
+  
 
   private String m_name;
   private PrereqCheckType m_type;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheck.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheck.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheck.java
new file mode 100644
index 0000000..d911411
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheck.java
@@ -0,0 +1,91 @@
+/*
+ * 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.checks;
+
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.repository.VersionDefinitionXml;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
+import org.apache.commons.lang.StringUtils;
+
+import com.google.inject.Singleton;
+
+/**
+ * The {@link RequiredServicesInRepositoryCheck} is used to ensure that if 
there
+ * are any services which require other services to also be included in the
+ * upgrade that they are included in the repository.
+ * <p/>
+ * This check is to prevent problems which can be caused by trying to patch
+ * upgrade services which have known depdenencies on other services because of
+ * things like hard coded versions.
+ */
+@Singleton
+@UpgradeCheck(
+    group = UpgradeCheckGroup.REPOSITORY_VERSION,
+    order = 1.0f,
+    required = { UpgradeType.ROLLING, UpgradeType.NON_ROLLING, 
UpgradeType.HOST_ORDERED },
+    orchestration = { RepositoryType.PATCH, RepositoryType.MAINT, 
RepositoryType.SERVICE })
+public class RequiredServicesInRepositoryCheck extends AbstractCheckDescriptor 
{
+
+  /**
+   * Constructor.
+   */
+  public RequiredServicesInRepositoryCheck() {
+    super(CheckDescription.VALID_SERVICES_INCLUDED_IN_REPOSITORY);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest 
request) throws AmbariException {
+    String clusterName = request.getClusterName();
+    Cluster cluster = clustersProvider.get().getCluster(clusterName);
+
+    VersionDefinitionXml xml = getVersionDefinitionXml(request);
+    Map<String, Set<String>> missingDependencies = 
xml.getMissingDependencies(cluster);
+
+    if (!missingDependencies.isEmpty()) {
+      String failReasonTemplate = getFailReason(prerequisiteCheck, request);
+
+      StringBuilder message = new StringBuilder();
+      for (String failedService : missingDependencies.keySet()) {
+        Set<String> servicesRequired = missingDependencies.get(failedService);
+
+        message.append(String.format(
+            "%s requires the following services which are not included: %s",
+            failedService, StringUtils.join(servicesRequired, 
','))).append(System.lineSeparator());
+      }
+
+      prerequisiteCheck.setFailedOn(new 
LinkedHashSet<>(missingDependencies.keySet()));
+      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
+      prerequisiteCheck.setFailReason(String.format(failReasonTemplate, 
message.toString()));
+      return;
+    }
+
+    prerequisiteCheck.setStatus(PrereqCheckStatus.PASS);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheck.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheck.java 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheck.java
index 58ef4ba..4e03f47 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheck.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheck.java
@@ -23,6 +23,7 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 
 import com.google.inject.ScopeAnnotation;
@@ -69,4 +70,14 @@ public @interface UpgradeCheck {
    *         defined in the upgrade pack or an empty array for none.
    */
   UpgradeType[] required() default {};
+
+
+  /**
+   * The valid orchestration repository type that this check if valid for. By
+   * default, a check is valid for all orchestration types.
+   *
+   * @return the repository types that the check is valid for.
+   */
+  RepositoryType[] orchestration() default { RepositoryType.STANDARD, 
RepositoryType.PATCH,
+      RepositoryType.MAINT, RepositoryType.SERVICE };
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index ba5a4e7..388551f 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -442,6 +442,32 @@ public class ClusterStackVersionResourceProvider extends 
AbstractControllerResou
           String.format("Version %s is backed by a version definition, but it 
could not be parsed", desiredRepoVersion), e);
     }
 
+    // stop the VDF distribution right now if there are problems with service
+    // dependencies
+    try {
+      if (repoVersionEntity.getType().isPartial()) {
+        Map<String, Set<String>> missingDependencies = 
desiredVersionDefinition.getMissingDependencies(cluster);
+
+        if (!missingDependencies.isEmpty()) {
+          StringBuilder message = new StringBuilder(
+              "The following services are included in this repository, but the 
repository is missing their dependencies: ").append(
+                  System.lineSeparator());
+
+          for (String failedService : missingDependencies.keySet()) {
+            message.append(String.format("%s requires the following services: 
%s", failedService,
+                StringUtils.join(missingDependencies.get(failedService), 
','))).append(
+                    System.lineSeparator());
+          }
+
+          throw new SystemException(message.toString());
+        }
+      }
+    } catch (AmbariException ambariException) {
+      throw new SystemException(
+          "Unable to determine if this repository contains the necessary 
service dependencies",
+          ambariException);
+    }
+
     // if true, then we need to force all new host versions into the INSTALLED 
state
     boolean forceInstalled = Boolean.parseBoolean((String)propertyMap.get(
         CLUSTER_STACK_VERSION_FORCE));

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
index bf7eab0..da2eb06 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
@@ -54,6 +54,13 @@ public enum RepositoryType {
       RepositoryType.PATCH);
 
   /**
+   * The types of repositories which can participate in an upgrade where only
+   * some services are orchestrated.
+   */
+  public static final EnumSet<RepositoryType> PARTIAL = 
EnumSet.of(RepositoryType.MAINT,
+      RepositoryType.PATCH, RepositoryType.SERVICE);
+
+  /**
    * Gets whether applications of this repository are revertable after they 
have
    * been finalized.
    *
@@ -72,4 +79,15 @@ public enum RepositoryType {
         return false;
     }
   }
+
+  /**
+   * Gets whether this repository type can be used to upgrade only a subset of
+   * services.
+   *
+   * @return {@code true} if the repository can be be applied to a subset of
+   *         isntalled services, {@code false} otherwise.
+   */
+  public boolean isPartial() {
+    return PARTIAL.contains(this);
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/state/repository/StackPackage.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/StackPackage.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/StackPackage.java
new file mode 100644
index 0000000..39670da
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/StackPackage.java
@@ -0,0 +1,69 @@
+/**
+ * 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.state.repository;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.reflect.TypeToken;
+
+/**
+ * Represents the data inside of the {@code stack_packages.json}.
+ */
+public class StackPackage {
+
+  /**
+   * The upgrade dependencies, if any. Will be {@code null} if none.
+   */
+  @SerializedName("upgrade-dependencies")
+  public UpgradeDependencies upgradeDependencies;
+
+  /**
+   * The upgrade dependencies between services.
+   */
+  public static class UpgradeDependencies {
+    Map<String, List<String>> dependencies;
+  }
+
+  /**
+   * A deserializer which extracts the "upgrade-dependencies" key from the
+   * stack_packages.json.
+   */
+  public static class UpgradeDependencyDeserializer
+      implements JsonDeserializer<UpgradeDependencies> {
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public UpgradeDependencies deserialize(JsonElement json, Type typeOfT,
+        JsonDeserializationContext context) throws JsonParseException {
+      Type mapType = new TypeToken<Map<String, List<String>>>() {}.getType();
+      Map<String, List<String>> data = context.deserialize(json, mapType);
+
+      UpgradeDependencies upgradeDependencies = new UpgradeDependencies();
+      upgradeDependencies.dependencies = data;
+      return upgradeDependencies;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
index ec4814b..1dda0b1 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.state.repository;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.lang.reflect.Type;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -29,6 +30,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.TreeSet;
 
 import javax.xml.XMLConstants;
@@ -50,18 +52,28 @@ import javax.xml.validation.SchemaFactory;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.repository.AvailableVersion.Component;
+import 
org.apache.ambari.server.state.repository.StackPackage.UpgradeDependencies;
+import 
org.apache.ambari.server.state.repository.StackPackage.UpgradeDependencyDeserializer;
 import org.apache.ambari.server.state.stack.RepositoryXml;
 import org.apache.ambari.server.state.stack.RepositoryXml.Os;
 import org.apache.ambari.server.utils.VersionUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 
+import com.google.common.collect.Sets;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import jline.internal.Log;
+
 /**
  * Class that wraps a repository definition file.
  */
@@ -310,6 +322,81 @@ public class VersionDefinitionXml {
   }
 
   /**
+   * Gets information about services which cannot be upgraded because the
+   * repository does not contain required dependencies. This method will look 
at
+   * the {@code cluster-env/stack_packages} structure to see if there are any
+   * dependencies listed in the {@code upgrade-dependencies} key.
+   *
+   * @param cluster
+   *          the cluster (not {@code null}).
+   * @return a mapping of service name to its missing service dependencies, or
+   *         an empty map if there are none (never {@code null}).
+   * @throws AmbariException
+   */
+  public Map<String, Set<String>> getMissingDependencies(Cluster cluster)
+      throws AmbariException {
+    Map<String, Set<String>> missingDependencies = new TreeMap<>();
+
+    String stackPackagesJson = cluster.getClusterProperty(
+        ConfigHelper.CLUSTER_ENV_STACK_PACKAGES_PROPERTY, null);
+
+    // quick exit
+    if (StringUtils.isEmpty(stackPackagesJson)) {
+      return missingDependencies;
+    }
+
+    // create a GSON builder which can deserialize the stack_packages.json
+    GsonBuilder gsonBuilder = new GsonBuilder();
+    gsonBuilder.registerTypeAdapter(UpgradeDependencies.class, new 
UpgradeDependencyDeserializer());
+    Gson gson = gsonBuilder.create();
+    Type type = new TypeToken<Map<String, StackPackage>>(){}.getType();
+
+    // a mapping of stack name to stack-select/conf-select/upgade-deps
+    final Map<String, StackPackage> stackPackages;
+
+    try {
+      stackPackages = gson.fromJson(stackPackagesJson, type);
+    } catch( Exception exception ) {
+      Log.warn("Unable to deserialize the stack packages JSON, assuming no 
service dependencies",
+          exception);
+
+      return missingDependencies;
+    }
+
+    StackId stackId = new StackId(release.stackId);
+    StackPackage stackPackage = stackPackages.get(stackId.getStackName());
+    if (null == stackPackage || null == stackPackage.upgradeDependencies) {
+      return missingDependencies;
+    }
+
+    Map<String, List<String>> dependencies = 
stackPackage.upgradeDependencies.dependencies;
+
+    if (null == dependencies || dependencies.isEmpty()) {
+      return missingDependencies;
+    }
+
+    ClusterVersionSummary clusterVersionSummary = getClusterSummary(cluster);
+    Set<String> servicesInUpgrade = 
clusterVersionSummary.getAvailableServiceNames();
+    Set<String> servicesInRepository = getAvailableServiceNames();
+
+    for (String serviceInUpgrade : servicesInUpgrade) {
+      List<String> servicesRequired = dependencies.get(serviceInUpgrade);
+      if (null == servicesRequired) {
+        continue;
+      }
+
+      for (String serviceRequired : servicesRequired) {
+        if (!servicesInRepository.contains(serviceRequired)) {
+          missingDependencies.put(serviceInUpgrade, 
Sets.newTreeSet(servicesRequired));
+          break;
+        }
+      }
+    }
+
+    return missingDependencies;
+  }
+
+  /**
    * Structures the manifest by service name.
    * <p/>
    * !!! WARNING. This is currently based on the assumption that there is one 
and only

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json
 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json
index 8f685f6..c217ea8 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json
@@ -1174,6 +1174,10 @@
           "current_dir": "{0}/current/zookeeper-client/conf"
         }
       ]
-    }
+    },
+    "upgrade-dependencies" : {
+      "YARN": ["TEZ"],
+      "TEZ": ["YARN"]
+    }    
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java
index 092bd0b..9915346 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/AbstractCheckDescriptorTest.java
@@ -30,6 +30,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -120,6 +121,7 @@ public class AbstractCheckDescriptorTest extends 
EasyMockSupport {
     expect(cluster.getServices()).andReturn(services).atLeastOnce();
 
     RepositoryVersionEntity repositoryVersion = 
createNiceMock(RepositoryVersionEntity.class);
+    
expect(repositoryVersion.getType()).andReturn(RepositoryType.STANDARD).anyTimes();
     
expect(repositoryVersion.getRepositoryXml()).andReturn(m_vdfXml).atLeastOnce();
     
expect(m_vdfXml.getClusterSummary(EasyMock.anyObject(Cluster.class))).andReturn(
         m_clusterVersionSummary).atLeastOnce();
@@ -170,6 +172,7 @@ public class AbstractCheckDescriptorTest extends 
EasyMockSupport {
     expect(cluster.getServices()).andReturn(services).atLeastOnce();
 
     RepositoryVersionEntity repositoryVersion = 
createNiceMock(RepositoryVersionEntity.class);
+    
expect(repositoryVersion.getType()).andReturn(RepositoryType.STANDARD).anyTimes();
     
expect(repositoryVersion.getRepositoryXml()).andReturn(m_vdfXml).atLeastOnce();
     
expect(m_vdfXml.getClusterSummary(EasyMock.anyObject(Cluster.class))).andReturn(
         m_clusterVersionSummary).atLeastOnce();

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/AutoStartDisabledCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/AutoStartDisabledCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/AutoStartDisabledCheckTest.java
index 4a84483..b3d5b32 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/AutoStartDisabledCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/AutoStartDisabledCheckTest.java
@@ -25,10 +25,12 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.commons.lang.StringUtils;
@@ -48,6 +50,8 @@ public class AutoStartDisabledCheckTest {
   private final Clusters m_clusters = EasyMock.createMock(Clusters.class);
   private Map<String, String> m_configMap = new HashMap<>();
 
+  RepositoryVersionEntity repositoryVersionEntity;
+
   @Before
   public void before() throws Exception {
 
@@ -73,7 +77,10 @@ public class AutoStartDisabledCheckTest {
 
     expect(m_clusters.getCluster((String) 
anyObject())).andReturn(cluster).anyTimes();
 
-    replay(m_clusters, cluster, config);
+    repositoryVersionEntity = 
EasyMock.createNiceMock(RepositoryVersionEntity.class);
+    
expect(repositoryVersionEntity.getType()).andReturn(RepositoryType.STANDARD).anyTimes();
+
+    replay(m_clusters, cluster, config, repositoryVersionEntity);
 
     m_configMap.clear();
   }
@@ -82,6 +89,7 @@ public class AutoStartDisabledCheckTest {
   public void testNoAutoStart() throws Exception {
     PrerequisiteCheck check = new 
PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo");
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(repositoryVersionEntity);
 
     Assert.assertTrue(m_check.isApplicable(request));
 
@@ -95,6 +103,7 @@ public class AutoStartDisabledCheckTest {
   public void testAutoStartFalse() throws Exception {
     PrerequisiteCheck check = new 
PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo");
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(repositoryVersionEntity);
 
     Assert.assertTrue(m_check.isApplicable(request));
 
@@ -110,6 +119,7 @@ public class AutoStartDisabledCheckTest {
   public void testAutoStartTrue() throws Exception {
     PrerequisiteCheck check = new 
PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo");
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(repositoryVersionEntity);
 
     Assert.assertTrue(m_check.isApplicable(request));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ClientRetryPropertyCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ClientRetryPropertyCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ClientRetryPropertyCheckTest.java
index ecc3165..52ec530 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ClientRetryPropertyCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ClientRetryPropertyCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -78,6 +79,7 @@ public class ClientRetryPropertyCheckTest {
     Configuration config = Mockito.mock(Configuration.class);
     m_check.config = config;
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.3.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.3"));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentExistsInRepoCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentExistsInRepoCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentExistsInRepoCheckTest.java
index ede1daa..2fe8ee0 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentExistsInRepoCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentExistsInRepoCheckTest.java
@@ -30,6 +30,7 @@ import 
org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 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.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceInfo;
@@ -147,6 +148,7 @@ public class ComponentExistsInRepoCheckTest extends 
EasyMockSupport {
         TARGET_STACK.getStackVersion(), "ZOOKEEPER", 
"ZOOKEEPER_SERVER")).andReturn(
             m_zookeeperServerInfo).anyTimes();
 
+    
expect(m_repositoryVersion.getType()).andReturn(RepositoryType.STANDARD).anyTimes();
     
expect(m_repositoryVersion.getStackId()).andReturn(TARGET_STACK).anyTimes();
     expect(m_repositoryVersion.getVersion()).andReturn("2.2.0").anyTimes();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentsInstallationCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentsInstallationCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentsInstallationCheckTest.java
index 4ae33f8..0e57966 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentsInstallationCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ComponentsInstallationCheckTest.java
@@ -33,6 +33,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.StackId;
@@ -86,6 +87,8 @@ public class ComponentsInstallationCheckTest {
     MockitoAnnotations.initMocks(this);
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.2"));
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ConfigurationMergeCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ConfigurationMergeCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ConfigurationMergeCheckTest.java
index fd450b9..e017a02 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ConfigurationMergeCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ConfigurationMergeCheckTest.java
@@ -37,6 +37,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigMergeHelper;
 import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
@@ -82,6 +83,7 @@ public class ConfigurationMergeCheckTest {
 
     
expect(cluster.getDesiredConfigByType(CONFIG_TYPE)).andReturn(config).anyTimes();
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("1.1.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "1.1"));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/DruidHighAvailabilityCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/DruidHighAvailabilityCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/DruidHighAvailabilityCheckTest.java
index dfb18ed..efc6a80 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/DruidHighAvailabilityCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/DruidHighAvailabilityCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
@@ -87,6 +88,7 @@ public class DruidHighAvailabilityCheckTest
     druidHighAvailabilityCheck.config = config;
 
     m_services.clear();
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveMultipleMetastoreCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveMultipleMetastoreCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveMultipleMetastoreCheckTest.java
index 3dfe2f8..6bba2ea 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveMultipleMetastoreCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveMultipleMetastoreCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
@@ -85,6 +86,8 @@ public class HiveMultipleMetastoreCheckTest {
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "1.0"));
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveNotRollingWarningTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveNotRollingWarningTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveNotRollingWarningTest.java
index 3b0c900..bed1b43 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveNotRollingWarningTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HiveNotRollingWarningTest.java
@@ -24,6 +24,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -66,6 +67,8 @@ public class HiveNotRollingWarningTest extends 
EasyMockSupport {
   @Before
   public void setup() throws Exception {
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
index daf2e4c..cf42ab7 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
@@ -29,6 +29,7 @@ import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostHealthStatus;
 import org.apache.ambari.server.state.HostHealthStatus.HealthStatus;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
@@ -53,6 +54,7 @@ public class HostsHeartbeatCheckTest {
    */
   @Before
   public void setup() throws Exception {
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.2"));
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
index 8fcb1b2..c7cb13f 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -71,6 +72,8 @@ public class HostsMasterMaintenanceCheckTest {
   @Before
   public void setup() throws Exception {
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());
@@ -170,4 +173,4 @@ public class HostsMasterMaintenanceCheckTest {
     hostsMasterMaintenanceCheck.perform(check, checkRequest);
     Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
index 5539618..2d60a52 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
@@ -31,6 +31,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
@@ -73,6 +74,7 @@ public class HostsRepositoryVersionCheckTest {
   public void setup() throws Exception {
     m_services.clear();
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("1.0.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "1.0"));
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
index cdfbb0a..b02d834 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
@@ -34,6 +34,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
@@ -73,6 +74,7 @@ public class InstallPackagesCheckTest {
    */
   @Before
   public void setup() throws Exception {
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     
Mockito.when(m_repositoryVersion.getVersion()).thenReturn(repositoryVersion);
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(targetStackId);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/KafkaKerberosCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/KafkaKerberosCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/KafkaKerberosCheckTest.java
index 9a95c42..b4ee6ec 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/KafkaKerberosCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/KafkaKerberosCheckTest.java
@@ -24,6 +24,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -68,6 +69,7 @@ public class KafkaKerberosCheckTest {
     };
 
     m_services.clear();
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
index 096781c..f8ea169 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
@@ -97,6 +97,8 @@ public class MapReduce2JobHistoryStatePreservingCheckTest {
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.3"));
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
index ec91e48..4a7e8d3 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -72,6 +73,8 @@ public class RangerAuditDbCheckTest {
     rangerAuditDbCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerPasswordCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerPasswordCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerPasswordCheckTest.java
index cfffb8f..d24c73c 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerPasswordCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerPasswordCheckTest.java
@@ -39,6 +39,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -149,6 +150,8 @@ public class RangerPasswordCheckTest {
     
PowerMockito.whenNew(URLStreamProvider.class).withAnyArguments().thenReturn(m_streamProvider);
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerSSLConfigCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerSSLConfigCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerSSLConfigCheckTest.java
index af016b0..50ec21c 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerSSLConfigCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerSSLConfigCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -73,6 +74,8 @@ public class RangerSSLConfigCheckTest {
     rangerSSLConfigCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheckTest.java
new file mode 100644
index 0000000..0285c0a
--- /dev/null
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/RequiredServicesInRepositoryCheckTest.java
@@ -0,0 +1,116 @@
+/**
+ * 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.checks;
+
+import static org.mockito.Mockito.mock;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.repository.VersionDefinitionXml;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.inject.Provider;
+
+/**
+ * Tests {@link RequiredServicesInRepositoryCheck}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class RequiredServicesInRepositoryCheckTest {
+
+  private static final String CLUSTER_NAME = "c1";
+
+  @Mock
+  private VersionDefinitionXml m_vdfXml;
+
+  @Mock
+  private RepositoryVersionEntity m_repositoryVersion;
+
+  private RequiredServicesInRepositoryCheck m_requiredServicesCheck;
+
+  /**
+   * Used to return the missing dependencies for the test.
+   */
+  private Map<String, Set<String>> m_missingDependencies = new HashMap<>();
+
+  @Before
+  public void setUp() throws Exception {
+    final Clusters clusters = mock(Clusters.class);
+    m_requiredServicesCheck = new RequiredServicesInRepositoryCheck();
+    m_requiredServicesCheck.clustersProvider = new Provider<Clusters>() {
+      @Override
+      public Clusters get() {
+        return clusters;
+      }
+    };
+
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(clusters.getCluster(CLUSTER_NAME)).thenReturn(cluster);
+
+    Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
+    
Mockito.when(m_vdfXml.getMissingDependencies(Mockito.eq(cluster))).thenReturn(m_missingDependencies);
+  }
+
+  /**
+   * Tests that a no missing services results in a passed test.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testNoMissingServices() throws Exception {
+    PrereqCheckRequest request = new PrereqCheckRequest(CLUSTER_NAME);
+    request.setTargetRepositoryVersion(m_repositoryVersion);
+
+    PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME);
+    m_requiredServicesCheck.perform(check, request);
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+  }
+
+  /**
+   * Tests that a missing required service causes the test to fail.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testMissingRequiredService() throws Exception {
+    PrereqCheckRequest request = new PrereqCheckRequest(CLUSTER_NAME);
+    request.setTargetRepositoryVersion(m_repositoryVersion);
+
+    m_missingDependencies.put("FOO", Sets.newHashSet("BAR"));
+
+    PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME);
+    m_requiredServicesCheck.perform(check, request);
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
index 67c458a..c038c47 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -87,6 +88,8 @@ public class SecondaryNamenodeDeletedCheckTest {
     secondaryNamenodeDeletedCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
index 6577651..694a9b6 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
@@ -70,6 +71,7 @@ public class ServicesMaintenanceModeCheckTest {
   public void setup() throws Exception {
     m_services.clear();
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.2"));
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
index a8569cc..b32a782 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -77,6 +78,8 @@ public class ServicesMapReduceDistributedCacheCheckTest {
     servicesMapReduceDistributedCacheCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
index c7e8fd6..8c51add 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -77,6 +78,8 @@ public class ServicesNamenodeHighAvailabilityCheckTest {
     servicesNamenodeHighAvailabilityCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeTruncateCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeTruncateCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeTruncateCheckTest.java
index 545caf3..356d2cd 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeTruncateCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeTruncateCheckTest.java
@@ -31,6 +31,7 @@ import 
org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -99,6 +100,7 @@ public class ServicesNamenodeTruncateCheckTest {
       }
     };
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("HDP-2.2.0.0");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.2.0"));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
index 96eefc1..0123f18 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -77,6 +78,8 @@ public class ServicesTezDistributedCacheCheckTest {
     servicesTezDistributedCacheCheck.config = config;
 
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
index a851919..4d00644 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
@@ -33,6 +33,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.StackId;
@@ -87,6 +88,7 @@ public class ServicesUpCheckTest {
 
     m_services.clear();
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.0.0-1234");
     Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new 
StackId("HDP", "2.2"));
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
index 331223d..5164a4f 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
@@ -77,6 +78,7 @@ public class ServicesYarnWorkPreservingCheckTest {
     Configuration config = Mockito.mock(Configuration.class);
     servicesYarnWorkPreservingCheck.config = config;
 
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/checks/StormShutdownWarningTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/StormShutdownWarningTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/StormShutdownWarningTest.java
index 1441256..a5e24f1 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/checks/StormShutdownWarningTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/checks/StormShutdownWarningTest.java
@@ -24,6 +24,7 @@ import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
@@ -66,6 +67,8 @@ public class StormShutdownWarningTest extends EasyMockSupport 
{
   @Before
   public void setup() throws Exception {
     m_services.clear();
+
+    
Mockito.when(m_repositoryVersion.getType()).thenReturn(RepositoryType.STANDARD);
     Mockito.when(m_repositoryVersion.getRepositoryXml()).thenReturn(m_vdfXml);
     
Mockito.when(m_vdfXml.getClusterSummary(Mockito.any(Cluster.class))).thenReturn(m_clusterVersionSummary);
     
Mockito.when(m_clusterVersionSummary.getAvailableServiceNames()).thenReturn(m_services.keySet());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c19f363c/ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java
index 0301431..14a1eaf 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java
@@ -100,6 +100,8 @@ public class CheckHelperTest {
     updateChecksRegistry.add(m_mockCheck);
 
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(m_repositoryVersion);
+
     helper.performChecks(request, updateChecksRegistry, configuration);
 
     Assert.assertEquals(PrereqCheckStatus.PASS, 
request.getResult(m_mockCheckDescription));
@@ -128,6 +130,7 @@ public class CheckHelperTest {
     updateChecksRegistry.add(m_mockCheck);
 
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+
     helper.performChecks(request, updateChecksRegistry, configuration);
 
 
@@ -151,6 +154,8 @@ public class CheckHelperTest {
     Mockito.when(m_mockPerform.toString()).thenThrow(new RuntimeException());
 
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(m_repositoryVersion);
+
     helper.performChecks(request, updateChecksRegistry, configuration);
 
     Assert.assertEquals(PrereqCheckStatus.FAIL, 
request.getResult(m_mockCheckDescription));
@@ -173,6 +178,8 @@ public class CheckHelperTest {
     Mockito.when(m_mockPerform.toString()).thenThrow(new RuntimeException());
 
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+    request.setTargetRepositoryVersion(m_repositoryVersion);
+
     helper.performChecks(request, updateChecksRegistry, configuration);
 
     Assert.assertEquals(PrereqCheckStatus.BYPASS, 
request.getResult(m_mockCheckDescription));

Reply via email to