This is an automated email from the ASF dual-hosted git repository.

jonathanhurley pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new 7ca1a5a  AMBARI-23246 - Pass Mpack ID In Agent Commands For 
Installation Updates (#963)
7ca1a5a is described below

commit 7ca1a5a83181eb85daf19638d460ffafd6e79dce
Author: Jonathan Hurley <jonathanhur...@apache.org>
AuthorDate: Wed Apr 11 13:11:04 2018 -0400

    AMBARI-23246 - Pass Mpack ID In Agent Commands For Installation Updates 
(#963)
---
 .../main/python/ambari_agent/CommandStatusDict.py  |   3 +-
 .../server/actionmanager/ActionScheduler.java      |   3 +-
 .../actionmanager/ExecutionCommandWrapper.java     |   7 +-
 .../apache/ambari/server/actionmanager/Stage.java  |   8 +-
 .../ambari/server/agent/ExecutionCommand.java      |  12 +-
 .../server/controller/ActionExecutionContext.java  |  14 ++-
 .../controller/AmbariActionExecutionHelper.java    |   7 +-
 .../AmbariCustomCommandExecutionHelper.java        |  36 ++----
 .../controller/AmbariManagementControllerImpl.java |  23 ++--
 .../server/events/CommandReportReceivedEvent.java  |   4 +-
 .../upgrade/MpackInstallStateListener.java         |   5 +
 .../ambari/server/state/cluster/ClusterImpl.java   |   1 +
 .../org/apache/ambari/server/utils/StageUtils.java |   6 +-
 .../actionmanager/ExecutionCommandWrapperTest.java |   7 +-
 .../actionmanager/TestActionDBAccessorImpl.java    |  16 +--
 .../server/actionmanager/TestActionManager.java    |  10 +-
 .../server/actionmanager/TestActionScheduler.java  |  40 +++---
 .../ambari/server/actionmanager/TestStage.java     |   6 +-
 .../server/agent/HeartbeatProcessorTest.java       |  13 +-
 .../ambari/server/agent/HeartbeatTestHelper.java   |   3 +-
 .../ambari/server/agent/TestHeartbeatHandler.java  |   6 +-
 .../alerts/ComponentVersionAlertRunnableTest.java  |  10 --
 .../AmbariCustomCommandExecutionHelperTest.java    |  34 ++---
 .../controller/AmbariManagementControllerTest.java |  10 +-
 .../server/controller/KerberosHelperTest.java      |  12 +-
 .../internal/HostResourceProviderTest.java         |  24 +---
 ...erAuthenticationSourceResourceProviderTest.java |   4 -
 .../internal/UserResourceProviderTest.java         | 138 ++++++---------------
 .../upgrades/KerberosKeytabsActionTest.java        |   4 -
 .../upgrades/PreconfigureKerberosActionTest.java   |  35 +-----
 .../PostUserCreationHookServerActionTest.java      |   5 +-
 .../server/stageplanner/TestStagePlanner.java      |  70 +++++------
 .../ambari/server/state/ConfigHelperTest.java      |   9 +-
 .../ambari/server/state/cluster/ClusterTest.java   |   7 +-
 .../services/AlertNoticeDispatchServiceTest.java   |  18 +--
 .../services/CachedAlertFlushServiceTest.java      |   8 +-
 .../server/testutils/PartialNiceMockBinder.java    |  47 +++++--
 .../apache/ambari/server/utils/StageUtilsTest.java |  16 ---
 38 files changed, 264 insertions(+), 417 deletions(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py 
b/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
index 0ddc1d9..5a6ef85 100644
--- a/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
+++ b/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
@@ -168,7 +168,8 @@ class CommandStatusDict():
       'taskId': command['taskId'],
       'clusterId': command['clusterId'],
       'serviceName': command['serviceName'],
-      'roleCommand': command['roleCommand']
+      'roleCommand': command['roleCommand'],
+      'mpackId': command['mpackId'] if 'mpackId' in command else None
     }
     return stub
     
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 0ad306c..c7d937a 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -281,8 +281,7 @@ class ActionScheduler implements Runnable {
 
     this(sleepTimeMilliSec, actionTimeoutMilliSec, db, fsmObject, maxAttempts, 
hostsMap, unitOfWork,
         commandReportEventPublisher, configuration, entityManagerProvider, 
hostRoleCommandDAO,
-        hostRoleCommandFactory,null,
-            null);
+        hostRoleCommandFactory, null, agentCommandsPublisher);
   }
 
   /**
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 251eda4..d245fda 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
@@ -52,7 +52,6 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 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.UpgradeContext;
 import org.apache.ambari.server.state.UpgradeContext.UpgradeSummary;
 import org.apache.ambari.server.state.UpgradeContextFactory;
@@ -216,7 +215,9 @@ public class ExecutionCommandWrapper {
       Mpack mpack = ambariMetaInfo.getMpack(mpackId);
       MpackEntity mpackEntity = mpackDAO.findById(mpackId);
 
-      executionCommand.setMpackId(mpackId);
+      if (null == executionCommand.getMpackId()) {
+        executionCommand.setMpackId(mpackId);
+      }
 
       // setting repositoryFile
       final Host host = cluster.getHost(executionCommand.getHostname());  // 
can be null on internal commands
@@ -284,7 +285,7 @@ public class ExecutionCommandWrapper {
 
       if (null != stackEntity) {
         StackId stackId = new StackId(stackEntity);
-        StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
+        ambariMetaInfo.getStack(stackId.getStackName(),
           stackId.getStackVersion());
 
         if (!commandParams.containsKey(HOOKS_FOLDER)) {
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
index 3dfa5a3..21293d4 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
@@ -397,7 +397,8 @@ public class Stage {
    * This should be called only once for a host-role for a given stage.
    */
   public synchronized void addHostRoleExecutionCommand(String host, Role role, 
RoleCommand command,
-      ServiceComponentHostEvent event, String clusterName, String 
serviceGroupName, String serviceName, boolean retryAllowed,
+      ServiceComponentHostEvent event, String clusterName, Long mpackId, 
String serviceGroupName,
+      String serviceName, boolean retryAllowed,
       boolean autoSkipFailure) {
 
     boolean isHostRoleCommandAutoSkippable = autoSkipFailure && 
supportsAutoSkipOnFailure
@@ -406,6 +407,7 @@ public class Stage {
     ExecutionCommandWrapper commandWrapper = 
addGenericExecutionCommand(clusterName, host, role,
         command, event, retryAllowed, isHostRoleCommandAutoSkippable);
 
+    commandWrapper.getExecutionCommand().setMpackId(mpackId);
     commandWrapper.getExecutionCommand().setServiceGroupName(serviceGroupName);
     commandWrapper.getExecutionCommand().setServiceName(serviceName);
   }
@@ -416,7 +418,8 @@ public class Stage {
    * This should be called only once for a host-role for a given stage.
    */
   public synchronized void addHostRoleExecutionCommand(Host host, Role role, 
RoleCommand command,
-      ServiceComponentHostEvent event, Cluster cluster, String 
serviceGroupName, String serviceName, boolean retryAllowed,
+      ServiceComponentHostEvent event, Cluster cluster, Long mpackId, String 
serviceGroupName,
+      String serviceName, boolean retryAllowed,
       boolean autoSkipFailure) {
 
     boolean isHostRoleCommandAutoSkippable = autoSkipFailure && 
supportsAutoSkipOnFailure
@@ -425,6 +428,7 @@ public class Stage {
     ExecutionCommandWrapper commandWrapper = 
addGenericExecutionCommand(cluster, host, role,
         command, event, retryAllowed, isHostRoleCommandAutoSkippable);
 
+    commandWrapper.getExecutionCommand().setMpackId(mpackId);
     commandWrapper.getExecutionCommand().setServiceGroupName(serviceGroupName);
     commandWrapper.getExecutionCommand().setServiceName(serviceName);
   }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
index 17fcdb9..f1df6b5 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
@@ -126,6 +126,12 @@ public class ExecutionCommand extends AgentCommand {
   @com.fasterxml.jackson.annotation.JsonProperty("commandParams")
   private Map<String, String> commandParams = new HashMap<>();
 
+  /**
+   * If set, the management pack associated with this command.
+   */
+  @SerializedName("mpackId")
+  private Long mpackId;
+
   @SerializedName("serviceGroupName")
   private String serviceGroupName;
 
@@ -204,12 +210,6 @@ public class ExecutionCommand extends AgentCommand {
   @SerializedName("roleParameters")
   private Map<String, Object> roleParameters;
 
-  /**
-   * If set, the management pack associated with this command.
-   */
-  @SerializedName("mpackId")
-  private Long mpackId;
-
   public void setConfigurationCredentials(Map<String, Map<String, String>> 
configurationCredentials) {
     this.configurationCredentials = configurationCredentials;
   }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
index cd7b46d..9affac8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
@@ -42,6 +42,7 @@ public class ActionExecutionContext {
   private Map<String, String> parameters;
   private TargetHostType targetType;
   private Short timeout;
+  private Long mpackId;
   private String expectedServiceGroupName;
   private String expectedServiceName;
   private String expectedComponentName;
@@ -63,8 +64,8 @@ public class ActionExecutionContext {
   public ActionExecutionContext(String clusterName, String actionName,
       List<RequestResourceFilter> resourceFilters,
       Map<String, String> parameters, TargetHostType targetType,
-      Short timeout, String expectedServiceGroupName, String 
expectedServiceName,
-      String expectedComponentName) {
+      Short timeout, Long mpackId, String expectedServiceGroupName,
+      String expectedServiceName, String expectedComponentName) {
 
     this.clusterName = clusterName;
     this.actionName = actionName;
@@ -72,6 +73,7 @@ public class ActionExecutionContext {
     this.parameters = parameters;
     this.targetType = targetType;
     this.timeout = timeout;
+    this.mpackId = mpackId;
     this.expectedServiceGroupName = expectedServiceGroupName;
     this.expectedServiceName = expectedServiceName;
     this.expectedComponentName = expectedComponentName;
@@ -129,6 +131,14 @@ public class ActionExecutionContext {
     this.operationLevel = operationLevel;
   }
 
+  public Long getMpackId() {
+    return mpackId;
+  }
+
+  public void setMpackId(Long mpackId) {
+    this.mpackId = mpackId;
+  }
+
   public String getExpectedServiceGroupName() {
     return expectedServiceGroupName;
   }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 010b7a8..72516ce 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -50,6 +50,7 @@ import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceGroup;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
 import 
org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpInProgressEvent;
@@ -274,6 +275,7 @@ public class AmbariActionExecutionHelper {
     // List of host to select from
     Set<String> candidateHosts = new HashSet<>();
 
+    final Long mpackId = actionContext.getMpackId();
     final String serviceGroupName = 
actionContext.getExpectedServiceGroupName();
     final String serviceName = actionContext.getExpectedServiceName();
     final String componentName = actionContext.getExpectedComponentName();
@@ -291,9 +293,10 @@ public class AmbariActionExecutionHelper {
 //      if (serviceGroupName != null && !serviceGroupName.isEmpty()) {
       if (serviceName != null && !serviceName.isEmpty()) {
         if (componentName != null && !componentName.isEmpty()) {
+          ServiceGroup serviceGroup = 
cluster.getServiceGroup(serviceGroupName);
           Service service = cluster.getService(serviceGroupName, serviceName);
           ServiceComponent component = 
service.getServiceComponent(componentName);
-          StackId stackId = component.getStackId();
+          StackId stackId = serviceGroup.getStackId();
 
           Map<String, ServiceComponentHost> componentHosts = 
component.getServiceComponentHosts();
           candidateHosts.addAll(componentHosts.keySet());
@@ -395,7 +398,7 @@ public class AmbariActionExecutionHelper {
           RoleCommand.ACTIONEXECUTE,
           new 
ServiceComponentHostOpInProgressEvent(actionContext.getActionName(), hostName,
               System.currentTimeMillis()),
-          clusterName, serviceGroupName, serviceName, 
actionContext.isRetryAllowed(),
+          clusterName, mpackId, serviceGroupName, serviceName, 
actionContext.isRetryAllowed(),
           actionContext.isFailureAutoSkipped());
 
       Map<String, String> commandParams = new TreeMap<>();
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 97b8f36..4a99793 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -92,11 +92,11 @@ import 
org.apache.ambari.server.state.RefreshCommandConfiguration;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceGroup;
 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.State;
-import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
 import 
org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpInProgressEvent;
 import org.apache.ambari.server.utils.StageUtils;
@@ -167,9 +167,6 @@ public class AmbariCustomCommandExecutionHelper {
   private MaintenanceStateHelper maintenanceStateHelper;
 
   @Inject
-  private OsFamily os_family;
-
-  @Inject
   private HostRoleCommandDAO hostRoleCommandDAO;
 
   @Inject
@@ -325,12 +322,12 @@ public class AmbariCustomCommandExecutionHelper {
       throw new AmbariException(message);
     }
 
+    ServiceGroup serviceGroup = cluster.getServiceGroup(serviceGroupName);
     Service service = cluster.getService(serviceGroupName, serviceName);
     StackId stackId = service.getStackId();
 
     AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
     ServiceInfo serviceInfo = ambariMetaInfo.getService(service);
-    StackInfo stackInfo = ambariMetaInfo.getStack(stackId);
 
     CustomCommandDefinition customCommandDefinition = null;
     ComponentInfo ci = serviceInfo.getComponentByName(componentName);
@@ -344,10 +341,11 @@ public class AmbariCustomCommandExecutionHelper {
 
       Host host = clusters.getHost(hostName);
 
-      stage.addHostRoleExecutionCommand(hostName, Role.valueOf(componentName),
+      stage.addHostRoleExecutionCommand(host, Role.valueOf(componentName),
           RoleCommand.CUSTOM_COMMAND,
           new ServiceComponentHostOpInProgressEvent(componentName, hostName, 
nowTimestamp),
-          cluster.getClusterName(), serviceGroupName, serviceName, 
retryAllowed, autoSkipFailure);
+          cluster, serviceGroup.getMpackId(), serviceGroupName, serviceName, 
retryAllowed,
+          autoSkipFailure);
 
       Map<String, Map<String, String>> configurations =
           new TreeMap<>();
@@ -413,14 +411,6 @@ public class AmbariCustomCommandExecutionHelper {
 
       Map<String, String> hostLevelParams = new TreeMap<>();
 
-      // Set parameters required for re-installing clients on restart
-      String repoInfoString;
-      try {
-        repoInfoString = repoVersionHelper.getRepoInfoString(cluster, 
component, host);
-      } catch (SystemException e) {
-        throw new RuntimeException(e);
-      }
-
       hostLevelParams.put(STACK_NAME, stackId.getStackName());
       hostLevelParams.put(STACK_VERSION, stackId.getStackVersion());
 
@@ -851,23 +841,21 @@ public class AmbariCustomCommandExecutionHelper {
 
     String clusterName = stage.getClusterName();
     Cluster cluster = clusters.getCluster(clusterName);
+    ServiceGroup serviceGroup = cluster.getServiceGroup(serviceGroupName);
     Service service = cluster.getService(serviceName);
-    ServiceComponent component = null;
-    if (null != componentName) {
-      component = service.getServiceComponent(componentName);
-    }
-    StackId stackId = (null != component) ? component.getStackId() : 
service.getStackId();
+    StackId stackId = serviceGroup.getStackId();
 
     AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
         stackId.getStackVersion(), service.getServiceType());
-    StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
-        stackId.getStackVersion());
 
-    stage.addHostRoleExecutionCommand(hostname, Role.valueOf(smokeTestRole),
+    Host host = clusters.getHost(hostname);
+
+    stage.addHostRoleExecutionCommand(host, Role.valueOf(smokeTestRole),
         RoleCommand.SERVICE_CHECK,
         new ServiceComponentHostOpInProgressEvent(componentName, hostname, 
nowTimestamp),
-        cluster.getClusterName(), serviceGroupName, serviceName, retryAllowed, 
autoSkipFailure);
+        cluster, serviceGroup.getMpackId(), serviceGroupName, serviceName, 
retryAllowed,
+        autoSkipFailure);
 
     HostRoleCommand hrc = stage.getHostRoleCommand(hostname, smokeTestRole);
     if (hrc != null) {
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 ac85548..29cc3ee 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
@@ -332,8 +332,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   @Inject
   private Users users;
   @Inject
-  private HostsMap hostsMap;
-  @Inject
   private Configuration configs;
   @Inject
   private AbstractRootServiceResponseFactory rootServiceResponseFactory;
@@ -682,7 +680,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     // do all validation checks
     Map<String, Map<String, Map<String, Set<String>>>> hostComponentNames = 
new HashMap<>();
     Set<String> duplicates = new HashSet<>();
-    Set<ServiceComponentHostResponse> createdSvcHostCmpnt = null;
     for (ServiceComponentHostRequest request : requests) {
       validateServiceComponentHostRequest(request);
 
@@ -1369,11 +1366,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   }
 
   private Set<ServiceComponentHostResponse> getHostComponents(
-      ServiceComponentHostRequest request) throws AmbariException {
-    return getHostComponents(request, false);
-  }
-
-  private Set<ServiceComponentHostResponse> getHostComponents(
       ServiceComponentHostRequest request, boolean statusOnly) throws 
AmbariException {
     LOG.debug("Processing request {}", request);
 
@@ -2593,8 +2585,13 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     String serviceGroupName = scHost.getServiceGroupName();
     String serviceName = scHost.getServiceName();
 
+    ServiceGroup serviceGroup = cluster.getServiceGroup(serviceGroupName);
+    Long mpackId = serviceGroup.getMpackId();
+    StackId stackId = serviceGroup.getStackId();
+
     stage.addHostRoleExecutionCommand(scHost.getHost(),
-        Role.valueOf(scHost.getServiceComponentName()), roleCommand, event, 
cluster, serviceGroupName, serviceName, false, skipFailure);
+        Role.valueOf(scHost.getServiceComponentName()), roleCommand, event, 
cluster, mpackId,
+        serviceGroupName, serviceName, false, skipFailure);
 
     String componentName = scHost.getServiceComponentName();
     String hostname = scHost.getHostName();
@@ -2608,7 +2605,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
       //TODO fix matainfo
       servicesMap.put(clusterServiceName, 
ambariMetaInfo.getService(services.get(clusterServiceName)));
     }
-    StackId stackId = scHost.getServiceComponent().getStackId();
 
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
         stackId.getStackVersion(), scHost.getServiceType());
@@ -2937,8 +2933,8 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
               new ActionExecutionContext(actionRequest.getClusterName(),
               actionRequest.getActionName(), 
actionRequest.getResourceFilters(),
               actionRequest.getParameters(), actionDef.getTargetType(),
-              actionDef.getDefaultTimeout(), 
actionDef.getTargetServiceGroup(), actionDef.getTargetService(),
-              actionDef.getTargetComponent());
+              actionDef.getDefaultTimeout(), null, 
actionDef.getTargetServiceGroup(),
+              actionDef.getTargetService(), actionDef.getTargetComponent());
       actionExecutionContext.setOperationLevel(operationLevel);
       return actionExecutionContext;
     }
@@ -5170,7 +5166,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
       Set<RootServiceComponentRequest> requests) throws AmbariException {
     Set<RootServiceComponentResponse> response = new HashSet<>();
     for (RootServiceComponentRequest request : requests) {
-      String serviceName  = request.getServiceName();
       try {
         Set<RootServiceComponentResponse> rootServiceComponents = 
getRootServiceComponents(request);
         response.addAll(rootServiceComponents);
@@ -6235,8 +6230,6 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
         PropertyType.NOT_MANAGED_HDFS_PATH, cluster, desiredConfigs);
     String notManagedHdfsPathList = gson.toJson(notManagedHdfsPathSet);
     clusterLevelParams.put(NOT_MANAGED_HDFS_PATH_LIST, notManagedHdfsPathList);
-
-    StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
     clusterLevelParams.put(HOOKS_FOLDER, 
configs.getProperty(Configuration.HOOKS_FOLDER));
 
     return clusterLevelParams;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/events/CommandReportReceivedEvent.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/events/CommandReportReceivedEvent.java
index 4d27f3f..ddb0aed 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/events/CommandReportReceivedEvent.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/events/CommandReportReceivedEvent.java
@@ -19,7 +19,7 @@ package org.apache.ambari.server.events;
 
 import org.apache.ambari.server.agent.CommandReport;
 
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
 
 /**
  * The {@link CommandReportReceivedEvent} is fired when a command report is
@@ -69,7 +69,7 @@ public final class CommandReportReceivedEvent {
 
   @Override
   public String toString() {
-    return Objects.toStringHelper(this).add("clusterId", clusterId)
+    return MoreObjects.toStringHelper(this).add("clusterId", clusterId)
         .add("hostname", hostname)
         .add("status", commandReport.getStatus())
         .add("role", role).toString();
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/MpackInstallStateListener.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/MpackInstallStateListener.java
index 0a0a40e..425e8da 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/MpackInstallStateListener.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/MpackInstallStateListener.java
@@ -247,6 +247,11 @@ public class MpackInstallStateListener {
       mpackId = structuredOutput.mpackId;
     }
 
+    // last chance - try to get it from the failed command report
+    if (null == mpackId) {
+      mpackId = commandReport.getMpackId();
+    }
+
     if (!StringUtils.equals(HostRoleStatus.COMPLETED.name(), 
commandReport.getStatus())) {
       LOG.warn(
           "Command {} for {} did not complete on {}. The management pack 
installation state will be updated to {}.",
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 8d75747..eb689d9 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
@@ -311,6 +311,7 @@ public class ClusterImpl implements Cluster {
   @Inject
   private ClusterSettingDAO clusterSettingDAO;
 
+  @Inject
   private TopologyDeleteFormer topologyDeleteFormer;
 
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java 
b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
index 8a12df9..c5b8158 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
@@ -106,7 +106,7 @@ public class StageUtils {
 
   @Inject
   private static Configuration configuration;
-  
+
   @Inject
   public StageUtils(StageFactory stageFactory) {
     StageUtils.stageFactory = stageFactory;
@@ -222,7 +222,7 @@ public class StageUtils {
     long now = System.currentTimeMillis();
     s.addHostRoleExecutionCommand(hostname, Role.NAMENODE, RoleCommand.INSTALL,
         new ServiceComponentHostInstallEvent("NAMENODE", hostname, now, 
"HDP-1.2.0"), "cluster1",
-        "core", "HDFS", false, false);
+        1L, "core", "HDFS", false, false);
     ExecutionCommand execCmd = s.getExecutionCommandWrapper(hostname, 
"NAMENODE").getExecutionCommand();
 
     execCmd.setRequestAndStage(s.getRequestId(), s.getStageId());
@@ -443,7 +443,7 @@ public class StageUtils {
      * ambari-server hostname.
      */
     clusterHostInfo.put(AMBARI_SERVER_HOST, Sets.newHashSet(getHostName()));
-    
+
     boolean serverUseSsl = configuration.getApiSSLAuthentication();
     int port = serverUseSsl ? configuration.getClientSSLApiPort() : 
configuration.getClientApiPort();
     clusterHostInfo.put(AMBARI_SERVER_PORT, 
Sets.newHashSet(Integer.toString(port)));
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
index d71e2dc..fab7791 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
@@ -42,7 +42,6 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceGroup;
 import org.apache.ambari.server.state.StackId;
 import 
org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
@@ -114,7 +113,6 @@ public class ExecutionCommandWrapperTest {
 
     Cluster cluster1 = clusters.getCluster(CLUSTER1);
 
-    OrmTestHelper helper = injector.getInstance(OrmTestHelper.class);
     ServiceGroup serviceGroup = cluster1.addServiceGroup("CORE", 
cluster1.getDesiredStackVersion().getStackId());
     cluster1.addService(serviceGroup, "HDFS", "HDFS");
 
@@ -163,7 +161,7 @@ public class ExecutionCommandWrapperTest {
     s.addHostRoleExecutionCommand(hostName, Role.NAMENODE,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.NAMENODE.toString(),
-            hostName, System.currentTimeMillis()), clusterName, "core", 
"HDFS", false, false);
+            hostName, System.currentTimeMillis()), clusterName, 1L, "core", 
"HDFS", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
@@ -292,8 +290,6 @@ public class ExecutionCommandWrapperTest {
     repositoryVersion.setResolved(false);
     ormTestHelper.repositoryVersionDAO.merge(repositoryVersion);
 
-    Service service = cluster.getService("HDFS");
-
     // first try with an INSTALL command - this should not populate version 
info
     ExecutionCommand executionCommand = new ExecutionCommand();
     Map<String, String> commandParams = new HashMap<>();
@@ -362,7 +358,6 @@ public class ExecutionCommandWrapperTest {
     StackId stackId = cluster.getDesiredStackVersion();
     RepositoryVersionEntity repositoryVersion = 
ormTestHelper.getOrCreateRepositoryVersion(stackId, "0.1-0000");
     repositoryVersion.setResolved(true); // has build number
-    Service service = cluster.getService("HDFS");
 
     repositoryVersion.addRepoOsEntities(new ArrayList<>());
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
index 3c6a0be..9e4ce97 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
@@ -572,23 +572,23 @@ public class TestActionDBAccessorImpl {
     s.addHostRoleExecutionCommand("host1", Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            "host1", System.currentTimeMillis()), "cluster1", "core", "HBASE", 
false, false);
+            "host1", System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     s.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            "host2", System.currentTimeMillis()), "cluster1", "core", "HBASE", 
false, false);
+            "host2", System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     s.addHostRoleExecutionCommand(
         "host3",
         Role.HBASE_REGIONSERVER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
-            .toString(), "host3", System.currentTimeMillis()), "cluster1", 
"core", "HBASE", false, false);
+            .toString(), "host3", System.currentTimeMillis()), "cluster1", 1L, 
"core", "HBASE", false, false);
     s.addHostRoleExecutionCommand(
         "host4",
         Role.HBASE_REGIONSERVER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
-            .toString(), "host4", System.currentTimeMillis()), "cluster1", 
"core", "HBASE", false, false);
+            .toString(), "host4", System.currentTimeMillis()), "cluster1", 1L, 
"core", "HBASE", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     s.getOrderedHostRoleCommands().get(0).setStatus(HostRoleStatus.PENDING);
@@ -700,7 +700,7 @@ public class TestActionDBAccessorImpl {
       clusters.addHost(host);
 
       s.addHostRoleExecutionCommand("host" + i, Role.HBASE_MASTER,
-        RoleCommand.START, null, "cluster1", "core", "HBASE", false, false);
+        RoleCommand.START, null, "cluster1", 1L, "core", "HBASE", false, 
false);
     }
 
     List<Stage> stages = new ArrayList<>();
@@ -786,13 +786,13 @@ public class TestActionDBAccessorImpl {
     s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            hostname, System.currentTimeMillis()), "cluster1", "core", 
"HBASE", retryAllowed, false);
+            hostname, System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", retryAllowed, false);
     s.addHostRoleExecutionCommand(
         hostname,
         Role.HBASE_REGIONSERVER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
-            .toString(), hostname, System.currentTimeMillis()), "cluster1", 
"core", "HBASE", false, false);
+            .toString(), hostname, System.currentTimeMillis()), "cluster1", 
1L, "core", "HBASE", false, false);
     return s;
   }
 
@@ -804,7 +804,7 @@ public class TestActionDBAccessorImpl {
     s.addHostRoleExecutionCommand(hostname, Role.valueOf(actionName),
         RoleCommand.ACTIONEXECUTE,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            hostname, System.currentTimeMillis()), "cluster1", "core", 
"HBASE", false, false);
+            hostname, System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     final RequestResourceFilter resourceFilter = new 
RequestResourceFilter("core", "HBASE", "HBASE_MASTER", null);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
index ee04745..661a779 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
@@ -61,7 +61,6 @@ import org.junit.Test;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import com.google.inject.persist.UnitOfWork;
 
 import junit.framework.Assert;
 
@@ -74,7 +73,6 @@ public class TestActionManager {
   private String clusterName = "cluster1";
 
   private Clusters clusters;
-  private UnitOfWork unitOfWork;
   private StageFactory stageFactory;
 
   @Before
@@ -89,7 +87,6 @@ public class TestActionManager {
     clusters.addHost(hostname);
     StackId stackId = new StackId("HDP-0.1");
     clusters.addCluster(clusterName, stackId);
-    unitOfWork = injector.getInstance(UnitOfWork.class);
 
     EasyMock.replay(injector.getInstance(AuditLogger.class));
   }
@@ -224,7 +221,7 @@ public class TestActionManager {
     s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            hostname, System.currentTimeMillis()), "cluster1", "core", 
"HBASE", false, false);
+            hostname, System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
@@ -237,11 +234,11 @@ public class TestActionManager {
     s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-          hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", 
false, false);
+          hostname, System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     s.addHostRoleExecutionCommand(hostname, Role.HBASE_REGIONSERVER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER.toString(),
-          hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", 
false, false);
+          hostname, System.currentTimeMillis()), "cluster1", 1L, "core", 
"HBASE", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
@@ -253,7 +250,6 @@ public class TestActionManager {
   @Test
   public void testCascadeDeleteStages() throws Exception {
     ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);
-    ActionManager am = injector.getInstance(ActionManager.class);
     populateActionDB(db, hostname);
     assertEquals(1, clusters.getClusters().size());
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index e17d428..1f1c102 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -76,7 +76,6 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.events.CommandReportReceivedEvent;
 import org.apache.ambari.server.events.publishers.AgentCommandsPublisher;
-import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.events.publishers.CommandReportEventPublisher;
 import org.apache.ambari.server.metadata.RoleCommandOrder;
 import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
@@ -136,10 +135,6 @@ public class TestActionScheduler {
   private static final String CLUSTER_HOST_INFO = 
"{all_hosts=[c6403.ambari.apache.org," +
                " c6401.ambari.apache.org, c6402.ambari.apache.org], 
slave_hosts=[c6403.ambari.apache.org," +
                " c6401.ambari.apache.org, c6402.ambari.apache.org]}";
-  private static final String CLUSTER_HOST_INFO_UPDATED = 
"{all_hosts=[c6401.ambari.apache.org,"
-      + " c6402.ambari.apache.org], slave_hosts=[c6401.ambari.apache.org,"
-      + " c6402.ambari.apache.org]}";
-
   private final Injector injector;
 
   private final String hostname = "ahost.ambari.apache.org";
@@ -240,7 +235,9 @@ public class TestActionScheduler {
     //Keep large number of attempts so that the task is not expired finally
     //Small action timeout to test rescheduling
     ActionScheduler scheduler = new ActionScheduler(100, 5, db, fsm,
-        10000, new HostsMap((String) null), unitOfWork, eventPublisher, conf, 
entityManagerProviderMock, hostRoleCommandDAOMock, null,null);
+        10000, new HostsMap((String) null), unitOfWork, eventPublisher, conf,
+        entityManagerProviderMock, hostRoleCommandDAOMock, null, 
agentCommandsPublisher);
+
     scheduler.setTaskTimeoutAdjustment(false);
 
     List<AgentCommand> commands = waitForQueueSize(hostId, 
agentCommandsPublisher, 1, scheduler);
@@ -454,7 +451,7 @@ public class TestActionScheduler {
       "{\"host_param\":\"param_value\"}", "{\"stage_param\":\"param_value\"}");
     s.addHostRoleExecutionCommand(hostname, Role.SECONDARY_NAMENODE, 
RoleCommand.INSTALL,
             new ServiceComponentHostInstallEvent("SECONDARY_NAMENODE", 
hostname, System.currentTimeMillis(), "HDP-1.2.0"),
-            "cluster1", "core", "HDFS", false, false);
+            "cluster1", 1L, "core", "HDFS", false, false);
     s.setHostRoleStatus(hostname, "SECONDARY_NAMENODE", 
HostRoleStatus.IN_PROGRESS);
     List<Stage> stages = Collections.singletonList(s);
 
@@ -527,7 +524,6 @@ public class TestActionScheduler {
     ServiceComponent scomp = mock(ServiceComponent.class);
     ServiceComponentHost sch = mock(ServiceComponentHost.class);
     UnitOfWork unitOfWork = mock(UnitOfWork.class);
-    AgentCommandsPublisher agentCommandsPublisher = 
mock(AgentCommandsPublisher.class);
     when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
     when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
     when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -1102,8 +1098,8 @@ public class TestActionScheduler {
     ActionScheduler scheduler = 
EasyMock.createMockBuilder(ActionScheduler.class)
             .withConstructor(long.class, long.class, ActionDBAccessor.class, 
Clusters.class, int.class,
                     HostsMap.class, UnitOfWork.class, 
CommandReportEventPublisher.class,
-                    Configuration.class,
-                    Provider.class, HostRoleCommandDAO.class, 
HostRoleCommandFactory.class)
+                    Configuration.class, Provider.class, 
HostRoleCommandDAO.class,
+                    HostRoleCommandFactory.class, AgentCommandsPublisher.class)
             .withArgs(100L, 50L, db, fsm, -1, null, null, 
CommandReportEventPublisher, null,
 
                     entityManagerProviderMock, mock(HostRoleCommandDAO.class),
@@ -1570,7 +1566,6 @@ public class TestActionScheduler {
     ServiceComponent scomp = mock(ServiceComponent.class);
     ServiceComponentHost sch = mock(ServiceComponentHost.class);
     UnitOfWork unitOfWork = mock(UnitOfWork.class);
-    AmbariEventPublisher ambariEventPublisher = 
mock(AmbariEventPublisher.class);
     RequestFactory requestFactory = mock(RequestFactory.class);
     when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
     when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
@@ -1928,7 +1923,7 @@ public class TestActionScheduler {
                                            RoleCommand command, String host, 
String cluster) {
     stage.addHostRoleExecutionCommand(host, role, command,
         new ServiceComponentHostInstallEvent(role.toString(), host, now, 
"HDP-0.2"),
-        cluster, serviceGroup, service.toString(), false, false);
+        cluster, 1L, serviceGroup, service.toString(), false, false);
     stage.getExecutionCommandWrapper(host,
         role.toString()).getExecutionCommand();
   }
@@ -1957,19 +1952,19 @@ public class TestActionScheduler {
     stage.setStageId(1);
     stage.addHostRoleExecutionCommand("host1", Role.DATANODE, 
RoleCommand.UPGRADE,
         new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), 
"host1", now, "HDP-0.2"),
-        "cluster1", "core", Service.Type.HDFS.toString(), false, false);
+        "cluster1", 1L, "core", Service.Type.HDFS.toString(), false, false);
     stage.getExecutionCommandWrapper("host1",
         Role.DATANODE.toString()).getExecutionCommand();
 
     stage.addHostRoleExecutionCommand("host2", Role.DATANODE, 
RoleCommand.UPGRADE,
         new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), 
"host2", now, "HDP-0.2"),
-        "cluster1", "core", Service.Type.HDFS.toString(), false, false);
+        "cluster1", 1L, "core", Service.Type.HDFS.toString(), false, false);
     stage.getExecutionCommandWrapper("host2",
         Role.DATANODE.toString()).getExecutionCommand();
 
     stage.addHostRoleExecutionCommand("host3", Role.DATANODE, 
RoleCommand.UPGRADE,
         new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), 
"host3", now, "HDP-0.2"),
-        "cluster1", "core", Service.Type.HDFS.toString(), false, false);
+        "cluster1", 1L, "core", Service.Type.HDFS.toString(), false, false);
     stage.getExecutionCommandWrapper("host3",
         Role.DATANODE.toString()).getExecutionCommand();
 
@@ -2113,7 +2108,7 @@ public class TestActionScheduler {
                         RoleCommand roleCommand, String serviceGroupName, 
String serviceName, int taskId) {
     stage.addHostRoleExecutionCommand(hostname, role, roleCommand,
         new ServiceComponentHostUpgradeEvent(role.toString(), hostname, 
System.currentTimeMillis(), "HDP-0.2"),
-        clusterName, serviceGroupName, serviceName, false, false);
+        clusterName, 1L, serviceGroupName, serviceName, false, false);
     stage.getExecutionCommandWrapper(hostname,
         role.toString()).getExecutionCommand();
     stage.getOrderedHostRoleCommands().get(0).setTaskId(taskId);
@@ -2148,7 +2143,7 @@ public class TestActionScheduler {
 
     stage.addHostRoleExecutionCommand(hostname, role, roleCommand,
       new ServiceComponentHostInstallEvent(role.toString(), hostname,
-        System.currentTimeMillis(), "HDP-0.2"), clusterName, serviceGroup, 
service.toString(), false, false);
+        System.currentTimeMillis(), "HDP-0.2"), clusterName, 1L, serviceGroup, 
service.toString(), false, false);
     ExecutionCommand command = stage.getExecutionCommandWrapper
       (hostname, role.toString()).getExecutionCommand();
     command.setTaskId(taskId);
@@ -2904,6 +2899,8 @@ public class TestActionScheduler {
     hostEntity1.setHostName("h1");
     hostDAO.merge(hostEntity1);
 
+    AgentCommandsPublisher agentCommandsPublisher = 
mock(AgentCommandsPublisher.class);
+
     db.abortHostRole("h1", -1L, -1L, "AMBARI_SERVER_ACTION");
     EasyMock.expectLastCall();
 
@@ -2912,7 +2909,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, eventPublisher, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null, null);
+        (HostRoleCommandDAO) null, (HostRoleCommandFactory) null, 
agentCommandsPublisher);
 
     HostRoleCommand hrc1 = hostRoleCommandFactory.create("h1", Role.NAMENODE, 
null, RoleCommand.EXECUTE);
     hrc1.setStatus(HostRoleStatus.COMPLETED);
@@ -2939,12 +2936,14 @@ public class TestActionScheduler {
     hostEntity1.setHostName("h1");
     hostDAO.merge(hostEntity1);
 
+    AgentCommandsPublisher agentCommandsPublisher = 
mock(AgentCommandsPublisher.class);
+
     EasyMock.replay(db);
 
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, eventPublisher, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null, null);
+        (HostRoleCommandDAO) null, (HostRoleCommandFactory) null, 
agentCommandsPublisher);
 
     HostRoleCommand hrc1 = hostRoleCommandFactory.create("h1", Role.NAMENODE, 
null, RoleCommand.EXECUTE);
     hrc1.setStatus(HostRoleStatus.COMPLETED);
@@ -2995,7 +2994,6 @@ public class TestActionScheduler {
 
     // create 1 stage with 2 commands and then another stage with 1 command
     Stage stage = null;
-    Stage stage2 = null;
     final List<Stage> stages = new ArrayList<>();
     final List<Stage> firstStageInProgress = new ArrayList<>();
     stages.add(stage = getStageWithSingleTask(hostname1, "cluster1", 
Role.NAMENODE,
@@ -3004,7 +3002,7 @@ public class TestActionScheduler {
     addInstallTaskToStage(stage, hostname1, "cluster1", Role.HBASE_MASTER, 
RoleCommand.INSTALL,
         "core", Service.Type.HBASE, 1);
 
-    stages.add(stage2 = getStageWithSingleTask(hostname1, "cluster1", 
Role.DATANODE,
+    stages.add(getStageWithSingleTask(hostname1, "cluster1", Role.DATANODE,
         RoleCommand.STOP, "core", Service.Type.HDFS, 1, 1, 1));
 
     // !!! this is the test; make the stages skippable so that when their
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
index f4ad41e..d46aaaf 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
@@ -41,8 +41,6 @@ import com.google.inject.Injector;
 
 public class TestStage {
 
-  private static final String CLUSTER_HOST_INFO = "cluster_host_info";
-
   Injector injector;
 
   @Inject
@@ -62,9 +60,9 @@ public class TestStage {
   public void testTaskTimeout() {
     Stage s = StageUtils.getATestStage(1, 1, "h1",  
"{\"host_param\":\"param_value\"}", "{\"stage_param\":\"param_value\"}");
     s.addHostRoleExecutionCommand("h1", Role.DATANODE, RoleCommand.INSTALL,
-        null, "c1", "core", "HDFS", false, false);
+        null, "c1", 1L, "core", "HDFS", false, false);
     s.addHostRoleExecutionCommand("h1", Role.HBASE_MASTER, RoleCommand.INSTALL,
-        null, "c1", "core", "HBASE", false, false);
+        null, "c1", 1L, "core", "HBASE", false, false);
     for (ExecutionCommandWrapper wrapper : s.getExecutionCommands("h1")) {
       Map<String, String> commandParams = new TreeMap<>();
       commandParams.put(ExecutionCommand.KeyNames.COMMAND_TIMEOUT, "600");
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
index c49c948..7cb4b50 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
@@ -34,6 +34,7 @@ import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.sql.SQLException;
@@ -858,9 +859,6 @@ public class HeartbeatProcessorTest {
     ServiceComponentHost serviceComponentHost2 = 
clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1);
 
-    StackId stack130 = new StackId("HDP-1.3.0");
-    StackId stack120 = new StackId("HDP-1.2.0");
-
     serviceComponentHost1.setState(State.UPGRADING);
     serviceComponentHost2.setState(State.INSTALLING);
 
@@ -870,11 +868,11 @@ public class HeartbeatProcessorTest {
     s.addHostRoleExecutionCommand(DummyHostname1, Role.DATANODE, 
RoleCommand.UPGRADE,
         new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(),
             DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
-        DummyCluster, "core", "HDFS", false, false);
+        DummyCluster, 1L, "core", "HDFS", false, false);
     s.addHostRoleExecutionCommand(DummyHostname1, Role.NAMENODE, 
RoleCommand.INSTALL,
         new ServiceComponentHostInstallEvent(Role.NAMENODE.toString(),
             DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
-        DummyCluster, "core", "HDFS", false, false);
+        DummyCluster, 1L, "core", "HDFS", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
@@ -968,9 +966,6 @@ public class HeartbeatProcessorTest {
     ServiceComponentHost serviceComponentHost2 = 
clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1);
 
-    StackId stack130 = new StackId("HDP-1.3.0");
-    StackId stack120 = new StackId("HDP-1.2.0");
-
     serviceComponentHost1.setState(State.UPGRADING);
     serviceComponentHost2.setState(State.INSTALLING);
 
@@ -1042,6 +1037,8 @@ public class HeartbeatProcessorTest {
     replay(am);
 
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
+    assertNotNull(cluster);
+
     Clusters fsm = clusters;
     Host hostObject = clusters.getHost(DummyHostname1);
     hostObject.setIPv4("ipv4");
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
index 3f4b125..1fec6f3 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
@@ -224,11 +224,10 @@ public class HeartbeatTestHelper {
     Stage s = stageFactory.createNew(requestId, "/a/b", DummyCluster, 1L, 
"heartbeat handler test",
         "commandParamsStage", "hostParamsStage");
     s.setStageId(stageId);
-    String filename = null;
     s.addHostRoleExecutionCommand(DummyHostname1, Role.HBASE_MASTER,
         RoleCommand.START,
         new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
-            DummyHostname1, System.currentTimeMillis()), DummyCluster, 
CORE_SERVICE_GROUP, HBASE, false, false);
+            DummyHostname1, System.currentTimeMillis()), DummyCluster, 1L, 
CORE_SERVICE_GROUP, HBASE, false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 08f3df6..2b196b8 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -81,7 +81,6 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.events.publishers.AgentCommandsPublisher;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.orm.OrmTestHelper;
 import 
org.apache.ambari.server.serveraction.kerberos.KerberosIdentityDataFileWriter;
 import org.apache.ambari.server.serveraction.kerberos.KerberosServerAction;
 import 
org.apache.ambari.server.serveraction.kerberos.stageutils.KerberosKeytabController;
@@ -156,9 +155,6 @@ public class TestHeartbeatHandler {
   AuditLogger auditLogger;
 
   @Inject
-  private OrmTestHelper helper;
-
-  @Inject
   private AgentCommandsPublisher agentCommandsPublisher;
 
   @Rule
@@ -865,7 +861,7 @@ public class TestHeartbeatHandler {
     s.addHostRoleExecutionCommand(DummyHostname1, Role.DATANODE, 
RoleCommand.INSTALL,
       new ServiceComponentHostInstallEvent(Role.DATANODE.toString(),
         DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
-          DummyCluster, "core", "HDFS", false, false);
+          DummyCluster, 1L, "core", "HDFS", false, false);
     List<Stage> stages = new ArrayList<>();
     stages.add(s);
     Request request = new Request(stages, "clusterHostInfo", clusters);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnableTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnableTest.java
index 9208b1c..0e304f0 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnableTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnableTest.java
@@ -28,19 +28,14 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.persistence.EntityManager;
-
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.events.AlertEvent;
 import org.apache.ambari.server.events.AlertReceivedEvent;
 import org.apache.ambari.server.events.MockEventListener;
 import org.apache.ambari.server.events.publishers.AlertEventPublisher;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
-import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Alert;
 import org.apache.ambari.server.state.AlertState;
 import org.apache.ambari.server.state.Cluster;
@@ -354,14 +349,9 @@ public class ComponentVersionAlertRunnableTest extends 
EasyMockSupport {
           .addAmbariMetaInfoBinding()
           .build().configure(binder);
 
-      
binder.bind(AmbariMetaInfo.class).toInstance(createNiceMock(AmbariMetaInfo.class));
       binder.bind(Cluster.class).toInstance(cluster);
       
binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
-      
binder.bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
       
binder.bind(AmbariMetaInfo.class).toInstance(createNiceMock(AmbariMetaInfo.class));
-      
binder.bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
-      
binder.bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
-      
binder.bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
     }
   }
 }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index fd195e6..78ea265 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -17,6 +17,8 @@
  */
 package org.apache.ambari.server.controller;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -49,14 +51,12 @@ import org.apache.ambari.server.metadata.ActionMetadata;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
+import org.apache.ambari.server.orm.dao.MpackDAO;
 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.MpackEntity;
 import org.apache.ambari.server.orm.entities.RepoDefinitionEntity;
 import org.apache.ambari.server.orm.entities.RepoOsEntity;
 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.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.state.Cluster;
@@ -586,8 +586,6 @@ public class AmbariCustomCommandExecutionHelperTest {
     //add host with client only
     addHost("c1-c6403", "c1");
 
-    //create client service
-    OrmTestHelper ormTestHelper = injector.getInstance(OrmTestHelper.class);
     createService("c1", "CORE", "HADOOP_CLIENTS");
     createServiceComponent("c1", "CORE", "HADOOP_CLIENTS", 
"SOME_CLIENT_FOR_SERVICE_CHECK", "SOME_CLIENT_FOR_SERVICE_CHECK", State.INIT);
     createServiceComponentHost("c1", "CORE", "HADOOP_CLIENTS", 1L, 
"SOME_CLIENT_FOR_SERVICE_CHECK", "SOME_CLIENT_FOR_SERVICE_CHECK", "c1-c6403", 
State.INIT);
@@ -722,15 +720,12 @@ public class AmbariCustomCommandExecutionHelperTest {
     ServiceComponent componentZKC = 
serviceZK.getServiceComponent("ZOOKEEPER_CLIENT");
     Host host = clusters.getHost("c1-c6401");
 
-    StackDAO stackDAO = injector.getInstance(StackDAO.class);
-    RepositoryVersionDAO repoVersionDAO = 
injector.getInstance(RepositoryVersionDAO.class);
-    ServiceComponentDesiredStateDAO componentDAO = 
injector.getInstance(ServiceComponentDesiredStateDAO.class);
+    MpackDAO mpackDAO = injector.getInstance(MpackDAO.class);
     RepositoryVersionHelper repoVersionHelper = 
injector.getInstance(RepositoryVersionHelper.class);
 
     CommandRepository commandRepo = 
repoVersionHelper.getCommandRepository(cluster, componentRM, host);
     Assert.assertEquals(2, commandRepo.getRepositories().size());
 
-
     List<RepoOsEntity> operatingSystems = new ArrayList<>();
     RepoDefinitionEntity repoDefinitionEntity1 = new RepoDefinitionEntity();
     repoDefinitionEntity1.setRepoID("new-id");
@@ -742,14 +737,11 @@ public class AmbariCustomCommandExecutionHelperTest {
     repoOsEntity.addRepoDefinition(repoDefinitionEntity1);
     operatingSystems.add(repoOsEntity);
 
-    StackEntity stackEntity = 
stackDAO.find(cluster.getDesiredStackVersion().getStackName(),
-        cluster.getDesiredStackVersion().getStackVersion());
-
-    // add a repo version associated with a component
-    ServiceComponentDesiredStateEntity componentEntity = 
componentDAO.findByName(cluster.getClusterId(), serviceYARN.getServiceGroupId(),
-        serviceYARN.getServiceId(), componentRM.getName(), 
componentRM.getType());
-
-    componentDAO.merge(componentEntity);
+    MpackEntity mpackEntity = 
mpackDAO.findById(serviceYARN.getServiceGroupId());
+    mpackEntity.getRepositoryOperatingSystems().clear();
+    mpackEntity = mpackDAO.merge(mpackEntity);
+    mpackEntity.setRepositoryOperatingSystems(operatingSystems);
+    mpackEntity = mpackDAO.merge(mpackEntity);
 
     // !!! make sure the override is set
     commandRepo = repoVersionHelper.getCommandRepository(cluster, componentRM, 
host);
@@ -757,10 +749,6 @@ public class AmbariCustomCommandExecutionHelperTest {
     Assert.assertEquals(1, commandRepo.getRepositories().size());
     CommandRepository.Repository repo = 
commandRepo.getRepositories().iterator().next();
     Assert.assertEquals("http://foo";, repo.getBaseUrl());
-
-    // verify that ZK has no repositories, since we haven't defined a repo 
version for ZKC
-    commandRepo = repoVersionHelper.getCommandRepository(cluster, 
componentZKC, host);
-    Assert.assertEquals(2, commandRepo.getRepositories().size());
   }
 
   private void createClusterFixture(String clusterName, StackId stackId,
@@ -773,6 +761,8 @@ public class AmbariCustomCommandExecutionHelperTest {
     RepositoryVersionEntity repositoryVersion = 
ormTestHelper.getOrCreateRepositoryVersion(stackId,
         respositoryVersion);
 
+    assertNotNull(repositoryVersion);
+
     createCluster(clusterName, stackId.getStackId());
 
     addHost(hostC6401, clusterName);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index b2193da..fc02c6d 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -7309,7 +7309,7 @@ public class AmbariManagementControllerTest {
             RoleCommand.START,
             new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
                     hostName1, System.currentTimeMillis()),
-            cluster1, "CORE", "HBASE", false, false);
+            cluster1, 1L, "CORE", "HBASE", false, false);
 
     stages.add(stageFactory.createNew(requestId1, "/a2", cluster1, clusterId, 
context,
       "", ""));
@@ -7317,7 +7317,7 @@ public class AmbariManagementControllerTest {
     stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
             RoleCommand.START,
             new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
-                    hostName1, System.currentTimeMillis()), cluster1, "CORE", 
"HBASE", false, false);
+                    hostName1, System.currentTimeMillis()), cluster1, 1L, 
"CORE", "HBASE", false, false);
 
     stages.add(stageFactory.createNew(requestId1, "/a3", cluster1, clusterId, 
context,
       "", ""));
@@ -7325,7 +7325,7 @@ public class AmbariManagementControllerTest {
     stages.get(2).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
             RoleCommand.START,
             new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
-                    hostName1, System.currentTimeMillis()), cluster1, "CORE", 
"HBASE", false, false);
+                    hostName1, System.currentTimeMillis()), cluster1, 1L, 
"CORE", "HBASE", false, false);
 
     Request request = new Request(stages, "", clusters);
     actionDB.persistActions(request);
@@ -7337,7 +7337,7 @@ public class AmbariManagementControllerTest {
     stages.get(0).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
             RoleCommand.START,
             new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
-                    hostName1, System.currentTimeMillis()), cluster1, "CORE", 
"HBASE", false, false);
+                    hostName1, System.currentTimeMillis()), cluster1, 1L, 
"CORE", "HBASE", false, false);
 
     stages.add(stageFactory.createNew(requestId2, "/a5", cluster1, clusterId, 
context,
       "", ""));
@@ -7345,7 +7345,7 @@ public class AmbariManagementControllerTest {
     stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
             RoleCommand.START,
             new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
-                    hostName1, System.currentTimeMillis()), cluster1, "CORE", 
"HBASE", false, false);
+                    hostName1, System.currentTimeMillis()), cluster1, 1L, 
"CORE", "HBASE", false, false);
 
     request = new Request(stages, "", clusters);
     actionDB.persistActions(request);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
index 8984940..a7e2bd3 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
@@ -86,6 +86,7 @@ import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.orm.dao.KerberosKeytabPrincipalDAO;
 import org.apache.ambari.server.orm.dao.KerberosPrincipalDAO;
 import org.apache.ambari.server.orm.entities.KerberosKeytabPrincipalEntity;
+import org.apache.ambari.server.registry.RegistryManager;
 import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
@@ -109,6 +110,7 @@ import 
org.apache.ambari.server.serveraction.kerberos.PreconfigureServiceType;
 import 
org.apache.ambari.server.serveraction.kerberos.stageutils.ResolvedKerberosPrincipal;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.ClusterSettingFactory;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Config;
@@ -121,6 +123,7 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceComponentHostFactory;
+import org.apache.ambari.server.state.ServiceGroupFactory;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
@@ -135,8 +138,10 @@ import 
org.apache.ambari.server.state.kerberos.KerberosPrincipalType;
 import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
+import org.apache.ambari.server.topology.ComponentResolver;
 import org.apache.ambari.server.topology.PersistedState;
 import org.apache.ambari.server.topology.PersistedStateImpl;
+import org.apache.ambari.server.topology.StackFactory;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.directory.server.kerberos.shared.keytab.Keytab;
@@ -278,6 +283,11 @@ public class KerberosHelperTest extends EasyMockSupport {
         
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
         
bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
         
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
+        
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
+        
bind(RegistryManager.class).toInstance(createNiceMock(RegistryManager.class));
+        
bind(ComponentResolver.class).toInstance(createNiceMock(ComponentResolver.class));
+        
bind(ServiceGroupFactory.class).toInstance(createNiceMock(ServiceGroupFactory.class));
+        
bind(StackFactory.class).toInstance(createNiceMock(StackFactory.class));
 
         requestStaticInjection(KerberosChecker.class);
       }
@@ -2906,7 +2916,7 @@ public class KerberosHelperTest extends EasyMockSupport {
       put(DIRECTIVE_COMPONENTS, 
"SERVICE1:COMPONENT1;COMPONENT2,SERVICE2:COMPONENT1;COMPONENT2;COMPONENT3");
     }};
 
-    Set<String> expectedHosts = new HashSet<String>(Arrays.asList("host1", 
"host2", "host3"));
+    Set<String> expectedHosts = new HashSet<>(Arrays.asList("host1", "host2", 
"host3"));
     Set<String> hosts = KerberosHelperImpl.parseHostFilter(requestProperties);
 
     assertEquals(expectedHosts, hosts);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
index 1db61c4..81694e3 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
@@ -59,7 +59,6 @@ import 
org.apache.ambari.server.agent.stomp.HostLevelParamsHolder;
 import org.apache.ambari.server.agent.stomp.TopologyHolder;
 import org.apache.ambari.server.agent.stomp.dto.HostRepositories;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.controller.AbstractRootServiceResponseFactory;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.HostRequest;
@@ -81,12 +80,9 @@ import 
org.apache.ambari.server.metadata.CachedRoleCommandOrderProvider;
 import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.StageDAO;
-import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import 
org.apache.ambari.server.security.authorization.AuthorizationHelperInitializer;
-import org.apache.ambari.server.security.encryption.CredentialStoreService;
-import org.apache.ambari.server.security.encryption.CredentialStoreServiceImpl;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -98,13 +94,8 @@ import org.apache.ambari.server.state.HostHealthStatus;
 import org.apache.ambari.server.state.HostHealthStatus.HealthStatus;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
-import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceComponentHostFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
-import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
-import org.apache.ambari.server.topology.PersistedState;
-import org.apache.ambari.server.topology.PersistedStateImpl;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
@@ -114,15 +105,12 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.crypto.password.StandardPasswordEncoder;
 
 import com.google.gson.Gson;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.persist.UnitOfWork;
 
 /**
  * HostResourceProvider tests.
@@ -1400,38 +1388,28 @@ public class HostResourceProviderTest extends 
EasyMockSupport {
     Injector injector = Guice.createInjector(new AbstractModule() {
       @Override
       protected void configure() {
-        
PartialNiceMockBinder.newBuilder().addConfigsBindings().addFactoriesInstallBinding().build().configure(binder());
+        
PartialNiceMockBinder.newBuilder().addAmbariMetaInfoBinding().addConfigsBindings().addFactoriesInstallBinding().build().configure(binder());
 
         
bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
         bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
         bind(ActionDBAccessor.class).to(ActionDBAccessorImpl.class);
-        
bind(ExecutionScheduler.class).toInstance(createNiceMock(ExecutionScheduler.class));
         bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
         bind(Clusters.class).toInstance(createMock(Clusters.class));
-        
bind(AmbariManagementController.class).toInstance(createMock(AmbariManagementController.class));
         
bind(AmbariMetaInfo.class).toInstance(createNiceMock(AmbariMetaInfo.class));
         bind(Gson.class).toInstance(new Gson());
         
bind(MaintenanceStateHelper.class).toInstance(createNiceMock(MaintenanceStateHelper.class));
         
bind(KerberosHelper.class).toInstance(createNiceMock(KerberosHelper.class));
-        bind(UnitOfWork.class).toInstance(createNiceMock(UnitOfWork.class));
-        bind(PersistedState.class).to(PersistedStateImpl.class);
         
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
         
bind(RoleCommandOrderProvider.class).to(CachedRoleCommandOrderProvider.class);
-        bind(PasswordEncoder.class).toInstance(new StandardPasswordEncoder());
         bind(HookService.class).to(UserHookService.class);
         bind(StageFactory.class).to(StageFactoryImpl.class);
         
bind(AbstractRootServiceResponseFactory.class).to(RootServiceResponseFactory.class);
-        
bind(CredentialStoreService.class).to(CredentialStoreServiceImpl.class);
-        bind(AuditLogger.class).toInstance(createMock(AuditLogger.class));
         bind(StageDAO.class).toInstance(createNiceMock(StageDAO.class));
         
bind(HostLevelParamsHolder.class).toInstance(createNiceMock(HostLevelParamsHolder.class));
         
bind(TopologyHolder.class).toInstance(createNiceMock(TopologyHolder.class));
         
bind(RecoveryConfigHelper.class).toInstance(createNiceMock(RecoveryConfigHelper.class));
 
         install(new FactoryModuleBuilder().build(StackManagerFactory.class));
-        install(new FactoryModuleBuilder().implement(
-            ServiceComponentHost.class, ServiceComponentHostImpl.class).build(
-            ServiceComponentHostFactory.class));
       }
     });
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthenticationSourceResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthenticationSourceResourceProviderTest.java
index 2738b3d..d0956e2 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthenticationSourceResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthenticationSourceResourceProviderTest.java
@@ -42,11 +42,9 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.entities.UserAuthenticationEntity;
 import org.apache.ambari.server.orm.entities.UserEntity;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
@@ -192,8 +190,6 @@ public class UserAuthenticationSourceResourceProviderTest 
extends EasyMockSuppor
         
bind(AmbariMetaInfo.class).toInstance(createMock(AmbariMetaInfo.class));
         bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
         
bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
-        
bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
-        
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
         
bind(PasswordEncoder.class).toInstance(createNiceMock(PasswordEncoder.class));
         bind(Users.class).toInstance(createMock(Users.class));
       }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
index 0439ab3..de7fcbf 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
@@ -37,18 +37,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.persistence.EntityManager;
-
-import org.apache.ambari.server.actionmanager.ActionDBAccessor;
-import org.apache.ambari.server.actionmanager.ActionManager;
-import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
-import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl;
-import org.apache.ambari.server.actionmanager.RequestFactory;
-import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.controller.AbstractRootServiceResponseFactory;
 import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.KerberosHelper;
 import org.apache.ambari.server.controller.ResourceProviderFactory;
 import org.apache.ambari.server.controller.predicate.AndPredicate;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
@@ -63,12 +53,8 @@ import 
org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.hooks.HookContext;
 import org.apache.ambari.server.hooks.HookContextFactory;
 import org.apache.ambari.server.hooks.HookService;
-import org.apache.ambari.server.metadata.CachedRoleCommandOrderProvider;
-import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
-import org.apache.ambari.server.orm.DBAccessor;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.GroupDAO;
-import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.orm.dao.MemberDAO;
 import org.apache.ambari.server.orm.dao.PermissionDAO;
 import org.apache.ambari.server.orm.dao.PrincipalDAO;
@@ -85,31 +71,11 @@ import 
org.apache.ambari.server.orm.entities.PrivilegeEntity;
 import org.apache.ambari.server.orm.entities.ResourceEntity;
 import org.apache.ambari.server.orm.entities.UserAuthenticationEntity;
 import org.apache.ambari.server.orm.entities.UserEntity;
-import org.apache.ambari.server.registry.RegistryFactory;
-import org.apache.ambari.server.registry.RegistryManager;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
-import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.UserAuthenticationType;
-import org.apache.ambari.server.security.encryption.CredentialStoreService;
-import org.apache.ambari.server.security.encryption.CredentialStoreServiceImpl;
-import org.apache.ambari.server.stack.StackManagerFactory;
-import org.apache.ambari.server.stageplanner.RoleGraphFactory;
-import org.apache.ambari.server.state.ClusterSettingFactory;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ConfigFactory;
-import org.apache.ambari.server.state.ServiceComponentFactory;
-import org.apache.ambari.server.state.ServiceComponentHostFactory;
-import org.apache.ambari.server.state.ServiceFactory;
-import org.apache.ambari.server.state.ServiceGroupFactory;
-import org.apache.ambari.server.state.UpgradeContextFactory;
-import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
-import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
-import org.apache.ambari.server.state.stack.OsFamily;
-import org.apache.ambari.server.topology.PersistedState;
-import org.apache.ambari.server.topology.PersistedStateImpl;
-import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.testutils.PartialNiceMockBinder;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.apache.commons.lang.StringUtils;
 import org.easymock.Capture;
@@ -122,13 +88,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.crypto.password.PasswordEncoder;
 
-import com.google.inject.AbstractModule;
+import com.google.inject.Binder;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
-import com.google.inject.Provider;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.Module;
 
 /**
  * UserResourceProvider tests.
@@ -387,64 +351,7 @@ public class UserResourceProviderTest extends 
EasyMockSupport {
   }
 
   private Injector createInjector() throws Exception {
-    return Guice.createInjector(new AbstractModule() {
-      @Override
-      protected <T> Provider<T> getProvider(Class<T> type) {
-        return super.getProvider(type);
-      }
-
-      @Override
-      protected void configure() {
-        install(new FactoryModuleBuilder().build(UpgradeContextFactory.class));
-        install(new FactoryModuleBuilder().build(RoleGraphFactory.class));
-        install(new 
FactoryModuleBuilder().build(ConfigureClusterTaskFactory.class));
-
-        bind(EntityManager.class).toInstance(createMock(EntityManager.class));
-        bind(DBAccessor.class).toInstance(createMock(DBAccessor.class));
-        
bind(ActionDBAccessor.class).toInstance(createMock(ActionDBAccessor.class));
-        
bind(ExecutionScheduler.class).toInstance(createMock(ExecutionScheduler.class));
-        bind(OsFamily.class).toInstance(createMock(OsFamily.class));
-        
bind(AmbariMetaInfo.class).toInstance(createMock(AmbariMetaInfo.class));
-        bind(ActionManager.class).toInstance(createMock(ActionManager.class));
-        
bind(RequestFactory.class).toInstance(createMock(RequestFactory.class));
-        
bind(RequestExecutionFactory.class).toInstance(createMock(RequestExecutionFactory.class));
-        bind(StageFactory.class).toInstance(createMock(StageFactory.class));
-        bind(Clusters.class).toInstance(createMock(Clusters.class));
-        
bind(AbstractRootServiceResponseFactory.class).toInstance(createMock(AbstractRootServiceResponseFactory.class));
-        
bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
-        bind(ConfigFactory.class).toInstance(createMock(ConfigFactory.class));
-        
bind(ConfigGroupFactory.class).toInstance(createMock(ConfigGroupFactory.class));
-        
bind(ServiceGroupFactory.class).toInstance(createNiceMock(ServiceGroupFactory.class));
-        
bind(ServiceFactory.class).toInstance(createMock(ServiceFactory.class));
-        
bind(ServiceComponentFactory.class).toInstance(createMock(ServiceComponentFactory.class));
-        
bind(ServiceComponentHostFactory.class).toInstance(createMock(ServiceComponentHostFactory.class));
-        
bind(PasswordEncoder.class).toInstance(createMock(PasswordEncoder.class));
-        
bind(KerberosHelper.class).toInstance(createMock(KerberosHelper.class));
-        
bind(AmbariManagementController.class).toInstance(createMock(AmbariManagementController.class));
-        
bind(RoleCommandOrderProvider.class).to(CachedRoleCommandOrderProvider.class);
-        
bind(CredentialStoreService.class).to(CredentialStoreServiceImpl.class);
-        
bind(HostRoleCommandDAO.class).toInstance(createMock(HostRoleCommandDAO.class));
-        bind(HookService.class).toInstance(createMock(HookService.class));
-        
bind(HookContextFactory.class).toInstance(createMock(HookContextFactory.class));
-        
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
-        
bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
-        
bind(RegistryFactory.class).toInstance(createNiceMock(RegistryFactory.class));
-        
bind(RegistryManager.class).toInstance(createNiceMock(RegistryManager.class));
-        
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
-        
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
-        bind(PersistedState.class).to(PersistedStateImpl.class);
-        bind(UserDAO.class).toInstance(createMock(UserDAO.class));
-
-        
bind(UserAuthenticationDAO.class).toInstance(createMock(UserAuthenticationDAO.class));
-        bind(GroupDAO.class).toInstance(createMock(GroupDAO.class));
-        bind(MemberDAO.class).toInstance(createMock(MemberDAO.class));
-        bind(PrincipalDAO.class).toInstance(createMock(PrincipalDAO.class));
-        bind(PermissionDAO.class).toInstance(createMock(PermissionDAO.class));
-        bind(PrivilegeDAO.class).toInstance(createMock(PrivilegeDAO.class));
-        bind(ResourceDAO.class).toInstance(createMock(ResourceDAO.class));
-        
bind(PrincipalTypeDAO.class).toInstance(createMock(PrincipalTypeDAO.class));
-      }
-    });
+    return Guice.createInjector(new MockModule());
   }
 
 
@@ -905,4 +812,37 @@ public class UserResourceProviderTest extends 
EasyMockSupport {
     injector.injectMembers(resourceProvider);
     return resourceProvider;
   }
+
+  /**
+  *
+  */
+ private class MockModule implements Module {
+   /**
+    *
+    */
+   @Override
+   public void configure(Binder binder) {
+     Cluster cluster = createNiceMock(Cluster.class);
+
+     
PartialNiceMockBinder.newBuilder(UserResourceProviderTest.this).addConfigsBindings()
+         .addDBAccessorBinding()
+         .addFactoriesInstallBinding()
+         .addAmbariMetaInfoBinding()
+         .build().configure(binder);
+
+      binder.bind(UserDAO.class).toInstance(createMock(UserDAO.class));
+      
binder.bind(UserAuthenticationDAO.class).toInstance(createMock(UserAuthenticationDAO.class));
+      binder.bind(GroupDAO.class).toInstance(createMock(GroupDAO.class));
+      binder.bind(MemberDAO.class).toInstance(createMock(MemberDAO.class));
+      
binder.bind(PrincipalDAO.class).toInstance(createMock(PrincipalDAO.class));
+      
binder.bind(PermissionDAO.class).toInstance(createMock(PermissionDAO.class));
+      
binder.bind(PrivilegeDAO.class).toInstance(createMock(PrivilegeDAO.class));
+      binder.bind(ResourceDAO.class).toInstance(createMock(ResourceDAO.class));
+      
binder.bind(PrincipalTypeDAO.class).toInstance(createMock(PrincipalTypeDAO.class));
+
+      
binder.bind(AmbariMetaInfo.class).toInstance(createNiceMock(AmbariMetaInfo.class));
+      binder.bind(Cluster.class).toInstance(cluster);
+      
binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
+    }
+ }
 }
\ No newline at end of file
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/KerberosKeytabsActionTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/KerberosKeytabsActionTest.java
index 1f86c68..9c55eec 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/KerberosKeytabsActionTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/KerberosKeytabsActionTest.java
@@ -35,10 +35,8 @@ import org.apache.ambari.server.agent.CommandReport;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.KerberosHelper;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.StackDAO;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -103,8 +101,6 @@ public class KerberosKeytabsActionTest {
         
bind(OsFamily.class).toInstance(EasyMock.createNiceMock(OsFamily.class));
         
bind(UpgradeHelper.class).toInstance(EasyMock.createNiceMock(UpgradeHelper.class));
         
bind(StackManagerFactory.class).toInstance(EasyMock.createNiceMock(StackManagerFactory.class));
-        
bind(MpackManagerFactory.class).toInstance(EasyMock.createNiceMock(MpackManagerFactory.class));
-        
bind(RootLevelSettingsManagerFactory.class).toInstance(EasyMock.createNiceMock(RootLevelSettingsManagerFactory.class));
         
bind(StackDAO.class).toInstance(EasyMock.createNiceMock(StackDAO.class));
         
bind(EntityManager.class).toInstance(EasyMock.createNiceMock(EntityManager.class));
         
bind(DBAccessor.class).toInstance(EasyMock.createNiceMock(DBAccessor.class));
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosActionTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosActionTest.java
index a4061b8..d371009 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosActionTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosActionTest.java
@@ -56,14 +56,11 @@ import 
org.apache.ambari.server.actionmanager.ActionDBAccessorImpl;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl;
-import org.apache.ambari.server.actionmanager.RequestFactory;
-import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorHelper;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
 import 
org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
-import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AbstractRootServiceResponseFactory;
 import org.apache.ambari.server.controller.AmbariCustomCommandExecutionHelper;
@@ -81,7 +78,6 @@ import org.apache.ambari.server.hooks.users.UserCreatedEvent;
 import org.apache.ambari.server.hooks.users.UserHookService;
 import org.apache.ambari.server.metadata.CachedRoleCommandOrderProvider;
 import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.ArtifactDAO;
 import org.apache.ambari.server.orm.dao.HostDAO;
@@ -92,17 +88,13 @@ import 
org.apache.ambari.server.orm.entities.KerberosKeytabEntity;
 import org.apache.ambari.server.orm.entities.KerberosKeytabPrincipalEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
-import org.apache.ambari.server.security.encryption.CredentialStoreService;
 import org.apache.ambari.server.stack.StackManagerFactory;
-import org.apache.ambari.server.stageplanner.RoleGraphFactory;
 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.Config;
-import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostComponentAdminState;
@@ -112,7 +104,6 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceComponentHostFactory;
 import org.apache.ambari.server.state.ServiceComponentImpl;
 import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.ServiceImpl;
@@ -129,14 +120,10 @@ import org.apache.ambari.server.state.host.HostFactory;
 import org.apache.ambari.server.state.host.HostImpl;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptorFactory;
-import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
-import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
-import org.apache.ambari.server.topology.PersistedState;
 import org.apache.ambari.server.topology.TopologyManager;
-import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.commons.collections.MapUtils;
 import org.easymock.Capture;
@@ -145,8 +132,6 @@ import org.easymock.IAnswer;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.crypto.password.StandardPasswordEncoder;
 
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
@@ -613,42 +598,29 @@ public class PreconfigureKerberosActionTest extends 
EasyMockSupport {
     return Guice.createInjector(new AbstractModule() {
       @Override
       protected void configure() {
-        PartialNiceMockBinder.newBuilder(PreconfigureKerberosActionTest.this)
+        PartialNiceMockBinder.newBuilder(
+            PreconfigureKerberosActionTest.this).addAmbariMetaInfoBinding()
             .addActionDBAccessorConfigsBindings().build().configure(binder());
 
         bind(EntityManager.class).toInstance(createMock(EntityManager.class));
         bind(DBAccessor.class).toInstance(createMock(DBAccessor.class));
-        
bind(UpgradeContextFactory.class).toInstance(createMock(UpgradeContextFactory.class));
         bind(OsFamily.class).toInstance(createMock(OsFamily.class));
         
bind(StackManagerFactory.class).toInstance(createMock(StackManagerFactory.class));
-        
bind(MpackManagerFactory.class).toInstance(createMock(MpackManagerFactory.class));
-        
bind(RootLevelSettingsManagerFactory.class).toInstance(createMock(RootLevelSettingsManagerFactory.class));
-        bind(StageFactory.class).toInstance(createMock(StageFactory.class));
         
bind(AmbariMetaInfo.class).toInstance(createMock(AmbariMetaInfo.class));
         
bind(AmbariCustomCommandExecutionHelper.class).toInstance(createMock(AmbariCustomCommandExecutionHelper.class));
         bind(ActionManager.class).toInstance(createMock(ActionManager.class));
         
bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
-        bind(AuditLogger.class).toInstance(createNiceMock(AuditLogger.class));
         bind(ArtifactDAO.class).toInstance(createNiceMock(ArtifactDAO.class));
         
bind(KerberosPrincipalDAO.class).toInstance(createNiceMock(KerberosPrincipalDAO.class));
         
bind(RoleCommandOrderProvider.class).to(CachedRoleCommandOrderProvider.class);
         
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
         
bind(RoleCommandOrderProvider.class).to(CachedRoleCommandOrderProvider.class);
         
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
-        
bind(RoleGraphFactory.class).toInstance(createMock(RoleGraphFactory.class));
-        
bind(RequestFactory.class).toInstance(createMock(RequestFactory.class));
-        
bind(RequestExecutionFactory.class).toInstance(createMock(RequestExecutionFactory.class));
-        
bind(CredentialStoreService.class).toInstance(createMock(CredentialStoreService.class));
         
bind(TopologyManager.class).toInstance(createNiceMock(TopologyManager.class));
-        bind(ConfigFactory.class).toInstance(createMock(ConfigFactory.class));
-        
bind(PersistedState.class).toInstance(createMock(PersistedState.class));
-        
bind(ConfigureClusterTaskFactory.class).toInstance(createNiceMock(ConfigureClusterTaskFactory.class));
         bind(Configuration.class).toInstance(new Configuration(new 
Properties()));
-        bind(PasswordEncoder.class).toInstance(new StandardPasswordEncoder());
         bind(HookService.class).to(UserHookService.class);
         
bind(AbstractRootServiceResponseFactory.class).to(RootServiceResponseFactory.class);
 
-        
bind(AmbariManagementController.class).toInstance(createMock(AmbariManagementController.class));
         bind(KerberosHelper.class).to(KerberosHelperImpl.class);
         bind(Clusters.class).toInstance(createMock(Clusters.class));
         
bind(StackAdvisorHelper.class).toInstance(createMock(StackAdvisorHelper.class));
@@ -660,9 +632,6 @@ public class PreconfigureKerberosActionTest extends 
EasyMockSupport {
         install(new FactoryModuleBuilder().implement(HookContext.class, 
PostUserCreationHookContext.class)
             .build(HookContextFactory.class));
         install(new FactoryModuleBuilder().implement(
-            ServiceComponentHost.class, ServiceComponentHostImpl.class).build(
-            ServiceComponentHostFactory.class));
-        install(new FactoryModuleBuilder().implement(
             ServiceComponent.class, ServiceComponentImpl.class).build(
             ServiceComponentFactory.class));
         install(new FactoryModuleBuilder().implement(
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/PostUserCreationHookServerActionTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/PostUserCreationHookServerActionTest.java
index 45f9e99..4e1ab16 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/PostUserCreationHookServerActionTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/PostUserCreationHookServerActionTest.java
@@ -46,8 +46,6 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 
@@ -56,8 +54,6 @@ import com.google.common.collect.Maps;
  */
 public class PostUserCreationHookServerActionTest extends EasyMockSupport {
 
-  private static final Logger LOGGER = 
LoggerFactory.getLogger(PostUserCreationHookServerActionTest.class);
-
   @Rule
   public EasyMockRule mocks = new EasyMockRule(this);
 
@@ -117,6 +113,7 @@ public class PostUserCreationHookServerActionTest extends 
EasyMockSupport {
     commandParams.put(UserHookParams.CLUSTER_SECURITY_TYPE.param(), 
SecurityType.KERBEROS.name());
     commandParams.put(UserHookParams.CMD_HDFS_USER.param(), "test-hdfs-user");
 
+    EasyMock.expect(executionCommand.getMpackId()).andReturn(1L);
     
EasyMock.expect(executionCommand.getCommandParams()).andReturn(commandParams);
     EasyMock.expect(objectMapperMock.readValue(payloadJson, 
Map.class)).andReturn(payload);
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
index 6fe41cc..b169e15 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
@@ -121,10 +121,10 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.START, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     log.info("Build and ready to detect circular dependencies - short chain");
     rg.build(stage);
     boolean exceptionThrown = false;
@@ -160,13 +160,13 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.STOP, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.STOP, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     stage.addHostRoleExecutionCommand("host2", Role.RESOURCEMANAGER,
         RoleCommand.STOP, new ServiceComponentHostStartEvent("RESOURCEMANAGER",
-            "host4", now), "cluster1", "core", "YARN", false, false);
+            "host4", now), "cluster1", 1L, "core", "YARN", false, false);
 
     log.info("Build and ready to detect circular dependencies - long chain");
     rg.build(stage);
@@ -200,13 +200,13 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.UPGRADE, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.UPGRADE, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_REGIONSERVER,
         RoleCommand.UPGRADE, new 
ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
-            "host4", now), "cluster1", "core", "HBASE", false, false);
+            "host4", now), "cluster1", 1L, "core", "HBASE", false, false);
 
     log.info("Build and ready to detect circular dependencies - long chain");
     rg.build(stage);
@@ -240,13 +240,13 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.STOP, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.STOP, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_REGIONSERVER,
         RoleCommand.STOP, new 
ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
-            "host4", now), "cluster1", "core", "HBASE", false, false);
+            "host4", now), "cluster1", 1L, "core", "HBASE", false, false);
     log.info("Build and ready to detect circular dependencies");
     rg.build(stage);
     boolean exceptionThrown = false;
@@ -280,10 +280,10 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.START, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     log.info(stage.toString());
 
     rg.build(stage);
@@ -375,37 +375,37 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host11", Role.SECONDARY_NAMENODE,
         RoleCommand.START, new 
ServiceComponentHostStartEvent("SECONDARY_NAMENODE",
-            "host11", now), "cluster1", "core", "HDFS", false, false);
+            "host11", now), "cluster1", 1L, "core", "HDFS", false, false);
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
         RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
-            "host2", now), "cluster1", "core", "HBASE", false, false);
+            "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
         RoleCommand.START, new 
ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-            "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+            "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.DATANODE,
         RoleCommand.START, new ServiceComponentHostStartEvent("DATANODE",
-            "host4", now), "cluster1", "core", "HDFS", false, false);
+            "host4", now), "cluster1", 1L, "core", "HDFS", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.HBASE_REGIONSERVER,
         RoleCommand.START, new 
ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
-            "host4", now), "cluster1", "core", "HBASE", false, false);
+            "host4", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.TASKTRACKER,
         RoleCommand.START, new ServiceComponentHostStartEvent("TASKTRACKER",
-            "host4", now), "cluster1", "core", "MAPREDUCE", false, false);
+            "host4", now), "cluster1", 1L, "core", "MAPREDUCE", false, false);
     stage.addHostRoleExecutionCommand("host5", Role.JOBTRACKER,
         RoleCommand.START, new ServiceComponentHostStartEvent("JOBTRACKER",
-            "host5", now), "cluster1", "core", "MAPREDUCE", false, false);
+            "host5", now), "cluster1", 1L, "core", "MAPREDUCE", false, false);
     stage.addHostRoleExecutionCommand("host6", Role.OOZIE_SERVER,
         RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
-            "host6", now), "cluster1", "core", "OOZIE", false, false);
+            "host6", now), "cluster1", 1L, "core", "OOZIE", false, false);
     stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
-        "host7", now), "cluster1", "core", "WEBHCAT", false, false);
+        "host7", now), "cluster1", 1L, "core", "WEBHCAT", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
       RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
-        "host4", now), "cluster1", "core", "GANGLIA", false, false);
+        "host4", now), "cluster1", 1L, "core", "GANGLIA", false, false);
     stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
-        "host9", now), "cluster1", "core", "GANGLIA", false, false);
+        "host9", now), "cluster1", 1L, "core", "GANGLIA", false, false);
 
     log.info(stage.toString());
     rg.build(stage);
@@ -428,37 +428,37 @@ public class TestStagePlanner {
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
     stage.addHostRoleExecutionCommand("host11", Role.SECONDARY_NAMENODE,
       RoleCommand.START, new 
ServiceComponentHostStartEvent("SECONDARY_NAMENODE",
-        "host11", now), "cluster1", "core", "HDFS", false, false);
+        "host11", now), "cluster1", 1L, "core", "HDFS", false, false);
     stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
       RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
-        "host2", now), "cluster1", "core", "HBASE", false, false);
+        "host2", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
-        "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
+        "host3", now), "cluster1", 1L, "core", "ZOOKEEPER", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.DATANODE,
       RoleCommand.START, new ServiceComponentHostStartEvent("DATANODE",
-        "host4", now), "cluster1", "core", "HDFS", false, false);
+        "host4", now), "cluster1", 1L, "core", "HDFS", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.HBASE_REGIONSERVER,
       RoleCommand.START, new 
ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
-        "host4", now), "cluster1", "core", "HBASE", false, false);
+        "host4", now), "cluster1", 1L, "core", "HBASE", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.TASKTRACKER,
       RoleCommand.START, new ServiceComponentHostStartEvent("TASKTRACKER",
-        "host4", now), "cluster1", "core", "MAPREDUCE", false, false);
+        "host4", now), "cluster1", 1L, "core", "MAPREDUCE", false, false);
     stage.addHostRoleExecutionCommand("host5", Role.JOBTRACKER,
       RoleCommand.START, new ServiceComponentHostStartEvent("JOBTRACKER",
-        "host5", now), "cluster1", "core", "MAPREDUCE", false, false);
+        "host5", now), "cluster1", 1L, "core", "MAPREDUCE", false, false);
     stage.addHostRoleExecutionCommand("host6", Role.OOZIE_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
-        "host6", now), "cluster1", "core", "OOZIE", false, false);
+        "host6", now), "cluster1", 1L, "core", "OOZIE", false, false);
     stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
-        "host7", now), "cluster1", "core", "WEBHCAT", false, false);
+        "host7", now), "cluster1", 1L, "core", "WEBHCAT", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
       RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
-        "host4", now), "cluster1", "core", "GANGLIA", false, false);
+        "host4", now), "cluster1", 1L, "core", "GANGLIA", false, false);
     stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
       RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
-        "host9", now), "cluster1", "core", "GANGLIA", false, false);
+        "host9", now), "cluster1", 1L, "core", "GANGLIA", false, false);
     log.info(stage.toString());
     rg.build(stage);
     log.info(rg.stringifyGraph());
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index ca2e599..7b4bb4d 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -53,6 +53,7 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.registry.RegistryManager;
 import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.security.SecurityHelper;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
@@ -61,6 +62,8 @@ import org.apache.ambari.server.state.configgroup.ConfigGroup;
 import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
+import org.apache.ambari.server.topology.ComponentResolver;
+import org.apache.ambari.server.topology.StackFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -1100,7 +1103,11 @@ public class ConfigHelperTest {
           
bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
           
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
           
bind(StateUpdateEventPublisher.class).toInstance(createNiceMock(StateUpdateEventPublisher.class));
-
+          
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
+          
bind(RegistryManager.class).toInstance(createNiceMock(RegistryManager.class));
+          
bind(ComponentResolver.class).toInstance(createNiceMock(ComponentResolver.class));
+          
bind(ServiceGroupFactory.class).toInstance(createNiceMock(ServiceGroupFactory.class));
+          
bind(StackFactory.class).toInstance(createNiceMock(StackFactory.class));
         }
       });
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 78218b3..06b071d 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -67,6 +67,7 @@ import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.HostStateEntity;
+import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
 import org.apache.ambari.server.orm.entities.ServiceGroupEntity;
@@ -178,8 +179,8 @@ public class ClusterTest {
 
   private void createDefaultCluster(Set<String> hostNames, StackId stackId) 
throws Exception {
     // TODO, use common function
-    StackEntity stackEntity = stackDAO.find(stackId.getStackName(), 
stackId.getStackVersion());
-    org.junit.Assert.assertNotNull(stackEntity);
+    MpackEntity mpackEntity = helper.createMpack(stackId);
+    assertNotNull(mpackEntity);
 
     String clusterName = "c1";
 
@@ -189,8 +190,6 @@ public class ClusterTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "5.9");
 
-    helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
-
     for (String hostName : hostNames) {
       clusters.addHost(hostName);
 
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java
index 59aeaca..0e5d07e 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java
@@ -41,21 +41,16 @@ import java.util.Vector;
 import java.util.concurrent.Executor;
 
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.notifications.DispatchFactory;
 import org.apache.ambari.server.notifications.Notification;
 import org.apache.ambari.server.notifications.NotificationDispatcher;
 import org.apache.ambari.server.notifications.TargetConfigurationResult;
 import org.apache.ambari.server.notifications.dispatchers.AmbariSNMPDispatcher;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.AlertDispatchDAO;
-import org.apache.ambari.server.orm.dao.AlertsDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.AlertHistoryEntity;
 import org.apache.ambari.server.orm.entities.AlertNoticeEntity;
 import org.apache.ambari.server.orm.entities.AlertTargetEntity;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
-import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.AlertState;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.NotificationState;
@@ -408,7 +403,7 @@ public class AlertNoticeDispatchServiceTest extends 
AlertNoticeDispatchService {
     List<Vector> expectedTrapVectors = new LinkedList<>();
     Vector firstVector = new Vector();
     firstVector.add(new VariableBinding(SnmpConstants.sysUpTime, new 
TimeTicks(360000L)));
-    firstVector.add(new VariableBinding(SnmpConstants.snmpTrapOID, new 
OID(AmbariSNMPDispatcher.AMBARI_ALERT_TRAP_OID)));    
+    firstVector.add(new VariableBinding(SnmpConstants.snmpTrapOID, new 
OID(AmbariSNMPDispatcher.AMBARI_ALERT_TRAP_OID)));
     firstVector.add(new VariableBinding(new 
OID(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_ID_OID), new Integer32(new 
BigDecimal(1L).intValueExact())));
     firstVector.add(new VariableBinding(new 
OID(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_NAME_OID), new 
OctetString("alert-definition-1")));
     firstVector.add(new VariableBinding(new 
OID(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_HASH_OID), new 
OctetString("1")));
@@ -790,18 +785,11 @@ public class AlertNoticeDispatchServiceTest extends 
AlertNoticeDispatchService {
     @Override
     public void configure(Binder binder) {
       Cluster cluster = EasyMock.createNiceMock(Cluster.class);
-      
PartialNiceMockBinder.newBuilder().addDBAccessorBinding().addAmbariMetaInfoBinding().build().configure(binder);
+      
PartialNiceMockBinder.newBuilder().addDBAccessorBinding().addAmbariMetaInfoBinding(
+          m_metaInfo).build().configure(binder);
 
       binder.bind(AlertDispatchDAO.class).toInstance(m_dao);
       binder.bind(DispatchFactory.class).toInstance(m_dispatchFactory);
-      
binder.bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
-      
binder.bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
-      
binder.bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
-      binder.bind(AmbariMetaInfo.class).toInstance(m_metaInfo);
-      binder.bind(Cluster.class).toInstance(cluster);
-      
binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
-      binder.bind(AlertsDAO.class).toInstance(createNiceMock(AlertsDAO.class));
-
       binder.bind(AlertNoticeDispatchService.class).toInstance(new 
AlertNoticeDispatchService());
 
       
EasyMock.expect(m_metaInfo.getServerVersion()).andReturn("2.0.0").anyTimes();
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/services/CachedAlertFlushServiceTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/services/CachedAlertFlushServiceTest.java
index b7ac2d4..4d90dab 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/services/CachedAlertFlushServiceTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/services/CachedAlertFlushServiceTest.java
@@ -20,9 +20,7 @@ package org.apache.ambari.server.state.services;
 import static org.easymock.EasyMock.expect;
 
 import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.AlertsDAO;
-import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
@@ -117,8 +115,6 @@ public class CachedAlertFlushServiceTest extends 
EasyMockSupport {
      */
     @Override
     public void configure(Binder binder) {
-      Cluster cluster = EasyMock.createNiceMock(Cluster.class);
-
       // required for since the configuration is being mocked
       Configuration configuration = createNiceMock(Configuration.class);
       
expect(configuration.getAlertEventPublisherCorePoolSize()).andReturn(Integer.valueOf(Configuration.ALERTS_EXECUTION_SCHEDULER_THREADS_CORE_SIZE.getDefaultValue())).anyTimes();
@@ -128,11 +124,9 @@ public class CachedAlertFlushServiceTest extends 
EasyMockSupport {
 
       EasyMock.replay(configuration);
 
-      
PartialNiceMockBinder.newBuilder().addDBAccessorBinding().addAlertDefinitionDAOBinding().build().configure(binder);
+      
PartialNiceMockBinder.newBuilder().addAlertDefinitionBinding().build().configure(binder);
 
       binder.bind(Configuration.class).toInstance(configuration);
-      binder.bind(Cluster.class).toInstance(cluster);
-      
binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
       binder.bind(AlertsDAO.class).toInstance(createNiceMock(AlertsDAO.class));
     }
   }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/testutils/PartialNiceMockBinder.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/testutils/PartialNiceMockBinder.java
index fd7ca49..108d59a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/testutils/PartialNiceMockBinder.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/testutils/PartialNiceMockBinder.java
@@ -31,6 +31,7 @@ import 
org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl;
 import org.apache.ambari.server.actionmanager.RequestFactory;
 import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.actionmanager.StageFactoryImpl;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.audit.AuditLoggerDefaultImpl;
 import org.apache.ambari.server.controller.AbstractRootServiceResponseFactory;
@@ -46,16 +47,20 @@ import 
org.apache.ambari.server.hooks.users.UserCreatedEvent;
 import org.apache.ambari.server.hooks.users.UserHookService;
 import org.apache.ambari.server.metadata.CachedRoleCommandOrderProvider;
 import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
+import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.DaoUtils;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.registry.RegistryManager;
+import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.stageplanner.RoleGraphFactory;
 import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.ClusterSettingFactory;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigFactory;
@@ -67,6 +72,7 @@ import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHostFactory;
 import org.apache.ambari.server.state.ServiceComponentImpl;
 import org.apache.ambari.server.state.ServiceFactory;
+import org.apache.ambari.server.state.ServiceGroupFactory;
 import org.apache.ambari.server.state.ServiceImpl;
 import org.apache.ambari.server.state.UpgradeContextFactory;
 import org.apache.ambari.server.state.cluster.ClusterFactory;
@@ -80,7 +86,9 @@ import 
org.apache.ambari.server.state.scheduler.RequestExecution;
 import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
 import org.apache.ambari.server.state.scheduler.RequestExecutionImpl;
 import org.apache.ambari.server.state.stack.OsFamily;
+import org.apache.ambari.server.topology.ComponentResolver;
 import org.apache.ambari.server.topology.PersistedState;
+import org.apache.ambari.server.topology.StackFactory;
 import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
 import org.easymock.EasyMockSupport;
 import org.springframework.security.crypto.password.PasswordEncoder;
@@ -121,7 +129,7 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addAlertDefinitionBinding() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           binder.bind(Cluster.class).toInstance(createNiceMock(Cluster.class));
           
binder.bind(DaoUtils.class).toInstance(createNiceMock(DaoUtils.class));
           
binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
@@ -131,8 +139,21 @@ public class PartialNiceMockBinder implements Module {
       return this;
     }
 
+    public Builder addAmbariContextBindings() {
+      configurers.add((Binder binder) -> {
+          
binder.bind(MpackManagerFactory.class).toInstance(easyMockSupport.createNiceMock(MpackManagerFactory.class));
+          
binder.bind(RootLevelSettingsManagerFactory.class).toInstance(easyMockSupport.createNiceMock(RootLevelSettingsManagerFactory.class));
+          
binder.bind(ComponentResolver.class).toInstance(easyMockSupport.createNiceMock(ComponentResolver.class));
+          
binder.bind(ClusterSettingFactory.class).toInstance(easyMockSupport.createNiceMock(ClusterSettingFactory.class));
+          
binder.bind(RegistryManager.class).toInstance(easyMockSupport.createNiceMock(RegistryManager.class));
+          
binder.bind(ServiceGroupFactory.class).toInstance(easyMockSupport.createNiceMock(ServiceGroupFactory.class));
+          
binder.bind(StackFactory.class).toInstance(easyMockSupport.createNiceMock(StackFactory.class));
+      });
+      return this;
+    }
+
     public Builder addAmbariMetaInfoBinding(AmbariManagementController 
ambariManagementController) {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           
binder.bind(PersistedState.class).toInstance(easyMockSupport.createNiceMock(PersistedState.class));
           
binder.bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
           binder.bind(ActionDBAccessor.class).to(ActionDBAccessorImpl.class);
@@ -150,6 +171,7 @@ public class PartialNiceMockBinder implements Module {
       });
       addConfigsBindings();
       addFactoriesInstallBinding();
+      addAmbariContextBindings();
       return this;
     }
 
@@ -157,9 +179,12 @@ public class PartialNiceMockBinder implements Module {
       return 
addAmbariMetaInfoBinding(easyMockSupport.createNiceMock(AmbariManagementController.class));
     }
 
-    public Builder addAlertDefinitionDAOBinding() {
-      addAmbariMetaInfoBinding();
-      return this;
+    public Builder addAmbariMetaInfoBinding(AmbariMetaInfo ambariMetaInfo) {
+      configurers.add((Binder binder) -> {
+        binder.bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
+      });
+
+      return 
addAmbariMetaInfoBinding(easyMockSupport.createNiceMock(AmbariManagementController.class));
     }
 
     public Builder addClustersBinding(AmbariManagementController 
ambariManagementController) {
@@ -173,7 +198,7 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addDBAccessorBinding(DBAccessor dbAccessor) {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           
binder.bind(StackManagerFactory.class).toInstance(easyMockSupport.createNiceMock(StackManagerFactory.class));
           
binder.bind(EntityManager.class).toInstance(easyMockSupport.createNiceMock(EntityManager.class));
           binder.bind(DBAccessor.class).toInstance(dbAccessor);
@@ -184,7 +209,7 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addDBAccessorBinding() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           
binder.bind(StackManagerFactory.class).toInstance(easyMockSupport.createNiceMock(StackManagerFactory.class));
           
binder.bind(EntityManager.class).toInstance(easyMockSupport.createNiceMock(EntityManager.class));
           
binder.bind(DBAccessor.class).toInstance(easyMockSupport.createNiceMock(DBAccessor.class));
@@ -202,7 +227,7 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addHostRoleCommandsConfigsBindings() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           
binder.bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_ENABLED)).to(true);
           
binder.bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_SIZE)).to(10000L);
           
binder.bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES)).to(30L);
@@ -211,7 +236,7 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addActionSchedulerConfigsBindings() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           
binder.bindConstant().annotatedWith(Names.named("actionTimeout")).to(600000L);
           
binder.bindConstant().annotatedWith(Names.named("schedulerSleeptime")).to(1L);
       });
@@ -219,14 +244,14 @@ public class PartialNiceMockBinder implements Module {
     }
 
     public Builder addActionDBAccessorConfigsBindings() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) ->
+      configurers.add((Binder binder) ->
           
binder.bindConstant().annotatedWith(Names.named("executionCommandCacheSize")).to(10000L)
       );
       return this;
     }
 
     public Builder addFactoriesInstallBinding() {
-      PartialNiceMockBinder.this.configurers.add((Binder binder) -> {
+      configurers.add((Binder binder) -> {
           binder.install(new 
FactoryModuleBuilder().build(ConfigureClusterTaskFactory.class));
           binder.install(new FactoryModuleBuilder().implement(Config.class, 
ConfigImpl.class).build(ConfigFactory.class));
           binder.install(new 
FactoryModuleBuilder().build(RequestFactory.class));
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
index 13d2a1b..380e431 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
@@ -53,26 +53,17 @@ import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.mpack.MpackManagerFactory;
 import org.apache.ambari.server.orm.dao.HostDAO;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
-import org.apache.ambari.server.registry.RegistryManager;
-import org.apache.ambari.server.resources.RootLevelSettingsManagerFactory;
 import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.ClusterSettingFactory;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceGroupFactory;
 import org.apache.ambari.server.state.UpgradeContextFactory;
 import org.apache.ambari.server.testutils.PartialNiceMockBinder;
-import org.apache.ambari.server.topology.ComponentResolver;
-import org.apache.ambari.server.topology.DefaultStackFactory;
-import org.apache.ambari.server.topology.StackComponentResolver;
-import org.apache.ambari.server.topology.StackFactory;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.topology.validators.BasicBlueprintValidator;
 import org.apache.ambari.server.topology.validators.BlueprintValidator;
@@ -114,14 +105,7 @@ public class StageUtilsTest extends EasyMockSupport {
         
bind(TopologyManager.class).toInstance(createNiceMock(TopologyManager.class));
         bind(HostDAO.class).toInstance(createNiceMock(HostDAO.class));
         
bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
-        
bind(MpackManagerFactory.class).toInstance(createNiceMock(MpackManagerFactory.class));
-        
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
-        bind(ComponentResolver.class).to(StackComponentResolver.class);
         bind(BlueprintValidator.class).to(BasicBlueprintValidator.class);
-        bind(StackFactory.class).to(DefaultStackFactory.class);
-        
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
-        
bind(RegistryManager.class).toInstance(createNiceMock(RegistryManager.class));
-        
bind(ServiceGroupFactory.class).toInstance(createNiceMock(ServiceGroupFactory.class));
         install(new 
FactoryModuleBuilder().build(ExecutionCommandWrapperFactory.class));
         install(new FactoryModuleBuilder().build(UpgradeContextFactory.class));
       }

-- 
To stop receiving notification emails like this one, please contact
jonathanhur...@apache.org.

Reply via email to