ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [24/50] [abbrv] ambari git commit: AMBARI-21047 - Iterative Fixes For Patch/Service Upgrade Development (jonathanhurley)
Date Wed, 31 May 2017 20:12:55 GMT
AMBARI-21047 - Iterative Fixes For Patch/Service Upgrade Development (jonathanhurley)


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

Branch: refs/heads/trunk
Commit: c4132783225b541f0425526f7d1edaa822553229
Parents: 1427d81
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Wed May 17 13:46:08 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Thu May 18 09:45:03 2017 -0400

----------------------------------------------------------------------
 .../libraries/functions/decorator.py            |  22 +-
 .../upgrades/upgrade_nonrolling_new_stack.xml   |   2 +-
 .../actionmanager/ExecutionCommandWrapper.java  |  46 +++--
 .../AmbariManagementControllerImpl.java         |   2 +-
 .../ClusterStackVersionResourceProvider.java    |   6 +-
 .../internal/UpgradeResourceProvider.java       | 141 +++++++------
 .../upgrades/AbstractUpgradeServerAction.java   |   4 -
 .../upgrades/FinalizeUpgradeAction.java         |   3 +-
 .../upgrades/UpdateDesiredStackAction.java      |  19 --
 .../org/apache/ambari/server/state/Cluster.java |   7 -
 .../ambari/server/state/UpgradeContext.java     | 206 +++++++++----------
 .../server/state/cluster/ClusterImpl.java       |  15 --
 .../custom_actions/scripts/ru_set_all.py        |  49 +----
 .../AmbariManagementControllerImplTest.java     |   2 +-
 .../ComponentVersionCheckActionTest.java        |   6 -
 .../upgrades/UpgradeActionTest.java             |  22 +-
 .../stack/upgrade/StageWrapperBuilderTest.java  |   2 +-
 .../server/upgrade/UpgradeCatalog200Test.java   |   2 +-
 .../server/upgrade/UpgradeCatalog210Test.java   |   7 +
 .../server/upgrade/UpgradeCatalogHelper.java    |   5 +-
 .../python/custom_actions/test_ru_set_all.py    | 124 +----------
 .../src/test/python/stacks/utils/RMFTestCase.py |  12 +-
 .../upgrades/upgrade_nonrolling_new_stack.xml   |   2 +-
 23 files changed, 248 insertions(+), 458 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-common/src/main/python/resource_management/libraries/functions/decorator.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/decorator.py b/ambari-common/src/main/python/resource_management/libraries/functions/decorator.py
index b5b804d..9446d56 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/decorator.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/decorator.py
@@ -21,7 +21,7 @@ Ambari Agent
 """
 
 import time
-__all__ = ['retry', 'safe_retry', ]
+__all__ = ['retry', 'safe_retry', 'experimental' ]
 
 from resource_management.core.logger import Logger
 
@@ -107,3 +107,23 @@ def safe_retry(times=3, sleep_time=1, max_sleep_time=8, backoff_factor=1, err_cl
 
     return wrapper
   return decorator
+
+
+def experimental(feature=None, comment=None, disable=False):
+  """
+  Annotates a function as being experiemental, optionally logging a comment.
+  :param feature:  the feature area that is experimental
+  :param comment:  the comment to log
+  :param disable  True to skip invocation of the method entirely, defaults to False.
+  :return: 
+  """
+  def decorator(function):
+    def wrapper(*args, **kwargs):
+      if comment:
+        Logger.info(comment)
+
+      if not disable:
+        return function(*args, **kwargs)
+    return wrapper
+  return decorator
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
----------------------------------------------------------------------
diff --git a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
index ad6174c..d0f3e16 100644
--- a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
+++ b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
@@ -231,7 +231,7 @@
       <execute-stage title="Restore configuration directories and remove HDP 2.3 symlinks">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>
-          <function>unlink_all_configs</function>
+          <function>foo_function</function>
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
index f680c09..2ec09d9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
@@ -23,6 +23,7 @@ import java.util.TreeMap;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ClusterNotFoundException;
+import org.apache.ambari.server.ServiceNotFoundException;
 import org.apache.ambari.server.agent.AgentCommand.AgentCommandType;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
@@ -184,30 +185,39 @@ public class ExecutionCommandWrapper {
 
         // set the repository version for the component this command is for -
         // always use the current desired version
-        RepositoryVersionEntity repositoryVersion = null;
-        String serviceName = executionCommand.getServiceName();
-        if (!StringUtils.isEmpty(serviceName)) {
-          Service service = cluster.getService(serviceName);
-          if (null != service) {
-            repositoryVersion = service.getDesiredRepositoryVersion();
-          }
+        try {
+          RepositoryVersionEntity repositoryVersion = null;
+          String serviceName = executionCommand.getServiceName();
+          if (!StringUtils.isEmpty(serviceName)) {
+            Service service = cluster.getService(serviceName);
+            if (null != service) {
+              repositoryVersion = service.getDesiredRepositoryVersion();
+            }
 
-          String componentName = executionCommand.getComponentName();
-          if (!StringUtils.isEmpty(componentName)) {
-            ServiceComponent serviceComponent = service.getServiceComponent(
-                executionCommand.getComponentName());
+            String componentName = executionCommand.getComponentName();
+            if (!StringUtils.isEmpty(componentName)) {
+              ServiceComponent serviceComponent = service.getServiceComponent(
+                  executionCommand.getComponentName());
 
-            if (null != serviceComponent) {
-              repositoryVersion = serviceComponent.getDesiredRepositoryVersion();
+              if (null != serviceComponent) {
+                repositoryVersion = serviceComponent.getDesiredRepositoryVersion();
+              }
             }
           }
-        }
 
-        if (null != repositoryVersion) {
-          executionCommand.getCommandParams().put(KeyNames.VERSION, repositoryVersion.getVersion());
-          executionCommand.getHostLevelParams().put(KeyNames.CURRENT_VERSION, repositoryVersion.getVersion());
+          if (null != repositoryVersion) {
+            executionCommand.getCommandParams().put(KeyNames.VERSION,
+                repositoryVersion.getVersion());
+            executionCommand.getHostLevelParams().put(KeyNames.CURRENT_VERSION,
+                repositoryVersion.getVersion());
+          }
+        } catch (ServiceNotFoundException serviceNotFoundException) {
+          // it's possible that there are commands specified for a service where
+          // the service doesn't exist yet
+          LOG.warn(
+              "The service {} is not installed in the cluster. No repository version will be sent for this command.",
+              executionCommand.getServiceName());
         }
-
       }
     } catch (ClusterNotFoundException cnfe) {
       // it's possible that there are commands without clusters; in such cases,

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index a4f59a5..e373f81 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -3991,7 +3991,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     RepositoryVersionEntity desiredRepositoryVersion = null;
 
     RequestOperationLevel operationLevel = actionExecContext.getOperationLevel();
-    if (null != operationLevel) {
+    if (null != operationLevel && null != operationLevel.getServiceName()) {
       Service service = cluster.getService(operationLevel.getServiceName());
       if (null != service) {
         desiredRepositoryVersion = service.getDesiredRepositoryVersion();

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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 9ca8ddc..6447888 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
@@ -55,7 +55,6 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
@@ -169,9 +168,6 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
   private static Configuration configuration;
 
   @Inject
-  private static HostComponentStateDAO hostComponentStateDAO;
-
-  @Inject
   private static RepositoryVersionHelper repoVersionHelper;
 
 
@@ -222,7 +218,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
       requestedEntities.add(id);
     } else {
       cluster.getCurrentStackVersion();
-      List<RepositoryVersionEntity> entities = repositoryVersionDAO.findByStack(cluster.getCurrentStackVersion());
+      List<RepositoryVersionEntity> entities = repositoryVersionDAO.findAll();
 
       for (RepositoryVersionEntity entity : entities) {
         requestedEntities.add(entity.getId());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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 c3691bf..6027ce7 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
@@ -80,7 +80,6 @@ import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
 import org.apache.ambari.server.security.authorization.ResourceType;
 import org.apache.ambari.server.security.authorization.RoleAuthorization;
-import org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
@@ -105,6 +104,7 @@ import org.apache.ambari.server.state.stack.upgrade.ServerSideActionTask;
 import org.apache.ambari.server.state.stack.upgrade.StageWrapper;
 import org.apache.ambari.server.state.stack.upgrade.Task;
 import org.apache.ambari.server.state.stack.upgrade.TaskWrapper;
+import org.apache.ambari.server.state.stack.upgrade.UpdateStackGrouping;
 import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostServerActionEvent;
 import org.apache.commons.collections.CollectionUtils;
@@ -144,17 +144,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   public static final String UPGRADE_FAIL_ON_CHECK_WARNINGS = "Upgrade/fail_on_check_warnings";
 
   /**
-   * Names that appear in the Upgrade Packs that are used by
-   * {@link org.apache.ambari.server.state.cluster.ClusterImpl#isNonRollingUpgradePastUpgradingStack}
-   * to determine if an upgrade has already changed the version to use.
-   * For this reason, DO NOT CHANGE the name of these since they represent historic values.
-   */
-  public static final String CONST_UPGRADE_GROUP_NAME = "UPDATE_DESIRED_STACK_ID";
-  public static final String CONST_UPGRADE_ITEM_TEXT = "Update Target Stack";
-  public static final String CONST_CUSTOM_COMMAND_NAME = UpdateDesiredStackAction.class.getName();
-
-
-  /**
    * Skip slave/client component failures if the tasks are skippable.
    */
   public static final String UPGRADE_SKIP_FAILURES = "Upgrade/skip_failures";
@@ -208,11 +197,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
   private static final Set<String> PROPERTY_IDS = new HashSet<>();
 
-  /**
-   * 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";
 
   private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<>();
@@ -661,23 +645,38 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     // Non Rolling Upgrades require a group with name "UPDATE_DESIRED_STACK_ID".
     // This is needed as a marker to indicate which version to use when an upgrade is paused.
     if (pack.getType() == UpgradeType.NON_ROLLING) {
-      boolean foundGroupWithNameUPDATE_DESIRED_STACK_ID = false;
+      boolean foundUpdateDesiredRepositoryIdGrouping = false;
       for (UpgradeGroupHolder group : groups) {
-        if (group.name.equalsIgnoreCase(CONST_UPGRADE_GROUP_NAME)) {
-          foundGroupWithNameUPDATE_DESIRED_STACK_ID = true;
+        if (group.groupClass == UpdateStackGrouping.class) {
+          foundUpdateDesiredRepositoryIdGrouping = true;
           break;
         }
       }
 
-      if (foundGroupWithNameUPDATE_DESIRED_STACK_ID == false) {
-        throw new AmbariException(String.format("NonRolling Upgrade Pack %s requires a Group with name %s",
-            pack.getName(), CONST_UPGRADE_GROUP_NAME));
+      if (!foundUpdateDesiredRepositoryIdGrouping) {
+        throw new AmbariException(String.format(
+            "Express upgrade packs are required to have a group of type %s. The upgrade pack %s is missing this grouping.",
+            "update-stack", pack.getName()));
       }
     }
 
     List<UpgradeGroupEntity> groupEntities = new ArrayList<>();
     RequestStageContainer req = createRequest(upgradeContext);
 
+    UpgradeEntity upgrade = new UpgradeEntity();
+    upgrade.setRepositoryVersion(upgradeContext.getRepositoryVersion());
+    upgrade.setClusterId(cluster.getClusterId());
+    upgrade.setDirection(direction);
+    upgrade.setUpgradePackage(pack.getName());
+    upgrade.setUpgradeType(pack.getType());
+    upgrade.setAutoSkipComponentFailures(upgradeContext.isComponentFailureAutoSkipped());
+    upgrade.setAutoSkipServiceCheckFailures(upgradeContext.isServiceCheckFailureAutoSkipped());
+    upgrade.setDowngradeAllowed(upgradeContext.isDowngradeAllowed());
+
+    // create to/from history for this upgrade - this should be done before any
+    // possible changes to the desired version for components
+    addComponentHistoryToUpgrade(cluster, upgrade, upgradeContext);
+
     /**
     During a Rolling Upgrade, change the desired Stack Id if jumping across
     major stack versions (e.g., HDP 2.2 -> 2.3), and then set config changes
@@ -761,56 +760,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       }
     }
 
-    UpgradeEntity entity = new UpgradeEntity();
-    entity.setRepositoryVersion(upgradeContext.getRepositoryVersion());
-    entity.setUpgradeGroups(groupEntities);
-    entity.setClusterId(cluster.getClusterId());
-    entity.setDirection(direction);
-    entity.setUpgradePackage(pack.getName());
-    entity.setUpgradeType(pack.getType());
-    entity.setAutoSkipComponentFailures(upgradeContext.isComponentFailureAutoSkipped());
-    entity.setAutoSkipServiceCheckFailures(upgradeContext.isServiceCheckFailureAutoSkipped());
-
-    if (upgradeContext.getDirection().isDowngrade()) {
-      // !!! You can't downgrade a Downgrade, no matter what the upgrade pack says.
-      entity.setDowngradeAllowed(false);
-    } else {
-      entity.setDowngradeAllowed(pack.isDowngradeAllowed());
-    }
-
-    // set upgrade history for every component in the upgrade
-    Set<String> services = upgradeContext.getSupportedServices();
-    for (String serviceName : services) {
-      Service service = cluster.getService(serviceName);
-      Map<String, ServiceComponent> componentMap = service.getServiceComponents();
-      for (ServiceComponent component : componentMap.values()) {
-        UpgradeHistoryEntity history = new UpgradeHistoryEntity();
-        history.setUpgrade(entity);
-        history.setServiceName(serviceName);
-        history.setComponentName(component.getName());
-
-        // depending on whether this is an upgrade or a downgrade, the history
-        // will be different
-        if (upgradeContext.getDirection() == Direction.UPGRADE) {
-          history.setFromRepositoryVersion(component.getDesiredRepositoryVersion());
-          history.setTargetRepositoryVersion(upgradeContext.getRepositoryVersion());
-        } else {
-          // the target version on a downgrade is the original version that the
-          // service was on in the failed upgrade
-          RepositoryVersionEntity targetRepositoryVersion =
-              upgradeContext.getTargetRepositoryVersion(serviceName);
-
-          history.setFromRepositoryVersion(upgradeContext.getRepositoryVersion());
-          history.setTargetRepositoryVersion(targetRepositoryVersion);
-        }
-
-        // add the history
-        entity.addHistory(history);
-      }
-    }
+    // set all of the groups we just created
+    upgrade.setUpgradeGroups(groupEntities);
 
     req.getRequestStatusResponse();
-    return createUpgradeInsideTransaction(cluster, req, entity);
+    return createUpgradeInsideTransaction(cluster, req, upgrade);
   }
 
   /**
@@ -1418,7 +1372,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
     Map<String, String> commandParams = getNewParameterMap(request, context);
     commandParams.put(UpgradeContext.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.
@@ -1646,6 +1599,50 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   /**
+   * Creates the {@link UpgradeHistoryEntity} instances for this upgrade for
+   * every component participating.
+   *
+   * @param cluster
+   *          the cluster (not {@code null}).
+   * @param upgrade
+   *          the upgrade to add the entities to (not {@code null}).
+   * @param upgradeContext
+   *          the upgrade context for this upgrade (not {@code null}).
+   */
+  private void addComponentHistoryToUpgrade(Cluster cluster, UpgradeEntity upgrade,
+      UpgradeContext upgradeContext) throws AmbariException {
+    Set<String> services = upgradeContext.getSupportedServices();
+    for (String serviceName : services) {
+      Service service = cluster.getService(serviceName);
+      Map<String, ServiceComponent> componentMap = service.getServiceComponents();
+      for (ServiceComponent component : componentMap.values()) {
+        UpgradeHistoryEntity history = new UpgradeHistoryEntity();
+        history.setUpgrade(upgrade);
+        history.setServiceName(serviceName);
+        history.setComponentName(component.getName());
+
+        // depending on whether this is an upgrade or a downgrade, the history
+        // will be different
+        if (upgradeContext.getDirection() == Direction.UPGRADE) {
+          history.setFromRepositoryVersion(component.getDesiredRepositoryVersion());
+          history.setTargetRepositoryVersion(upgradeContext.getRepositoryVersion());
+        } else {
+          // the target version on a downgrade is the original version that the
+          // service was on in the failed upgrade
+          RepositoryVersionEntity targetRepositoryVersion = upgradeContext.getTargetRepositoryVersion(
+              serviceName);
+
+          history.setFromRepositoryVersion(upgradeContext.getRepositoryVersion());
+          history.setTargetRepositoryVersion(targetRepositoryVersion);
+        }
+
+        // add the history
+        upgrade.addHistory(history);
+      }
+    }
+  }
+
+  /**
    * Builds the correct {@link ConfigUpgradePack} based on the upgrade and
    * source stack.
    * <ul>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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
index 4942f27..be69311 100644
--- 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
@@ -32,10 +32,6 @@ import com.google.inject.Inject;
  */
 public abstract class AbstractUpgradeServerAction extends AbstractServerAction {
 
-  public static final String CLUSTER_NAME_KEY = UpgradeContext.COMMAND_PARAM_CLUSTER_NAME;
-  public static final String UPGRADE_DIRECTION_KEY = UpgradeContext.COMMAND_PARAM_DIRECTION;
-  protected static final String REQUEST_ID = UpgradeContext.COMMAND_PARAM_REQUEST_ID;
-
   @Inject
   protected Clusters m_clusters;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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 c4e073c..55ec84b 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
@@ -75,7 +75,7 @@ public class FinalizeUpgradeAction extends AbstractUpgradeServerAction {
   private AmbariMetaInfo ambariMetaInfo;
 
   @Inject
-  VersionEventPublisher versionEventPublisher;
+  private VersionEventPublisher versionEventPublisher;
 
   @Override
   public CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext)
@@ -241,7 +241,6 @@ public class FinalizeUpgradeAction extends AbstractUpgradeServerAction {
       }
 
       outSB.append(message).append(System.lineSeparator());
-      outSB.append(message).append(System.lineSeparator());
 
       // iterate through all host components and make sure that they are on the
       // correct version; if they are not, then this will throw an exception

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
index 657cb07..2eec581 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
@@ -61,22 +61,6 @@ public class UpdateDesiredStackAction extends AbstractUpgradeServerAction {
    */
   private static final Logger LOG = LoggerFactory.getLogger(UpdateDesiredStackAction.class);
 
-  public static final String COMMAND_PARAM_DIRECTION = "upgrade_direction";
-  public static final String COMMAND_PARAM_UPGRADE_PACK = "upgrade_pack";
-
-  /**
-   * 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 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}.
-   */
-  public static final String COMMAND_PARAM_TARGET_STACK = "target_stack";
 
   /**
    * The Cluster that this ServerAction implementation is executing on.
@@ -118,9 +102,6 @@ public class UpdateDesiredStackAction extends AbstractUpgradeServerAction {
       LOG.warn(String.format("Did not receive role parameter %s, will save configs using anonymous username %s", ServerAction.ACTION_USER_NAME, userName));
     }
 
-    // invalidate any cached effective ID
-    cluster.invalidateUpgradeEffectiveVersion();
-
     return updateDesiredRepositoryVersion(cluster, upgradeContext, userName);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index 9098cf1..cf2844b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -675,11 +675,4 @@ public interface Cluster {
    */
   void addSuspendedUpgradeParameters(Map<String, String> commandParams,
       Map<String, String> roleParams);
-
-  /**
-   * Invalidates any cached effective cluster versions for upgrades.
-   *
-   * @see #getEffectiveClusterVersion()
-   */
-  void invalidateUpgradeEffectiveVersion();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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 db58d27..5c29fb5 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
@@ -17,7 +17,6 @@
  */
 package org.apache.ambari.server.state;
 
-import static org.apache.ambari.server.controller.internal.UpgradeResourceProvider.UPGRADE_CLUSTER_NAME;
 import static org.apache.ambari.server.controller.internal.UpgradeResourceProvider.UPGRADE_DIRECTION;
 import static org.apache.ambari.server.controller.internal.UpgradeResourceProvider.UPGRADE_FAIL_ON_CHECK_WARNINGS;
 import static org.apache.ambari.server.controller.internal.UpgradeResourceProvider.UPGRADE_HOST_ORDERED_HOSTS;
@@ -116,11 +115,6 @@ public class UpgradeContext {
   final private UpgradeType m_type;
 
   /**
-   * The request parameters from the REST API for creating this upgrade.
-   */
-  final private Map<String, Object> m_upgradeRequestMap;
-
-  /**
    * The upgrade pack for this upgrade.
    */
   private UpgradePack m_upgradePack;
@@ -247,10 +241,9 @@ public class UpgradeContext {
     m_repoVersionDAO = repoVersionDAO;
 
     m_cluster = cluster;
-    m_upgradeRequestMap = upgradeRequestMap;
 
     // determine direction
-    String directionProperty = (String) m_upgradeRequestMap.get(UPGRADE_DIRECTION);
+    String directionProperty = (String) upgradeRequestMap.get(UPGRADE_DIRECTION);
     if (StringUtils.isEmpty(directionProperty)) {
       throw new AmbariException(String.format("%s is required", UPGRADE_DIRECTION));
     }
@@ -258,10 +251,10 @@ public class UpgradeContext {
     m_direction = Direction.valueOf(directionProperty);
 
     // determine upgrade type (default is ROLLING)
-    String upgradeTypeProperty = (String) m_upgradeRequestMap.get(UPGRADE_TYPE);
+    String upgradeTypeProperty = (String) upgradeRequestMap.get(UPGRADE_TYPE);
     if (StringUtils.isNotBlank(upgradeTypeProperty)) {
       try {
-        m_type = UpgradeType.valueOf(m_upgradeRequestMap.get(UPGRADE_TYPE).toString());
+        m_type = UpgradeType.valueOf(upgradeRequestMap.get(UPGRADE_TYPE).toString());
       } catch (Exception e) {
         throw new AmbariException(String.format("Property %s has an incorrect value of %s.",
             UPGRADE_TYPE, upgradeTypeProperty));
@@ -274,7 +267,7 @@ public class UpgradeContext {
     // depending on the direction, we must either have a target repository or an upgrade we are downgrading from
     switch(m_direction){
       case UPGRADE:{
-        String repositoryVersionId = (String) m_upgradeRequestMap.get(UPGRADE_REPO_VERSION_ID);
+        String repositoryVersionId = (String) upgradeRequestMap.get(UPGRADE_REPO_VERSION_ID);
         if (null == repositoryVersionId) {
           throw new AmbariException(
               String.format("The property %s is required when the upgrade direction is %s",
@@ -340,7 +333,7 @@ public class UpgradeContext {
      * For the unit tests tests, there are multiple upgrade packs for the same
      * type, so allow picking one of them. In prod, this is empty.
      */
-    String preferredUpgradePackName = (String) m_upgradeRequestMap.get(UPGRADE_PACK);
+    String preferredUpgradePackName = (String) upgradeRequestMap.get(UPGRADE_PACK);
 
     @Experimental(feature = ExperimentalFeature.PATCH_UPGRADES, comment="This is wrong")
     String upgradePackFromVersion = cluster.getService(
@@ -352,7 +345,8 @@ public class UpgradeContext {
 
     // the validator will throw an exception if the upgrade request is not valid
     UpgradeRequestValidator upgradeRequestValidator = buildValidator(m_type);
-    upgradeRequestValidator.validate(this);
+    upgradeRequestValidator.validate(cluster, m_direction, m_type, m_upgradePack,
+        upgradeRequestMap);
 
     // optionally skip failures - this can be supplied on either the request or
     // in the upgrade pack explicitely, however the request will always override
@@ -361,21 +355,21 @@ public class UpgradeContext {
     boolean skipServiceCheckFailures = m_upgradePack.isServiceCheckFailureAutoSkipped();
 
     // only override the upgrade pack if set on the request
-    if (m_upgradeRequestMap.containsKey(UPGRADE_SKIP_FAILURES)) {
+    if (upgradeRequestMap.containsKey(UPGRADE_SKIP_FAILURES)) {
       skipComponentFailures = Boolean.parseBoolean(
-          (String) m_upgradeRequestMap.get(UPGRADE_SKIP_FAILURES));
+          (String) upgradeRequestMap.get(UPGRADE_SKIP_FAILURES));
     }
 
     // only override the upgrade pack if set on the request
-    if (m_upgradeRequestMap.containsKey(UPGRADE_SKIP_SC_FAILURES)) {
+    if (upgradeRequestMap.containsKey(UPGRADE_SKIP_SC_FAILURES)) {
       skipServiceCheckFailures = Boolean.parseBoolean(
-          (String) m_upgradeRequestMap.get(UPGRADE_SKIP_SC_FAILURES));
+          (String) upgradeRequestMap.get(UPGRADE_SKIP_SC_FAILURES));
     }
 
     boolean skipManualVerification = false;
-    if (m_upgradeRequestMap.containsKey(UPGRADE_SKIP_MANUAL_VERIFICATION)) {
+    if (upgradeRequestMap.containsKey(UPGRADE_SKIP_MANUAL_VERIFICATION)) {
       skipManualVerification = Boolean.parseBoolean(
-          (String) m_upgradeRequestMap.get(UPGRADE_SKIP_MANUAL_VERIFICATION));
+          (String) upgradeRequestMap.get(UPGRADE_SKIP_MANUAL_VERIFICATION));
     }
 
     m_autoSkipComponentFailures = skipComponentFailures;
@@ -423,22 +417,6 @@ public class UpgradeContext {
     m_upgradePack = packs.get(upgradePackage);
 
     m_resolver = new MasterHostResolver(configHelper, this);
-
-    // since this constructor is initialized from an entity, then this map is
-    // not present
-    m_upgradeRequestMap = Collections.emptyMap();
-  }
-
-
-  /**
-   * Gets the original mapping of key/value pairs from the request which created
-   * the upgrade.
-   *
-   * @return the original mapping of key/value pairs from the request which
-   *         created the upgrade.
-   */
-  public Map<String, Object> getUpgradeRequest() {
-    return m_upgradeRequestMap;
   }
 
   /**
@@ -752,6 +730,22 @@ public class UpgradeContext {
   }
 
   /**
+   * Gets whether a downgrade is allowed for this upgrade. If the direction is
+   * {@link Direction#DOWNGRADE}, then this method always returns false.
+   * Otherwise it will consule {@link UpgradePack#isDowngradeAllowed()}.
+   *
+   * @return {@code true} of a downgrade is allowed for this upgrade,
+   *         {@code false} otherwise.
+   */
+  public boolean isDowngradeAllowed() {
+    if (m_direction == Direction.DOWNGRADE) {
+      return false;
+    }
+
+    return m_upgradePack.isDowngradeAllowed();
+  }
+
+  /**
    * Builds a chain of {@link UpgradeRequestValidator}s to ensure that the
    * incoming request to create a new upgrade is valid.
    *
@@ -805,19 +799,22 @@ public class UpgradeContext {
     /**
      * Validates the upgrade request from this point in the chain.
      *
-     * @param upgradeContext
+     * @param cluster
+     * @param direction
+     * @param type
      * @param upgradePack
+     * @param requestMap
      * @throws AmbariException
      */
-    final void validate(UpgradeContext upgradeContext)
-        throws AmbariException {
+    final void validate(Cluster cluster, Direction direction, UpgradeType type,
+        UpgradePack upgradePack, Map<String, Object> requestMap) throws AmbariException {
 
       // run this instance's check
-      check(upgradeContext, upgradeContext.getUpgradePack());
+      check(cluster, direction, type, upgradePack, requestMap);
 
       // pass along to the next
       if( null != m_nextValidator ) {
-        m_nextValidator.validate(upgradeContext);
+        m_nextValidator.validate(cluster, direction, type, upgradePack, requestMap);
       }
     }
 
@@ -825,13 +822,15 @@ public class UpgradeContext {
      * Checks to ensure that upgrade request is valid given the specific
      * arguments.
      *
-     * @param upgradeContext
+     * @param cluster
+     * @param direction
+     * @param type
      * @param upgradePack
-     *
+     * @param requestMap
      * @throws AmbariException
      */
-    abstract void check(UpgradeContext upgradeContext, UpgradePack upgradePack)
-        throws AmbariException;
+    abstract void check(Cluster cluster, Direction direction, UpgradeType type,
+        UpgradePack upgradePack, Map<String, Object> requestMap) throws AmbariException;
   }
 
   /**
@@ -844,22 +843,10 @@ public class UpgradeContext {
      * {@inheritDoc}
      */
     @Override
-    public void check(UpgradeContext upgradeContext, UpgradePack upgradePack)
-        throws AmbariException {
-      Map<String, Object> requestMap = upgradeContext.getUpgradeRequest();
-
-      String clusterName = (String) requestMap.get(UPGRADE_CLUSTER_NAME);
-      String direction = (String) requestMap.get(UPGRADE_DIRECTION);
-
-      if (StringUtils.isBlank(clusterName)) {
-        throw new AmbariException(String.format("%s is required", UPGRADE_CLUSTER_NAME));
-      }
-
-      if (StringUtils.isBlank(direction)) {
-        throw new AmbariException(String.format("%s is required", UPGRADE_DIRECTION));
-      }
+    public void check(Cluster cluster, Direction direction, UpgradeType type,
+        UpgradePack upgradePack, Map<String, Object> requestMap) throws AmbariException {
 
-      if (Direction.valueOf(direction) == Direction.UPGRADE) {
+      if (direction == Direction.UPGRADE) {
         String repositoryVersionId = (String) requestMap.get(UPGRADE_REPO_VERSION_ID);
         if (StringUtils.isBlank(repositoryVersionId)) {
           throw new AmbariException(
@@ -878,11 +865,8 @@ public class UpgradeContext {
      * {@inheritDoc}
      */
     @Override
-    void check(UpgradeContext upgradeContext, UpgradePack upgradePack) throws AmbariException {
-      Cluster cluster = upgradeContext.getCluster();
-      Direction direction = upgradeContext.getDirection();
-      Map<String, Object> requestMap = upgradeContext.getUpgradeRequest();
-      UpgradeType upgradeType = upgradeContext.getType();
+    void check(Cluster cluster, Direction direction, UpgradeType type, UpgradePack upgradePack,
+        Map<String, Object> requestMap) throws AmbariException {
 
       String repositoryVersionId = (String) requestMap.get(UPGRADE_REPO_VERSION_ID);
       boolean skipPrereqChecks = Boolean.parseBoolean((String) requestMap.get(UPGRADE_SKIP_PREREQUISITE_CHECKS));
@@ -913,7 +897,7 @@ public class UpgradeContext {
       Predicate preUpgradeCheckPredicate = new PredicateBuilder().property(
           PreUpgradeCheckResourceProvider.UPGRADE_CHECK_CLUSTER_NAME_PROPERTY_ID).equals(cluster.getClusterName()).and().property(
           PreUpgradeCheckResourceProvider.UPGRADE_CHECK_REPOSITORY_VERSION_PROPERTY_ID).equals(repositoryVersion.getVersion()).and().property(
-          PreUpgradeCheckResourceProvider.UPGRADE_CHECK_UPGRADE_TYPE_PROPERTY_ID).equals(upgradeType).and().property(
+          PreUpgradeCheckResourceProvider.UPGRADE_CHECK_UPGRADE_TYPE_PROPERTY_ID).equals(type).and().property(
           PreUpgradeCheckResourceProvider.UPGRADE_CHECK_UPGRADE_PACK_PROPERTY_ID).equals(preferredUpgradePack).toPredicate();
 
       Request preUpgradeCheckRequest = PropertyHelper.getReadRequest();
@@ -960,10 +944,8 @@ public class UpgradeContext {
      * {@inheritDoc}
      */
     @Override
-    void check(UpgradeContext upgradeContext, UpgradePack upgradePack) throws AmbariException {
-      Cluster cluster = upgradeContext.getCluster();
-      Direction direction = upgradeContext.getDirection();
-      Map<String, Object> requestMap = upgradeContext.getUpgradeRequest();
+    void check(Cluster cluster, Direction direction, UpgradeType type, UpgradePack upgradePack,
+        Map<String, Object> requestMap) throws AmbariException {
 
       String skipFailuresRequestProperty = (String) requestMap.get(UPGRADE_SKIP_FAILURES);
       if (Boolean.parseBoolean(skipFailuresRequestProperty)) {
@@ -1020,56 +1002,56 @@ public class UpgradeContext {
         }
       }
     }
-  }
 
-  /**
-   * Builds the list of {@link HostOrderItem}s from the upgrade request. If the
-   * upgrade request does not contain the hosts
-   *
-   * @param requestMap
-   *          the map of properties from the request (not {@code null}).
-   * @return the ordered list of actions to orchestrate for the
-   *         {@link UpgradeType#HOST_ORDERED} upgrade.
-   * @throws AmbariException
-   *           if the request properties are not valid.
-   */
-  @SuppressWarnings("unchecked")
-  private List<HostOrderItem> extractHostOrderItemsFromRequest(Map<String, Object> requestMap)
-      throws AmbariException {
-    // ewwww
-    Set<Map<String, List<String>>> hostsOrder = (Set<Map<String, List<String>>>) requestMap.get(
-        UPGRADE_HOST_ORDERED_HOSTS);
-
-    if (CollectionUtils.isEmpty(hostsOrder)) {
-      throw new AmbariException(
-          String.format("The %s property must be specified when using a %s upgrade type.",
-              UPGRADE_HOST_ORDERED_HOSTS, UpgradeType.HOST_ORDERED));
-    }
+    /**
+     * Builds the list of {@link HostOrderItem}s from the upgrade request. If
+     * the upgrade request does not contain the hosts
+     *
+     * @param requestMap
+     *          the map of properties from the request (not {@code null}).
+     * @return the ordered list of actions to orchestrate for the
+     *         {@link UpgradeType#HOST_ORDERED} upgrade.
+     * @throws AmbariException
+     *           if the request properties are not valid.
+     */
+    private List<HostOrderItem> extractHostOrderItemsFromRequest(Map<String, Object> requestMap)
+        throws AmbariException {
+      // ewwww
+      Set<Map<String, List<String>>> hostsOrder = (Set<Map<String, List<String>>>) requestMap.get(
+          UPGRADE_HOST_ORDERED_HOSTS);
 
-    List<HostOrderItem> hostOrderItems = new ArrayList<>();
+      if (CollectionUtils.isEmpty(hostsOrder)) {
+        throw new AmbariException(
+            String.format("The %s property must be specified when using a %s upgrade type.",
+                UPGRADE_HOST_ORDERED_HOSTS, UpgradeType.HOST_ORDERED));
+      }
 
-    // extract all of the hosts so that we can ensure they are all accounted for
-    Iterator<Map<String, List<String>>> iterator = hostsOrder.iterator();
-    while (iterator.hasNext()) {
-      Map<String, List<String>> grouping = iterator.next();
-      List<String> hosts = grouping.get("hosts");
-      List<String> serviceChecks = grouping.get("service_checks");
+      List<HostOrderItem> hostOrderItems = new ArrayList<>();
 
-      if (CollectionUtils.isEmpty(hosts) && CollectionUtils.isEmpty(serviceChecks)) {
-        throw new AmbariException(String.format(
-            "The %s property must contain at least one object with either a %s or %s key",
-            UPGRADE_HOST_ORDERED_HOSTS, "hosts", "service_checks"));
-      }
+      // extract all of the hosts so that we can ensure they are all accounted
+      // for
+      Iterator<Map<String, List<String>>> iterator = hostsOrder.iterator();
+      while (iterator.hasNext()) {
+        Map<String, List<String>> grouping = iterator.next();
+        List<String> hosts = grouping.get("hosts");
+        List<String> serviceChecks = grouping.get("service_checks");
 
-      if (CollectionUtils.isNotEmpty(hosts)) {
-        hostOrderItems.add(new HostOrderItem(HostOrderActionType.HOST_UPGRADE, hosts));
-      }
+        if (CollectionUtils.isEmpty(hosts) && CollectionUtils.isEmpty(serviceChecks)) {
+          throw new AmbariException(String.format(
+              "The %s property must contain at least one object with either a %s or %s key",
+              UPGRADE_HOST_ORDERED_HOSTS, "hosts", "service_checks"));
+        }
+
+        if (CollectionUtils.isNotEmpty(hosts)) {
+          hostOrderItems.add(new HostOrderItem(HostOrderActionType.HOST_UPGRADE, hosts));
+        }
 
-      if (CollectionUtils.isNotEmpty(serviceChecks)) {
-        hostOrderItems.add(new HostOrderItem(HostOrderActionType.SERVICE_CHECK, serviceChecks));
+        if (CollectionUtils.isNotEmpty(serviceChecks)) {
+          hostOrderItems.add(new HostOrderItem(HostOrderActionType.SERVICE_CHECK, serviceChecks));
+        }
       }
-    }
 
-    return hostOrderItems;
+      return hostOrderItems;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 281523a..e4ac23e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -304,13 +304,6 @@ public class ClusterImpl implements Cluster {
    */
   private Map<String, String> m_clusterPropertyCache = new ConcurrentHashMap<>();
 
-  /**
-   * A simple cache of the effective cluster version during an upgrade. Since
-   * calculation of this during an upgrade is not very quick or clean, it's good
-   * to cache it.
-   */
-  private final Map<Long, String> upgradeEffectiveVersionCache = new ConcurrentHashMap<>();
-
   @Inject
   public ClusterImpl(@Assisted ClusterEntity clusterEntity, Injector injector,
       AmbariEventPublisher eventPublisher)
@@ -969,14 +962,6 @@ public class ClusterImpl implements Cluster {
    * {@inheritDoc}
    */
   @Override
-  public void invalidateUpgradeEffectiveVersion() {
-    upgradeEffectiveVersionCache.clear();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
   @Transactional
   public List<Host> transitionHostsToInstalling(RepositoryVersionEntity repoVersionEntity,
       VersionDefinitionXml versionDefinitionXml, boolean forceInstalled) throws AmbariException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
index a7732d9..7b44677 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
@@ -27,7 +27,6 @@ from ambari_commons.os_check import OSCheck
 from resource_management.libraries.script import Script
 from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_tools
-from resource_management.libraries.functions.constants import Direction
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions.version import format_stack_version
 from resource_management.core import shell
@@ -36,13 +35,14 @@ from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Execute, Link, Directory
 from resource_management.libraries.functions.stack_features import check_stack_feature
 from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions.decorator import experimental
 
 class UpgradeSetAll(Script):
   """
   This script is a part of stack upgrade workflow and is used to set the
   all of the component versions as a final step in the upgrade process
   """
-
+  @experimental(feature="PATCH_UPGRADES", disable = True, comment = "Skipping stack-select set all")
   def actionexecute(self, env):
     version = default('/commandParams/version', None)
 
@@ -79,51 +79,6 @@ class UpgradeSetAll(Script):
           link_config(dir_def['conf_dir'], dir_def['current_dir'])
 
 
-  def unlink_all_configs(self, env):
-    """
-    Reverses the work performed in link_config. This should only be used when downgrading from
-    HDP 2.3 to 2.2 in order to under the symlink work required for 2.3.
-    """
-    stack_name = default('/hostLevelParams/stack_name', "").upper()
-    downgrade_to_version = default('/commandParams/version', None)
-    downgrade_from_version = default('/commandParams/downgrade_from_version', None)
-    upgrade_direction = default("/commandParams/upgrade_direction", Direction.UPGRADE)
-
-    # downgrade only
-    if upgrade_direction != Direction.DOWNGRADE:
-      Logger.warning("Unlinking configurations should only be performed on a downgrade.")
-      return
-
-    if downgrade_to_version is None or downgrade_from_version is None:
-      Logger.warning("Both 'commandParams/version' and 'commandParams/downgrade_from_version' must be specified to unlink configs on downgrade.")
-      return
-
-    Logger.info("Unlinking all configs when downgrading from {0} {1} to {2}".format(
-        stack_name, downgrade_from_version, downgrade_to_version))
-
-    # normalize the versions
-    downgrade_to_version = format_stack_version(downgrade_to_version)
-    downgrade_from_version = format_stack_version(downgrade_from_version)
-
-    # downgrade-to-version must be 2.2 (less than 2.3)
-    if downgrade_to_version and check_stack_feature(StackFeature.CONFIG_VERSIONING, downgrade_to_version):
-      Logger.warning("Unlinking configurations should not be performed when downgrading {0} {1} to {2}".format(
-          stack_name, downgrade_from_version, downgrade_to_version))
-      return
-
-    # downgrade-from-version must be 2.3+
-    if not( downgrade_from_version and check_stack_feature(StackFeature.CONFIG_VERSIONING, downgrade_from_version) ):
-      Logger.warning("Unlinking configurations should not be performed when downgrading {0} {1} to {2}".format(
-          stack_name, downgrade_from_version, downgrade_to_version))
-      return
-
-    # iterate through all directory conf mappings and undo the symlinks
-    for key, value in conf_select.get_package_dirs().iteritems():
-      for directory_mapping in value:
-        original_config_directory = directory_mapping['conf_dir']
-        self._unlink_config(original_config_directory)
-
-
   def _unlink_config(self, original_conf_directory):
     """
     Reverses the work performed in link_config. This should only be used when downgrading from

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 4170342..0735d5a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -2117,7 +2117,7 @@ public class AmbariManagementControllerImplTest {
 
     Map<String, String> defaultHostParams = helper.createDefaultHostParams(cluster, repositoryVersionEntity);
 
-    assertEquals(defaultHostParams.size(), 16);
+    assertEquals(defaultHostParams.size(), 15);
     assertEquals(defaultHostParams.get(DB_DRIVER_FILENAME), MYSQL_JAR);
     assertEquals(defaultHostParams.get(STACK_NAME), SOME_STACK_NAME);
     assertEquals(defaultHostParams.get(STACK_VERSION), SOME_STACK_VERSION);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/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 738ad1f..b06117b 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
@@ -299,8 +299,6 @@ public class ComponentVersionCheckActionTest {
 
     // Finalize the upgrade
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName("c1");
@@ -367,8 +365,6 @@ public class ComponentVersionCheckActionTest {
     // now finalize and ensure we can transition from UPGRADING to UPGRADED
     // automatically before CURRENT
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName("c1");
@@ -434,8 +430,6 @@ public class ComponentVersionCheckActionTest {
 
     // Finalize the upgrade
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName("c1");

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
index 2bc2c13..0aea8b3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
@@ -75,7 +75,6 @@ import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.stack.UpgradePack;
-import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
@@ -363,7 +362,8 @@ public class UpgradeActionTest {
     String urlInfo = "[{'repositories':["
         + "{'Repositories/base_url':'http://foo1','Repositories/repo_name':'HDP','Repositories/repo_id':'" + targetRepo + "'}"
         + "], 'OperatingSystems/os_type':'redhat6'}]";
-    repoVersionDAO.create(stackEntityTarget, targetRepo, String.valueOf(System.currentTimeMillis()), urlInfo);
+
+    m_helper.getOrCreateRepositoryVersion(new StackId(stackEntityTarget), targetRepo);
 
     // Start upgrading the newer repo
 
@@ -426,11 +426,6 @@ public class UpgradeActionTest {
     Assert.assertFalse(configs.isEmpty());
 
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(UpdateDesiredStackAction.COMMAND_PARAM_ORIGINAL_STACK, sourceStack.getStackId());
-    commandParams.put(UpdateDesiredStackAction.COMMAND_PARAM_TARGET_STACK, targetStack.getStackId());
-    commandParams.put(UpdateDesiredStackAction.COMMAND_PARAM_DIRECTION, Direction.UPGRADE.toString());
-    commandParams.put(UpdateDesiredStackAction.COMMAND_PARAM_UPGRADE_PACK, upgradePackName);
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     Map<String, String> roleParams = new HashMap<>();
@@ -476,8 +471,6 @@ public class UpgradeActionTest {
     createUpgrade(cluster, repositoryVersion2111);
 
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "downgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);
@@ -527,8 +520,6 @@ public class UpgradeActionTest {
     createUpgrade(cluster, repositoryVersion2202);
 
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "downgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);
@@ -565,8 +556,6 @@ public class UpgradeActionTest {
 
     // Finalize the upgrade
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);
@@ -624,7 +613,6 @@ public class UpgradeActionTest {
 
     // Finalize the upgrade
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
 
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
@@ -661,8 +649,6 @@ public class UpgradeActionTest {
     createUpgrade(cluster, repositoryVersion2201);
 
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);
@@ -732,8 +718,6 @@ public class UpgradeActionTest {
     assertEquals(8, configs.size());
 
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "downgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);
@@ -832,8 +816,6 @@ public class UpgradeActionTest {
     // now finalize and ensure we can transition from UPGRADING to UPGRADED
     // automatically before CURRENT
     Map<String, String> commandParams = new HashMap<>();
-    commandParams.put(FinalizeUpgradeAction.UPGRADE_DIRECTION_KEY, "upgrade");
-
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
     executionCommand.setClusterName(clusterName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java
index 09fc5cd..2baf3fa 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java
@@ -100,7 +100,7 @@ public class StageWrapperBuilderTest extends EasyMockSupport {
     EasyMock.expect(repoVersionDAO.findByStackNameAndVersion(EasyMock.anyString(),
         EasyMock.anyString())).andReturn(repoVersionEntity).anyTimes();
 
-    UpgradeContext upgradeContext = EasyMock.createNiceMock(UpgradeContext.class);
+    UpgradeContext upgradeContext = createNiceMock(UpgradeContext.class);
     EasyMock.expect(upgradeContext.getCluster()).andReturn(cluster).anyTimes();
     EasyMock.expect(upgradeContext.getType()).andReturn(UpgradeType.ROLLING).anyTimes();
     EasyMock.expect(upgradeContext.getDirection()).andReturn(Direction.UPGRADE).anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index 3d1cdfc..1649078 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -643,7 +643,7 @@ public class UpgradeCatalog200Test {
         clusterEntity, HOST_NAME);
 
     upgradeCatalogHelper.addComponent(injector, clusterEntity,
-        clusterServiceEntityNagios, hostEntity, "NAGIOS_SERVER", stackEntity);
+        clusterServiceEntityNagios, hostEntity, "NAGIOS_SERVER", repositoryVersion);
 
     ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.findByName(
         clusterEntity.getClusterId(), "NAGIOS", "NAGIOS_SERVER");

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
index 4ed7685..6c2e9f7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java
@@ -65,6 +65,7 @@ import org.apache.ambari.server.orm.dao.ArtifactDAO;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
 import org.apache.ambari.server.orm.dao.ClusterStateDAO;
 import org.apache.ambari.server.orm.dao.HostComponentDesiredStateDAO;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.entities.ArtifactEntity;
@@ -73,6 +74,7 @@ import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
 import org.apache.ambari.server.orm.entities.ClusterStateEntity;
 import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.state.Cluster;
@@ -825,11 +827,16 @@ public class UpgradeCatalog210Test {
     clusterEntity.setClusterStateEntity(clusterStateEntity);
     clusterDAO.merge(clusterEntity);
 
+    RepositoryVersionDAO repositoryVersionDAO = injector.getInstance(RepositoryVersionDAO.class);
+    RepositoryVersionEntity repositoryVersion = repositoryVersionDAO.findByStackAndVersion(
+        desiredStackEntity, desiredRepositoryVersion);
+
     ServiceComponentDesiredStateEntity componentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
     componentDesiredStateEntity.setClusterId(clusterEntity.getClusterId());
     componentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
     componentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
     componentDesiredStateEntity.setComponentName("STORM_REST_API");
+    componentDesiredStateEntity.setDesiredRepositoryVersion(repositoryVersion);
 
     ServiceComponentDesiredStateDAO componentDesiredStateDAO =
       injector.getInstance(ServiceComponentDesiredStateDAO.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogHelper.java
index 2cf0321..6b28846 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogHelper.java
@@ -174,12 +174,12 @@ public class UpgradeCatalogHelper {
    * @param clusterServiceEntity
    * @param hostEntity
    * @param componentName
-   * @param desiredStackEntity
+   * @param repositoryversion
    */
   @Transactional
   protected void addComponent(Injector injector, ClusterEntity clusterEntity,
       ClusterServiceEntity clusterServiceEntity, HostEntity hostEntity,
-      String componentName, StackEntity desiredStackEntity) {
+      String componentName, RepositoryVersionEntity repositoryversion) {
     ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(
         ServiceComponentDesiredStateDAO.class);
 
@@ -189,6 +189,7 @@ public class UpgradeCatalogHelper {
     componentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
     componentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
     componentDesiredStateEntity.setClusterId(clusterServiceEntity.getClusterId());
+    componentDesiredStateEntity.setDesiredRepositoryVersion(repositoryversion);
     serviceComponentDesiredStateDAO.create(componentDesiredStateEntity);
 
     HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py b/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
index e1a89a8..29c99d8 100644
--- a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
+++ b/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
@@ -25,17 +25,15 @@ import json
 from mock.mock import patch
 from mock.mock import MagicMock
 
+from stacks.utils.RMFTestCase import experimental_mock
+patch('resource_management.libraries.functions.decorator.experimental', experimental_mock).start()
+
 # Module imports
-import subprocess
 from stacks.utils.RMFTestCase import *
 from resource_management import Script, ConfigDictionary
 from resource_management.libraries.functions.default import default
-from resource_management.libraries.functions import conf_select
 from resource_management.core.logger import Logger
-from ambari_agent.AmbariConfig import AmbariConfig
-from ambari_agent.FileCache import FileCache
 from ambari_commons.os_check import OSCheck
-from resource_management.core import shell
 from resource_management.core.environment import Environment
 import pprint
 
@@ -48,7 +46,6 @@ def fake_call(command, **kwargs):
   """
   return (0, str(command))
 
-
 class TestRUSetAll(RMFTestCase):
   def get_custom_actions_dir(self):
     return os.path.join(self.get_src_folder(), "test/resources/custom_actions/")
@@ -198,121 +195,6 @@ class TestRUSetAll(RMFTestCase):
     self.assertEqual(call_mock.call_count, 1)
 
 
-  @patch("os.path.islink")
-  @patch("os.path.isdir")
-  @patch("resource_management.core.shell.call")
-  @patch.object(Script, 'get_config')
-  @patch.object(OSCheck, 'is_redhat_family')
-  def test_downgrade_unlink_configs(self, family_mock, get_config_mock, call_mock,
-                                    isdir_mock, islink_mock):
-    """
-    Tests downgrading from 2.3 to 2.2 to ensure that conf symlinks are removed and the backup
-    directories restored.
-    """
-
-    isdir_mock.return_value = True
-
-    # required for the test to run since the Execute calls need this
-    from resource_management.core.environment import Environment
-    env = Environment(test_mode=True)
-    with env:
-      # Mock the config objects
-      json_file_path = os.path.join(self.get_custom_actions_dir(), "ru_execute_tasks_namenode_prepare.json")
-      self.assertTrue(os.path.isfile(json_file_path))
-      with open(json_file_path, "r") as json_file:
-        json_payload = json.load(json_file)
-
-      # alter JSON for a downgrade from 2.3 to 2.2
-      json_payload['commandParams']['version'] = "2.2.0.0-1234"
-      json_payload['commandParams']['downgrade_from_version'] = "2.3.0.0-1234"
-      json_payload['commandParams']['original_stack'] = "HDP-2.2"
-      json_payload['commandParams']['target_stack'] = "HDP-2.3"
-      json_payload['commandParams']['upgrade_direction'] = "downgrade"
-      json_payload['hostLevelParams']['stack_version'] = "2.2"
-      json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
-      json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
-
-      config_dict = ConfigDictionary(json_payload)
-
-      family_mock.return_value = True
-      get_config_mock.return_value = config_dict
-      call_mock.side_effect = fake_call   # echo the command
-
-      # test the function
-      ru_execute = UpgradeSetAll()
-      ru_execute.unlink_all_configs(None)
-
-      # verify that os.path.islink was called for each conf
-      self.assertTrue(islink_mock.called)
-      for key, value in conf_select.get_package_dirs().iteritems():
-        for directory_mapping in value:
-          original_config_directory = directory_mapping['conf_dir']
-          is_link_called = False
-
-          for call in islink_mock.call_args_list:
-            call_tuple = call[0]
-            if original_config_directory in call_tuple:
-              is_link_called = True
-
-          if not is_link_called:
-            self.fail("os.path.islink({0}) was never called".format(original_config_directory))
-
-      # alter JSON for a downgrade from 2.3 to 2.3
-      with open(json_file_path, "r") as json_file:
-        json_payload = json.load(json_file)
-
-      json_payload['commandParams']['version'] = "2.3.0.0-1234"
-      json_payload['commandParams']['downgrade_from_version'] = "2.3.0.0-5678"
-      json_payload['commandParams']['original_stack'] = "HDP-2.3"
-      json_payload['commandParams']['target_stack'] = "HDP-2.3"
-      json_payload['commandParams']['upgrade_direction'] = "downgrade"
-      json_payload['hostLevelParams']['stack_version'] = "2.3"
-      json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
-      json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
-
-      # reset config
-      config_dict = ConfigDictionary(json_payload)
-      family_mock.return_value = True
-      get_config_mock.return_value = config_dict
-
-      # reset mock
-      islink_mock.reset_mock()
-
-      # test the function
-      ru_execute = UpgradeSetAll()
-      ru_execute.unlink_all_configs(None)
-
-      # ensure it wasn't called this time
-      self.assertFalse(islink_mock.called)
-
-      with open(json_file_path, "r") as json_file:
-        json_payload = json.load(json_file)
-
-      # alter JSON for a downgrade from 2.2 to 2.2
-      json_payload['commandParams']['version'] = "2.2.0.0-1234"
-      json_payload['commandParams']['downgrade_from_version'] = "2.2.0.0-5678"
-      json_payload['commandParams']['original_stack'] = "HDP-2.2"
-      json_payload['commandParams']['target_stack'] = "HDP-2.2"
-      json_payload['commandParams']['upgrade_direction'] = "downgrade"
-      json_payload['hostLevelParams']['stack_version'] = "2.2"
-      json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
-      json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
-
-      # reset config
-      config_dict = ConfigDictionary(json_payload)
-      family_mock.return_value = True
-      get_config_mock.return_value = config_dict
-
-      # reset mock
-      islink_mock.reset_mock()
-
-      # test the function
-      ru_execute = UpgradeSetAll()
-      ru_execute.unlink_all_configs(None)
-
-      # ensure it wasn't called this time
-      self.assertFalse(islink_mock.called)
-
   @patch("os.path.isdir")
   @patch("os.path.islink")
   def test_unlink_configs_missing_backup(self, islink_mock, isdir_mock):

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
index badaaef..282b542 100644
--- a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
+++ b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
@@ -381,5 +381,15 @@ class CallFunctionMock():
       result = other(*self.args, **self.kwargs)
       return self.call_result == result
     return False
-      
+
+def experimental_mock(*args, **kwargs):
+  """
+  Used to disable experimental mocks...
+  :return: 
+  """
+  def decorator(function):
+    def wrapper(*args, **kwargs):
+      return function(*args, **kwargs)
+    return wrapper
+  return decorator
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4132783/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
index 9d53714..a397be9 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
@@ -231,7 +231,7 @@
       <execute-stage title="Restore configuration directories and remove HDP 2.3 symlinks">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>
-          <function>unlink_all_configs</function>
+          <function>foo_function</function>
         </task>
       </execute-stage>
     </group>


Mime
View raw message