ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From magyari_san...@apache.org
Subject [45/50] ambari git commit: AMBARI-17228. Blueprint deployments should support a START_ONLY provision_action for clusters (magyari_sandor)
Date Mon, 12 Sep 2016 11:54:09 GMT
AMBARI-17228. Blueprint deployments should support a START_ONLY provision_action for clusters (magyari_sandor)


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

Branch: refs/heads/AMBARI-2.4.0.2
Commit: 930613ec8e8b523c5544142760f5642ab8210ee5
Parents: 3a60e8c
Author: Sandor Magyari <smagyari@hortonworks.com>
Authored: Wed Sep 7 17:56:44 2016 +0200
Committer: Sandor Magyari <smagyari@hortonworks.com>
Committed: Fri Sep 9 15:15:19 2016 +0200

----------------------------------------------------------------------
 .../server/configuration/Configuration.java     |   9 -
 .../AmbariManagementControllerImpl.java         |  31 +-
 .../internal/HostComponentResourceProvider.java |   9 +-
 .../internal/HostResourceProvider.java          |   5 +-
 .../controller/internal/ProvisionAction.java    |   1 +
 .../ambari/server/topology/AmbariContext.java   |  14 +-
 .../ambari/server/topology/ClusterTopology.java |   3 +-
 .../server/topology/ClusterTopologyImpl.java    |  22 +-
 .../ambari/server/topology/HostRequest.java     |  21 +-
 .../ClusterDeployWithHostsSyspreppedTest.java   | 414 -----------------
 .../ClusterDeployWithStartOnlyTest.java         | 439 +++++++++++++++++++
 .../ClusterInstallWithoutStartTest.java         |   5 +-
 12 files changed, 519 insertions(+), 454 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index fae9378..a7a5596 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -506,9 +506,6 @@ public class Configuration {
   public static final String SYS_PREPPED_HOSTS_KEY = "packages.pre.installed";
   public static final String SYS_PREPPED_HOSTS_DEFAULT = "false";
 
-  public static final String BLUEPRINT_SKIP_INSTALL_TASKS_KEY = "blueprint.skip_install_tasks";
-  public static final String BLUEPRINT_SKIP_INSTALL_TASKS_DEFAULT = "false";
-
   /**
    * !!! TODO: For embedded server only - should be removed later
    */
@@ -1317,12 +1314,6 @@ public class Configuration {
     return properties.getProperty(SYS_PREPPED_HOSTS_KEY, SYS_PREPPED_HOSTS_DEFAULT);
   }
 
-  public boolean skipInstallTasks(){
-    String skipInstallCommandsProperty = properties.getProperty
-      (BLUEPRINT_SKIP_INSTALL_TASKS_KEY, BLUEPRINT_SKIP_INSTALL_TASKS_DEFAULT);
-    return Boolean.parseBoolean(areHostsSysPrepped()) && Boolean.parseBoolean(skipInstallCommandsProperty);
-  }
-
   public String getStackAdvisorScript() {
     return properties.getProperty(STACK_ADVISOR_SCRIPT, STACK_ADVISOR_SCRIPT_DEFAULT);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 6aa0853..ec8bfae 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
@@ -224,6 +224,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
   private static final String BASE_LOG_DIR = "/tmp/ambari";
 
+  public static final String SKIP_INSTALL_FOR_COMPONENTS = "skipInstallForComponents";
+  public static final String DONT_SKIP_INSTALL_FOR_COMPONENTS = "dontSkipInstallForComponents";
+
   private final Clusters clusters;
 
   private final ActionManager actionManager;
@@ -423,7 +426,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
     StackId stackId = new StackId(request.getStackVersion());
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
-        stackId.getStackVersion());
+      stackId.getStackVersion());
 
     if (stackInfo == null) {
       throw new StackAccessException("stackName=" + stackId.getStackName() + ", stackVersion=" + stackId.getStackVersion());
@@ -726,7 +729,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
       return;
     }
     Set<String> needRestartServices = ambariMetaInfo.getRestartRequiredServicesNames(
-        stackId.getStackName(), stackId.getStackVersion());
+      stackId.getStackName(), stackId.getStackVersion());
 
     if(needRestartServices.contains(service.getName())) {
       Map<String, ServiceComponent> m = service.getServiceComponents();
@@ -2776,11 +2779,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
             // Skip INSTALL task in case SysPrepped hosts and in case of server components. In case of server component
             // START task should run configuration script.
-            if (configs.skipInstallTasks() &&
-                  "INITIAL_INSTALL".equals(requestProperties.get("phase")) &&
-                    newState == State.INSTALLED && !isClientComponent(cluster, scHost)) {
-              LOG.info("Skipping create of INSTALL task for {} on {} because host is sysprepped.", scHost
-                .getServiceComponentName(), scHost.getHostName());
+            if (newState == State.INSTALLED && skipInstallTaskForComponent(requestProperties, cluster, scHost)) {
+              LOG.info("Skipping create of INSTALL task for {} on {}.", scHost.getServiceComponentName(), scHost.getHostName());
               scHost.setState(State.INSTALLED);
             } else {
               createHostAction(cluster, stage, scHost, configurations, configurationAttributes, configTags,
@@ -2871,15 +2871,28 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   }
 
 
-  private boolean isClientComponent(Cluster cluster, ServiceComponentHost sch) throws AmbariException {
+  private boolean skipInstallTaskForComponent(Map<String, String> requestProperties, Cluster cluster,
+                                              ServiceComponentHost sch) throws AmbariException {
+    boolean isClientComponent = false;
     Service service = cluster.getService(sch.getServiceName());
     if (service != null) {
       ServiceComponent serviceComponent = service.getServiceComponent(sch.getServiceComponentName());
       if (serviceComponent != null) {
-        return serviceComponent.isClientComponent();
+        isClientComponent = serviceComponent.isClientComponent();
       }
     }
+    // Skip INSTALL for service components if START_ONLY is set for component, or if START_ONLY is set on cluster
+    // level and no other provsion action is specified for component
+    if (requestProperties.get(SKIP_INSTALL_FOR_COMPONENTS) != null &&
+      (requestProperties.get(SKIP_INSTALL_FOR_COMPONENTS).contains(sch.getServiceComponentName()) ||
+        (requestProperties.get(SKIP_INSTALL_FOR_COMPONENTS).equals("ALL") && !requestProperties.get
+          (DONT_SKIP_INSTALL_FOR_COMPONENTS).contains(sch
+          .getServiceComponentName()))) &&
+      "INITIAL_INSTALL".equals(requestProperties.get("phase")) && !isClientComponent) {
+      return true;
+    }
     return false;
+
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index df2b476..89dcb11 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -31,6 +31,7 @@ import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariManagementControllerImpl;
 import org.apache.ambari.server.controller.MaintenanceStateHelper;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ServiceComponentHostRequest;
@@ -330,7 +331,7 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
     return unsupportedProperties;
   }
 
-  public RequestStatusResponse install(String cluster, String hostname, boolean skipFailure) throws  SystemException,
+  public RequestStatusResponse install(String cluster, String hostname, Collection<String> skipInstallForComponents, Collection<String> dontSkipInstallForComponents, boolean skipFailure) throws  SystemException,
       UnsupportedPropertyException, NoSuchParentResourceException {
 
     RequestStageContainer requestStages;
@@ -342,7 +343,11 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
     Map<String, String> requestInfo = new HashMap<>();
     requestInfo.put("context", String.format("Install components on host %s", hostname));
     requestInfo.put("phase", "INITIAL_INSTALL");
-    requestInfo.put(Setting.SETTING_NAME_SKIP_FAILURE, Boolean.toString(skipFailure));
+    requestInfo.put(AmbariManagementControllerImpl.SKIP_INSTALL_FOR_COMPONENTS, StringUtils.join
+      (skipInstallForComponents, ";"));
+    requestInfo.put(AmbariManagementControllerImpl.DONT_SKIP_INSTALL_FOR_COMPONENTS, StringUtils.join
+      (dontSkipInstallForComponents, ";"));
+
     Request installRequest = PropertyHelper.getUpdateRequest(installProperties, requestInfo);
 
     Predicate statePredicate = new EqualsPredicate<>(HOST_COMPONENT_STATE_PROPERTY_ID, "INIT");

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
index 6d555e6..4673c73 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.controller.internal;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -567,7 +568,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
     }
   }
 
-  public RequestStatusResponse install(final String cluster, final String hostname, final boolean skipFailure)
+  public RequestStatusResponse install(final String cluster, final String hostname, Collection<String> skipInstallForComponents, Collection<String> dontSkipInstallForComponents, final boolean skipFailure)
       throws ResourceAlreadyExistsException,
       SystemException,
       NoSuchParentResourceException,
@@ -575,7 +576,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
 
 
     return ((HostComponentResourceProvider) getResourceProvider(Resource.Type.HostComponent)).
-        install(cluster, hostname, skipFailure);
+        install(cluster, hostname, skipInstallForComponents, dontSkipInstallForComponents, skipFailure);
   }
 
   public RequestStatusResponse start(final String cluster, final String hostname)

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionAction.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionAction.java
index 9874c5e..a9934df 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionAction.java
@@ -21,5 +21,6 @@ package org.apache.ambari.server.controller.internal;
 
 public enum ProvisionAction {
   INSTALL_ONLY,     // Skip Start
+  START_ONLY,     // Skip Install
   INSTALL_AND_START // Default action
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 02aede6..b11d9d3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -117,11 +117,6 @@ public class AmbariContext {
     return cluster.getSecurityType() == SecurityType.KERBEROS;
   }
 
-  public boolean shouldSkipInstallTasks() {
-    return configs.skipInstallTasks();
-  }
-
-
   //todo: change return type to a topology abstraction
   public HostRoleCommand createAmbariTask(long requestId, long stageId, String component, String host,
                                           TaskType type, boolean skipFailure) {
@@ -349,11 +344,12 @@ public class AmbariContext {
     }
   }
 
-  public RequestStatusResponse installHost(String hostName, String clusterName, boolean skipFailure) {
+  public RequestStatusResponse installHost(String hostName, String clusterName, Collection<String> skipInstallForComponents, Collection<String> dontSkipInstallForComponents, boolean skipFailure) {
     try {
-      return getHostResourceProvider().install(clusterName, hostName, skipFailure);
+      return getHostResourceProvider().install(clusterName, hostName, skipInstallForComponents,
+        dontSkipInstallForComponents, skipFailure);
     } catch (Exception e) {
-      e.printStackTrace();
+      LOG.error("INSTALL Host request submission failed:", e);
       throw new RuntimeException("INSTALL Host request submission failed: " + e, e);
     }
   }
@@ -362,7 +358,7 @@ public class AmbariContext {
     try {
       return getHostComponentResourceProvider().start(clusterName, hostName, installOnlyComponents, skipFailure);
     } catch (Exception e) {
-      e.printStackTrace();
+      LOG.error("START Host request submission failed:", e);
       throw new RuntimeException("START Host request submission failed: " + e, e);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
index 03fac3e..de99518 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
@@ -142,9 +142,10 @@ public interface ClusterTopology {
    * Install the specified host.
    *
    * @param hostName  host name
+   * @param skipInstallTaskCreate
    * @return install response
    */
-  RequestStatusResponse installHost(String hostName, boolean skipFailure);
+  RequestStatusResponse installHost(String hostName, boolean skipInstallTaskCreate, boolean skipFailure);
 
   /**
    * Start the specified host.

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
index 699b82a..e5568be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
@@ -33,6 +33,9 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+
 /**
  * Represents a cluster topology.
  * Topology includes the the associated blueprint, cluster configuration and hostgroup -> host mapping.
@@ -224,9 +227,24 @@ public class ClusterTopologyImpl implements ClusterTopology {
   }
 
   @Override
-  public RequestStatusResponse installHost(String hostName, boolean skipFailure) {
+  public RequestStatusResponse installHost(String hostName, boolean skipInstallTaskCreate, boolean skipFailure) {
     try {
-      return ambariContext.installHost(hostName, ambariContext.getClusterName(getClusterId()), skipFailure);
+      String hostGroupName = getHostGroupForHost(hostName);
+      HostGroup hostGroup = this.blueprint.getHostGroup(hostGroupName);
+
+      Collection<String> skipInstallForComponents = new ArrayList<>();
+      if (skipInstallTaskCreate) {
+        skipInstallForComponents.add("ALL");
+      } else {
+        // get the set of components that are marked as START_ONLY for this hostgroup
+        skipInstallForComponents.addAll(hostGroup.getComponentNames(ProvisionAction.START_ONLY));
+      }
+
+      Collection<String> dontSkipInstallForComponents = hostGroup.getComponentNames(INSTALL_ONLY);
+      dontSkipInstallForComponents.addAll(hostGroup.getComponentNames(INSTALL_AND_START));
+
+      return ambariContext.installHost(hostName, ambariContext.getClusterName(getClusterId()),
+        skipInstallForComponents, dontSkipInstallForComponents, skipFailure);
     } catch (AmbariException e) {
       LOG.error("Cannot get cluster name for clusterId = " + getClusterId(), e);
       throw new RuntimeException(e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index 4dd6f97..b2a67f7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -24,6 +24,7 @@ import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
 import org.apache.ambari.server.controller.internal.HostResourceProvider;
+import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -43,7 +44,9 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
 import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.START_ONLY;
 
 /**
  * Represents a set of requests to a single host such as install, start, etc.
@@ -188,6 +191,7 @@ public class HostRequest implements Comparable<HostRequest> {
     logicalTaskMap.put(installTask, new HashMap<String, Long>());
 
     boolean skipStartTaskCreate = topology.getProvisionAction().equals(INSTALL_ONLY);
+    boolean skipInstallTaskCreate = topology.getProvisionAction().equals(START_ONLY);
 
     StartHostTask startTask = null;
     if (!skipStartTaskCreate) {
@@ -200,6 +204,10 @@ public class HostRequest implements Comparable<HostRequest> {
 
     // lower level logical component level tasks which get mapped to physical tasks
     HostGroup hostGroup = getHostGroup();
+    Collection<String> startOnlyComponents = hostGroup.getComponentNames(START_ONLY);
+    Collection<String> installOnlyComponents = hostGroup.getComponentNames(INSTALL_ONLY);
+    Collection<String> installAndStartComponents = hostGroup.getComponentNames(INSTALL_AND_START);
+
     for (String component : hostGroup.getComponentNames()) {
       if (component == null || component.equals("AMBARI_SERVER")) {
         LOG.info("Skipping component {} when creating request\n", component);
@@ -213,10 +221,12 @@ public class HostRequest implements Comparable<HostRequest> {
       AmbariContext context = topology.getAmbariContext();
       Stack stack = hostGroup.getStack();
 
-      // Skip INSTALL task in case SysPrepped hosts and in case of server components. In case of server component
-      // START task should run configuration script.
-      if (context.shouldSkipInstallTasks() && stack != null && !stack.getComponentInfo(component).isClient()) {
-        LOG.info("Skipping create of INSTALL task for {} on {} because host is sysprepped.", component, hostName);
+      // Skip INSTALL task in case server component is marked as START_ONLY, or the cluster provision_action is
+      // START_ONLY, unless component is marked with INSTALL_ONLY or INSTALL_AND_START.
+      if (startOnlyComponents.contains(component) || (skipInstallTaskCreate &&
+        !installOnlyComponents.contains(component) && !installAndStartComponents.contains(component))
+          && stack != null && !stack.getComponentInfo(component).isClient()) {
+        LOG.info("Skipping create of INSTALL task for {} on {}.", component, hostName);
       } else {
         HostRoleCommand logicalInstallTask = context.createAmbariTask(
           getRequestId(), id, component, hostName, AmbariContext.TaskType.INSTALL, skipFailure);
@@ -507,7 +517,8 @@ public class HostRequest implements Comparable<HostRequest> {
     @Override
     public void run() {
       LOG.info("HostRequest.InstallHostTask: Executing INSTALL task for host: " + hostname);
-      RequestStatusResponse response = clusterTopology.installHost(hostname, skipFailure);
+      boolean skipInstallTaskCreate = topology.getProvisionAction().equals(ProvisionAction.START_ONLY);
+      RequestStatusResponse response = clusterTopology.installHost(hostname, skipInstallTaskCreate, skipFailure);
       // map logical install tasks to physical install tasks
       List<ShortTaskStatus> underlyingTasks = response.getTasks();
       for (ShortTaskStatus task : underlyingTasks) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithHostsSyspreppedTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithHostsSyspreppedTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithHostsSyspreppedTest.java
deleted file mode 100644
index 8c308a7..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithHostsSyspreppedTest.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.topology;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-import org.apache.ambari.server.Role;
-import org.apache.ambari.server.RoleCommand;
-import org.apache.ambari.server.actionmanager.HostRoleCommand;
-import org.apache.ambari.server.actionmanager.HostRoleStatus;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.AmbariServer;
-import org.apache.ambari.server.controller.ClusterRequest;
-import org.apache.ambari.server.controller.ConfigurationRequest;
-import org.apache.ambari.server.controller.RequestStatusResponse;
-import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
-import org.apache.ambari.server.security.encryption.CredentialStoreService;
-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.SecurityType;
-import org.easymock.Capture;
-import org.easymock.EasyMockRule;
-import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.easymock.MockType;
-import org.easymock.TestSubject;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(AmbariServer.class)
-public class ClusterDeployWithHostsSyspreppedTest {
-  private static final String CLUSTER_NAME = "test-cluster";
-  private static final long CLUSTER_ID = 1;
-  private static final String BLUEPRINT_NAME = "test-bp";
-  private static final String STACK_NAME = "test-stack";
-  private static final String STACK_VERSION = "test-stack-version";
-
-  @Rule
-  public EasyMockRule mocks = new EasyMockRule(this);
-
-  @TestSubject
-  private TopologyManager topologyManager = new TopologyManager();
-
-  @Mock(type = MockType.NICE)
-  private Blueprint blueprint;
-
-  @Mock(type = MockType.NICE)
-  private Stack stack;
-
-  @Mock(type = MockType.NICE)
-  private ProvisionClusterRequest request;
-  private PersistedTopologyRequest persistedTopologyRequest;
-//  @Mock(type = MockType.STRICT)
-  private LogicalRequestFactory logicalRequestFactory;
-  @Mock(type = MockType.DEFAULT)
-  private LogicalRequest logicalRequest;
-  @Mock(type = MockType.NICE)
-  private AmbariContext ambariContext;
-  @Mock(type = MockType.NICE)
-  private ConfigurationRequest configurationRequest;
-  @Mock(type = MockType.NICE)
-  private ConfigurationRequest configurationRequest2;
-  @Mock(type = MockType.NICE)
-  private ConfigurationRequest configurationRequest3;
-  @Mock(type = MockType.NICE)
-  private RequestStatusResponse requestStatusResponse;
-  @Mock(type = MockType.STRICT)
-  private ExecutorService executor;
-  @Mock(type = MockType.STRICT)
-  private PersistedState persistedState;
-  @Mock(type = MockType.NICE)
-  private HostGroup group1;
-  @Mock(type = MockType.NICE)
-  private HostGroup group2;
-  @Mock(type = MockType.STRICT)
-  private SecurityConfigurationFactory securityConfigurationFactory;
-  @Mock(type = MockType.STRICT)
-  private CredentialStoreService credentialStoreService;
-  @Mock(type = MockType.STRICT)
-  private ClusterController clusterController;
-  @Mock(type = MockType.STRICT)
-  private ResourceProvider resourceProvider;
-  @Mock(type = MockType.NICE)
-  private AmbariManagementController managementController;
-  @Mock(type = MockType.NICE)
-  private Clusters clusters;
-  @Mock(type = MockType.NICE)
-  private Cluster cluster;
-  @Mock(type = MockType.NICE)
-  private HostRoleCommand hostRoleCommandInstallComponent3;
-  @Mock(type = MockType.NICE)
-  private HostRoleCommand hostRoleCommandInstallComponent4;
-
-
-  @Mock(type = MockType.NICE)
-  private ComponentInfo serviceComponentInfo;
-  @Mock(type = MockType.NICE)
-  private ComponentInfo clientComponentInfo;
-
-  @Mock(type = MockType.STRICT)
-  private Future mockFuture;
-
-  private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>());
-  private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), stackConfig);
-  private final Configuration topoConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
-  private final Configuration bpGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
-  private final Configuration bpGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
-
-  private final Configuration topoGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), bpGroup1Config);
-  private final Configuration topoGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
-    new HashMap<String, Map<String, Map<String, String>>>(), bpGroup2Config);
-
-  private HostGroupInfo group1Info = new HostGroupInfo("group1");
-  private HostGroupInfo group2Info = new HostGroupInfo("group2");
-  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<String, HostGroupInfo>();
-
-  private Collection<String> group1Components = Arrays.asList("component1", "component2", "component3");
-  private Collection<String> group2Components = Arrays.asList("component3", "component4");
-
-  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<String, Collection<String>>();
-  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<String, Collection<String>>();
-
-  private Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>();
-
-  private String predicate = "Hosts/host_name=foo";
-
-  private List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
-
-  private Capture<ClusterTopology> clusterTopologyCapture;
-  private Capture<Map<String, Object>> configRequestPropertiesCapture;
-  private Capture<Map<String, Object>> configRequestPropertiesCapture2;
-  private Capture<Map<String, Object>> configRequestPropertiesCapture3;
-  private Capture<ClusterRequest> updateClusterConfigRequestCapture;
-  private Capture<Runnable> updateConfigTaskCapture;
-
-  @Before
-  public void setup() throws Exception {
-    clusterTopologyCapture = newCapture();
-    configRequestPropertiesCapture = newCapture();
-    configRequestPropertiesCapture2 = newCapture();
-    configRequestPropertiesCapture3 = newCapture();
-    updateClusterConfigRequestCapture = newCapture();
-    updateConfigTaskCapture = newCapture();
-
-    topoConfiguration.setProperty("service1-site", "s1-prop", "s1-prop-value");
-    topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
-    topoConfiguration.setProperty("cluster-env", "g-prop", "g-prop-value");
-
-    //clusterRequestCapture = new Capture<ClusterRequest>();
-    // group 1 has fqdn specified
-    group1Info.addHost("host1");
-    group1Info.setConfiguration(topoGroup1Config);
-    // group 2 has host_count and host_predicate specified
-    group2Info.setRequestedCount(2);
-    group2Info.setPredicate(predicate);
-    group2Info.setConfiguration(topoGroup2Config);
-
-    groupInfoMap.put("group1", group1Info);
-    groupInfoMap.put("group2", group2Info);
-
-    Map<String, HostGroup> groupMap = new HashMap<String, HostGroup>();
-    groupMap.put("group1", group1);
-    groupMap.put("group2", group2);
-
-    serviceComponents.put("service1", Arrays.asList("component1", "component3"));
-    serviceComponents.put("service2", Arrays.asList("component2", "component4"));
-
-    group1ServiceComponents.put("service1", Arrays.asList("component1", "component3"));
-    group1ServiceComponents.put("service2", Collections.singleton("component2"));
-    group2ServiceComponents.put("service2", Collections.singleton("component3"));
-    group2ServiceComponents.put("service2", Collections.singleton("component4"));
-
-    expect(blueprint.getHostGroup("group1")).andReturn(group1).anyTimes();
-    expect(blueprint.getHostGroup("group2")).andReturn(group2).anyTimes();
-    expect(blueprint.getComponents("service1")).andReturn(Arrays.asList("component1", "component3")).anyTimes();
-    expect(blueprint.getComponents("service2")).andReturn(Arrays.asList("component2", "component4")).anyTimes();
-    expect(blueprint.getConfiguration()).andReturn(bpConfiguration).anyTimes();
-    expect(blueprint.getHostGroups()).andReturn(groupMap).anyTimes();
-    expect(blueprint.getHostGroupsForComponent("component1")).andReturn(Collections.singleton(group1)).anyTimes();
-    expect(blueprint.getHostGroupsForComponent("component2")).andReturn(Collections.singleton(group1)).anyTimes();
-    expect(blueprint.getHostGroupsForComponent("component3")).andReturn(Arrays.asList(group1, group2)).anyTimes();
-    expect(blueprint.getHostGroupsForComponent("component4")).andReturn(Collections.singleton(group2)).anyTimes();
-    expect(blueprint.getHostGroupsForService("service1")).andReturn(Arrays.asList(group1, group2)).anyTimes();
-    expect(blueprint.getHostGroupsForService("service2")).andReturn(Arrays.asList(group1, group2)).anyTimes();
-    expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes();
-    expect(blueprint.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
-    expect(blueprint.getStack()).andReturn(stack).anyTimes();
-    // don't expect toEntity()
-
-    expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site", "service1-env")).anyTimes();
-    expect(stack.getAllConfigurationTypes("service2")).andReturn(Arrays.asList("service2-site", "service2-env")).anyTimes();
-    expect(stack.getAutoDeployInfo("component1")).andReturn(null).anyTimes();
-    expect(stack.getAutoDeployInfo("component2")).andReturn(null).anyTimes();
-    expect(stack.getAutoDeployInfo("component3")).andReturn(null).anyTimes();
-    expect(stack.getAutoDeployInfo("component4")).andReturn(null).anyTimes();
-
-    expect(serviceComponentInfo.isClient()).andReturn(false).anyTimes();
-    expect(clientComponentInfo.isClient()).andReturn(true).anyTimes();
-
-    expect(stack.getComponentInfo("component1")).andReturn(serviceComponentInfo).anyTimes();
-    expect(stack.getComponentInfo("component2")).andReturn(serviceComponentInfo).anyTimes();
-    expect(stack.getComponentInfo("component3")).andReturn(clientComponentInfo).anyTimes();
-    expect(stack.getComponentInfo("component4")).andReturn(clientComponentInfo).anyTimes();
-
-    expect(stack.getCardinality("component1")).andReturn(new Cardinality("1")).anyTimes();
-    expect(stack.getCardinality("component2")).andReturn(new Cardinality("1")).anyTimes();
-    expect(stack.getCardinality("component3")).andReturn(new Cardinality("1+")).anyTimes();
-    expect(stack.getCardinality("component4")).andReturn(new Cardinality("1+")).anyTimes();
-    expect(stack.getComponents()).andReturn(serviceComponents).anyTimes();
-    expect(stack.getComponents("service1")).andReturn(serviceComponents.get("service1")).anyTimes();
-    expect(stack.getComponents("service2")).andReturn(serviceComponents.get("service2")).anyTimes();
-    expect(stack.getConfiguration()).andReturn(stackConfig).anyTimes();
-    expect(stack.getName()).andReturn(STACK_NAME).anyTimes();
-    expect(stack.getVersion()).andReturn(STACK_VERSION).anyTimes();
-    expect(stack.getServiceForConfigType("service1-site")).andReturn("service1").anyTimes();
-    expect(stack.getServiceForConfigType("service2-site")).andReturn("service2").anyTimes();
-    expect(stack.getExcludedConfigurationTypes("service1")).andReturn(Collections.<String>emptySet()).anyTimes();
-    expect(stack.getExcludedConfigurationTypes("service2")).andReturn(Collections.<String>emptySet()).anyTimes();
-
-    expect(request.getBlueprint()).andReturn(blueprint).anyTimes();
-    expect(request.getClusterId()).andReturn(CLUSTER_ID).anyTimes();
-    expect(request.getClusterName()).andReturn(CLUSTER_NAME).anyTimes();
-    expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
-    expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
-    expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
-    expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
-    expect(request.getProvisionAction()).andReturn(INSTALL_ONLY).anyTimes();
-    expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
-
-
-    expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
-    expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
-    expect(group1.containsMasterComponent()).andReturn(true).anyTimes();
-    expect(group1.getComponentNames()).andReturn(group1Components).anyTimes();
-    expect(group1.getComponents("service1")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
-    expect(group1.getComponents("service2")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
-    expect(group1.getConfiguration()).andReturn(topoGroup1Config).anyTimes();
-    expect(group1.getName()).andReturn("group1").anyTimes();
-    expect(group1.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
-    expect(group1.getStack()).andReturn(stack).anyTimes();
-
-    expect(group2.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
-    expect(group2.getCardinality()).andReturn("test cardinality").anyTimes();
-    expect(group2.containsMasterComponent()).andReturn(false).anyTimes();
-    expect(group2.getComponentNames()).andReturn(group2Components).anyTimes();
-    expect(group2.getComponents("service1")).andReturn(group2ServiceComponents.get("service1")).anyTimes();
-    expect(group2.getComponents("service2")).andReturn(group2ServiceComponents.get("service2")).anyTimes();
-    expect(group2.getConfiguration()).andReturn(topoGroup2Config).anyTimes();
-    expect(group2.getName()).andReturn("group2").anyTimes();
-    expect(group2.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
-    expect(group2.getStack()).andReturn(stack).anyTimes();
-
-    // Create partial mock to allow actual logical request creation
-    logicalRequestFactory = createMockBuilder(LogicalRequestFactory.class).addMockedMethod(
-      LogicalRequestFactory.class.getMethod("createRequest",
-        Long.class, TopologyRequest.class, ClusterTopology.class,
-        TopologyLogicalRequestEntity.class)).createMock();
-    Field f = TopologyManager.class.getDeclaredField("logicalRequestFactory");
-    f.setAccessible(true);
-    f.set(topologyManager, logicalRequestFactory);
-
-    PowerMock.mockStatic(AmbariServer.class);
-    expect(AmbariServer.getController()).andReturn(managementController).anyTimes();
-    PowerMock.replay(AmbariServer.class);
-    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
-    expect(clusters.getClusterById(anyLong())).andReturn(cluster).anyTimes();
-    expect(cluster.getClusterName()).andReturn(CLUSTER_NAME).anyTimes();
-
-    expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
-    //todo: don't ignore param
-    ambariContext.createAmbariResources(isA(ClusterTopology.class), eq(CLUSTER_NAME), (SecurityType) isNull(), (String)isNull());
-    expectLastCall().once();
-    expect(ambariContext.getNextRequestId()).andReturn(1L).once();
-    expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();
-    expect(ambariContext.getClusterId(CLUSTER_NAME)).andReturn(CLUSTER_ID).anyTimes();
-    expect(ambariContext.getClusterName(CLUSTER_ID)).andReturn(CLUSTER_NAME).anyTimes();
-    expect(ambariContext.shouldSkipInstallTasks()).andReturn(true).anyTimes();
-    // so only INITIAL config
-    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture))).
-      andReturn(Collections.singletonList(configurationRequest));
-    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture2))).
-      andReturn(Collections.singletonList(configurationRequest2)).once();
-    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture3))).
-      andReturn(Collections.singletonList(configurationRequest3)).once();
-    // INSTALL task expectation
-
-
-    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component3"),
-      anyString(), eq(AmbariContext.TaskType.INSTALL), anyBoolean())).andReturn(hostRoleCommandInstallComponent3).times(3);
-    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component4"),
-      anyString(), eq(AmbariContext.TaskType.INSTALL), anyBoolean())).andReturn(hostRoleCommandInstallComponent4).times(2);
-
-    expect(hostRoleCommandInstallComponent3.getTaskId()).andReturn(1L).atLeastOnce();
-    expect(hostRoleCommandInstallComponent3.getRoleCommand()).andReturn(RoleCommand.INSTALL).atLeastOnce();
-    expect(hostRoleCommandInstallComponent3.getRole()).andReturn(Role.INSTALL_PACKAGES).atLeastOnce();
-    expect(hostRoleCommandInstallComponent3.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
-
-    expect(hostRoleCommandInstallComponent4.getTaskId()).andReturn(2L).atLeastOnce();
-    expect(hostRoleCommandInstallComponent4.getRoleCommand()).andReturn(RoleCommand.INSTALL).atLeastOnce();
-    expect(hostRoleCommandInstallComponent4.getRole()).andReturn(Role.INSTALL_PACKAGES).atLeastOnce();
-    expect(hostRoleCommandInstallComponent4.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
-
-    ambariContext.setConfigurationOnCluster(capture(updateClusterConfigRequestCapture));
-    expectLastCall().times(3);
-    ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
-    expectLastCall().once();
-
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
-    expect(executor.submit(anyObject(AsyncCallableService.class))).andReturn(mockFuture);
-
-    persistedTopologyRequest = new PersistedTopologyRequest(1, request);
-    expect(persistedState.getAllRequests()).andReturn(Collections.<ClusterTopology,
-      List<LogicalRequest>>emptyMap()).once();
-    expect(persistedState.persistTopologyRequest(request)).andReturn(persistedTopologyRequest).once();
-    persistedState.persistLogicalRequest((LogicalRequest) anyObject(), anyLong());
-    expectLastCall().once();
-
-    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory, logicalRequest,
-      configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse, executor,
-      persistedState, securityConfigurationFactory, credentialStoreService, clusterController, resourceProvider,
-      mockFuture, managementController, clusters, cluster, hostRoleCommandInstallComponent3,
-      hostRoleCommandInstallComponent4, serviceComponentInfo, clientComponentInfo);
-
-    Class clazz = TopologyManager.class;
-
-    f = clazz.getDeclaredField("executor");
-    f.setAccessible(true);
-    f.set(topologyManager, executor);
-
-    EasyMockSupport.injectMocks(topologyManager);
-  }
-
-  @After
-  public void tearDown() {
-    verify(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4);
-
-    reset(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4);
-  }
-
-  @Test
-  public void testProvisionCluster() throws Exception {
-    topologyManager.provisionCluster(request);
-    LogicalRequest request = topologyManager.getRequest(1);
-    assertEquals(request.getHostRequests().size(), 3);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
new file mode 100644
index 0000000..279340e
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
@@ -0,0 +1,439 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.topology;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariServer;
+import org.apache.ambari.server.controller.ClusterRequest;
+import org.apache.ambari.server.controller.ConfigurationRequest;
+import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.internal.ProvisionAction;
+import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
+import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.spi.ClusterController;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
+import org.apache.ambari.server.security.encryption.CredentialStoreService;
+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.SecurityType;
+import org.easymock.Capture;
+import org.easymock.EasyMockRule;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.MockType;
+import org.easymock.TestSubject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(AmbariServer.class)
+public class ClusterDeployWithStartOnlyTest {
+  private static final String CLUSTER_NAME = "test-cluster";
+  private static final long CLUSTER_ID = 1;
+  private static final String BLUEPRINT_NAME = "test-bp";
+  private static final String STACK_NAME = "test-stack";
+  private static final String STACK_VERSION = "test-stack-version";
+
+  @Rule
+  public EasyMockRule mocks = new EasyMockRule(this);
+
+  @TestSubject
+  private TopologyManager topologyManager = new TopologyManager();
+
+  @Mock(type = MockType.NICE)
+  private Blueprint blueprint;
+
+  @Mock(type = MockType.NICE)
+  private Stack stack;
+
+  @Mock(type = MockType.NICE)
+  private ProvisionClusterRequest request;
+  private PersistedTopologyRequest persistedTopologyRequest;
+//  @Mock(type = MockType.STRICT)
+  private LogicalRequestFactory logicalRequestFactory;
+  @Mock(type = MockType.DEFAULT)
+  private LogicalRequest logicalRequest;
+  @Mock(type = MockType.NICE)
+  private AmbariContext ambariContext;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest2;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest3;
+  @Mock(type = MockType.NICE)
+  private RequestStatusResponse requestStatusResponse;
+  @Mock(type = MockType.STRICT)
+  private ExecutorService executor;
+  @Mock(type = MockType.STRICT)
+  private PersistedState persistedState;
+  @Mock(type = MockType.NICE)
+  private HostGroup group1;
+  @Mock(type = MockType.NICE)
+  private HostGroup group2;
+  @Mock(type = MockType.STRICT)
+  private SecurityConfigurationFactory securityConfigurationFactory;
+  @Mock(type = MockType.STRICT)
+  private CredentialStoreService credentialStoreService;
+  @Mock(type = MockType.STRICT)
+  private ClusterController clusterController;
+  @Mock(type = MockType.STRICT)
+  private ResourceProvider resourceProvider;
+  @Mock(type = MockType.NICE)
+  private AmbariManagementController managementController;
+  @Mock(type = MockType.NICE)
+  private Clusters clusters;
+  @Mock(type = MockType.NICE)
+  private Cluster cluster;
+  @Mock(type = MockType.NICE)
+  private HostRoleCommand hostRoleCommandInstallComponent3;
+  @Mock(type = MockType.NICE)
+  private HostRoleCommand hostRoleCommandInstallComponent4;
+  @Mock(type = MockType.NICE)
+  private HostRoleCommand hostRoleCommandStartComponent1;
+  @Mock(type = MockType.NICE)
+  private HostRoleCommand hostRoleCommandStartComponent2;
+
+  @Mock(type = MockType.NICE)
+  private ComponentInfo serviceComponentInfo;
+  @Mock(type = MockType.NICE)
+  private ComponentInfo clientComponentInfo;
+
+  @Mock(type = MockType.STRICT)
+  private Future mockFuture;
+
+  private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>());
+  private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), stackConfig);
+  private final Configuration topoConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
+  private final Configuration bpGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
+  private final Configuration bpGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), bpConfiguration);
+
+  private final Configuration topoGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), bpGroup1Config);
+  private final Configuration topoGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
+    new HashMap<String, Map<String, Map<String, String>>>(), bpGroup2Config);
+
+  private HostGroupInfo group1Info = new HostGroupInfo("group1");
+  private HostGroupInfo group2Info = new HostGroupInfo("group2");
+  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<String, HostGroupInfo>();
+
+  private Collection<String> group1Components = Arrays.asList("component1", "component2", "component3");
+  private Collection<String> group2Components = Arrays.asList("component3", "component4");
+
+  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<String, Collection<String>>();
+
+  private Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>();
+
+  private String predicate = "Hosts/host_name=foo";
+
+  private List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
+
+  private Capture<ClusterTopology> clusterTopologyCapture;
+  private Capture<Map<String, Object>> configRequestPropertiesCapture;
+  private Capture<Map<String, Object>> configRequestPropertiesCapture2;
+  private Capture<Map<String, Object>> configRequestPropertiesCapture3;
+  private Capture<ClusterRequest> updateClusterConfigRequestCapture;
+  private Capture<Runnable> updateConfigTaskCapture;
+
+  @Before
+  public void setup() throws Exception {
+    clusterTopologyCapture = newCapture();
+    configRequestPropertiesCapture = newCapture();
+    configRequestPropertiesCapture2 = newCapture();
+    configRequestPropertiesCapture3 = newCapture();
+    updateClusterConfigRequestCapture = newCapture();
+    updateConfigTaskCapture = newCapture();
+
+    topoConfiguration.setProperty("service1-site", "s1-prop", "s1-prop-value");
+    topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
+    topoConfiguration.setProperty("cluster-env", "g-prop", "g-prop-value");
+
+    //clusterRequestCapture = new Capture<ClusterRequest>();
+    // group 1 has fqdn specified
+    group1Info.addHost("host1");
+    group1Info.setConfiguration(topoGroup1Config);
+    // group 2 has host_count and host_predicate specified
+    group2Info.setRequestedCount(2);
+    group2Info.setPredicate(predicate);
+    group2Info.setConfiguration(topoGroup2Config);
+
+    groupInfoMap.put("group1", group1Info);
+    groupInfoMap.put("group2", group2Info);
+
+    Map<String, HostGroup> groupMap = new HashMap<String, HostGroup>();
+    groupMap.put("group1", group1);
+    groupMap.put("group2", group2);
+
+    serviceComponents.put("service1", Arrays.asList("component1", "component3"));
+    serviceComponents.put("service2", Arrays.asList("component2", "component4"));
+
+    group1ServiceComponents.put("service1", Arrays.asList("component1", "component3"));
+    group1ServiceComponents.put("service2", Collections.singleton("component2"));
+    group2ServiceComponents.put("service2", Collections.singleton("component3"));
+    group2ServiceComponents.put("service2", Collections.singleton("component4"));
+
+    expect(blueprint.getHostGroup("group1")).andReturn(group1).anyTimes();
+    expect(blueprint.getHostGroup("group2")).andReturn(group2).anyTimes();
+    expect(blueprint.getComponents("service1")).andReturn(Arrays.asList("component1", "component3")).anyTimes();
+    expect(blueprint.getComponents("service2")).andReturn(Arrays.asList("component2", "component4")).anyTimes();
+    expect(blueprint.getConfiguration()).andReturn(bpConfiguration).anyTimes();
+    expect(blueprint.getHostGroups()).andReturn(groupMap).anyTimes();
+    expect(blueprint.getHostGroupsForComponent("component1")).andReturn(Collections.singleton(group1)).anyTimes();
+    expect(blueprint.getHostGroupsForComponent("component2")).andReturn(Collections.singleton(group1)).anyTimes();
+    expect(blueprint.getHostGroupsForComponent("component3")).andReturn(Arrays.asList(group1, group2)).anyTimes();
+    expect(blueprint.getHostGroupsForComponent("component4")).andReturn(Collections.singleton(group2)).anyTimes();
+    expect(blueprint.getHostGroupsForService("service1")).andReturn(Arrays.asList(group1, group2)).anyTimes();
+    expect(blueprint.getHostGroupsForService("service2")).andReturn(Arrays.asList(group1, group2)).anyTimes();
+    expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes();
+    expect(blueprint.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
+    expect(blueprint.getStack()).andReturn(stack).anyTimes();
+    // don't expect toEntity()
+
+    expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site", "service1-env")).anyTimes();
+    expect(stack.getAllConfigurationTypes("service2")).andReturn(Arrays.asList("service2-site", "service2-env")).anyTimes();
+    expect(stack.getAutoDeployInfo("component1")).andReturn(null).anyTimes();
+    expect(stack.getAutoDeployInfo("component2")).andReturn(null).anyTimes();
+    expect(stack.getAutoDeployInfo("component3")).andReturn(null).anyTimes();
+    expect(stack.getAutoDeployInfo("component4")).andReturn(null).anyTimes();
+
+    expect(serviceComponentInfo.isClient()).andReturn(false).anyTimes();
+    expect(clientComponentInfo.isClient()).andReturn(true).anyTimes();
+
+    expect(stack.getComponentInfo("component1")).andReturn(serviceComponentInfo).anyTimes();
+    expect(stack.getComponentInfo("component2")).andReturn(serviceComponentInfo).anyTimes();
+    expect(stack.getComponentInfo("component3")).andReturn(clientComponentInfo).anyTimes();
+    expect(stack.getComponentInfo("component4")).andReturn(clientComponentInfo).anyTimes();
+
+    expect(stack.getCardinality("component1")).andReturn(new Cardinality("1")).anyTimes();
+    expect(stack.getCardinality("component2")).andReturn(new Cardinality("1")).anyTimes();
+    expect(stack.getCardinality("component3")).andReturn(new Cardinality("1+")).anyTimes();
+    expect(stack.getCardinality("component4")).andReturn(new Cardinality("1+")).anyTimes();
+    expect(stack.getComponents()).andReturn(serviceComponents).anyTimes();
+    expect(stack.getComponents("service1")).andReturn(serviceComponents.get("service1")).anyTimes();
+    expect(stack.getComponents("service2")).andReturn(serviceComponents.get("service2")).anyTimes();
+    expect(stack.getConfiguration()).andReturn(stackConfig).anyTimes();
+    expect(stack.getName()).andReturn(STACK_NAME).anyTimes();
+    expect(stack.getVersion()).andReturn(STACK_VERSION).anyTimes();
+    expect(stack.getServiceForConfigType("service1-site")).andReturn("service1").anyTimes();
+    expect(stack.getServiceForConfigType("service2-site")).andReturn("service2").anyTimes();
+    expect(stack.getExcludedConfigurationTypes("service1")).andReturn(Collections.<String>emptySet()).anyTimes();
+    expect(stack.getExcludedConfigurationTypes("service2")).andReturn(Collections.<String>emptySet()).anyTimes();
+
+    expect(request.getBlueprint()).andReturn(blueprint).anyTimes();
+    expect(request.getClusterId()).andReturn(CLUSTER_ID).anyTimes();
+    expect(request.getClusterName()).andReturn(CLUSTER_NAME).anyTimes();
+    expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
+    expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
+    expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
+    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
+    expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
+    expect(request.getProvisionAction()).andReturn(ProvisionAction.START_ONLY).anyTimes();
+    expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
+
+
+    expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
+    expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
+    expect(group1.containsMasterComponent()).andReturn(true).anyTimes();
+    expect(group1.getComponentNames()).andReturn(group1Components).anyTimes();
+    expect(group1.getComponentNames(anyObject(ProvisionAction.class))).andReturn(Collections.<String>emptyList()).anyTimes();
+    expect(group1.getComponents("service1")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
+    expect(group1.getComponents("service2")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
+    expect(group1.getConfiguration()).andReturn(topoGroup1Config).anyTimes();
+    expect(group1.getName()).andReturn("group1").anyTimes();
+    expect(group1.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
+    expect(group1.getStack()).andReturn(stack).anyTimes();
+
+    expect(group2.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
+    expect(group2.getCardinality()).andReturn("test cardinality").anyTimes();
+    expect(group2.containsMasterComponent()).andReturn(false).anyTimes();
+    expect(group2.getComponentNames()).andReturn(group2Components).anyTimes();
+    expect(group2.getComponentNames(anyObject(ProvisionAction.class))).andReturn(Collections.<String>emptyList()).anyTimes();
+    expect(group2.getComponents("service1")).andReturn(group2ServiceComponents.get("service1")).anyTimes();
+    expect(group2.getComponents("service2")).andReturn(group2ServiceComponents.get("service2")).anyTimes();
+    expect(group2.getConfiguration()).andReturn(topoGroup2Config).anyTimes();
+    expect(group2.getName()).andReturn("group2").anyTimes();
+    expect(group2.getServices()).andReturn(Arrays.asList("service1", "service2")).anyTimes();
+    expect(group2.getStack()).andReturn(stack).anyTimes();
+
+    // Create partial mock to allow actual logical request creation
+    logicalRequestFactory = createMockBuilder(LogicalRequestFactory.class).addMockedMethod(
+      LogicalRequestFactory.class.getMethod("createRequest",
+        Long.class, TopologyRequest.class, ClusterTopology.class,
+        TopologyLogicalRequestEntity.class)).createMock();
+    Field f = TopologyManager.class.getDeclaredField("logicalRequestFactory");
+    f.setAccessible(true);
+    f.set(topologyManager, logicalRequestFactory);
+
+    PowerMock.mockStatic(AmbariServer.class);
+    expect(AmbariServer.getController()).andReturn(managementController).anyTimes();
+    PowerMock.replay(AmbariServer.class);
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
+    expect(clusters.getClusterById(anyLong())).andReturn(cluster).anyTimes();
+    expect(cluster.getClusterName()).andReturn(CLUSTER_NAME).anyTimes();
+
+    expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
+    //todo: don't ignore param
+    ambariContext.createAmbariResources(isA(ClusterTopology.class), eq(CLUSTER_NAME), (SecurityType) isNull(), (String) isNull());
+    expectLastCall().once();
+    expect(ambariContext.getNextRequestId()).andReturn(1L).once();
+    expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();
+    expect(ambariContext.getClusterId(CLUSTER_NAME)).andReturn(CLUSTER_ID).anyTimes();
+    expect(ambariContext.getClusterName(CLUSTER_ID)).andReturn(CLUSTER_NAME).anyTimes();
+    // so only INITIAL config
+    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture))).
+      andReturn(Collections.singletonList(configurationRequest));
+    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture2))).
+      andReturn(Collections.singletonList(configurationRequest2)).once();
+    expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture3))).
+      andReturn(Collections.singletonList(configurationRequest3)).once();
+    // INSTALL task expectation
+
+
+    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component3"),
+      anyString(), eq(AmbariContext.TaskType.INSTALL), anyBoolean())).andReturn(hostRoleCommandInstallComponent3).times(3);
+    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component4"),
+      anyString(), eq(AmbariContext.TaskType.INSTALL), anyBoolean())).andReturn(hostRoleCommandInstallComponent4).times(2);
+
+    expect(hostRoleCommandInstallComponent3.getTaskId()).andReturn(1L).atLeastOnce();
+    expect(hostRoleCommandInstallComponent3.getRoleCommand()).andReturn(RoleCommand.INSTALL).atLeastOnce();
+    expect(hostRoleCommandInstallComponent3.getRole()).andReturn(Role.INSTALL_PACKAGES).atLeastOnce();
+    expect(hostRoleCommandInstallComponent3.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
+
+    expect(hostRoleCommandInstallComponent4.getTaskId()).andReturn(2L).atLeastOnce();
+    expect(hostRoleCommandInstallComponent4.getRoleCommand()).andReturn(RoleCommand.INSTALL).atLeastOnce();
+    expect(hostRoleCommandInstallComponent4.getRole()).andReturn(Role.INSTALL_PACKAGES).atLeastOnce();
+    expect(hostRoleCommandInstallComponent4.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
+
+    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component1"),
+      anyString(), eq(AmbariContext.TaskType.START), anyBoolean())).andReturn(hostRoleCommandStartComponent1).times
+      (1);
+    expect(ambariContext.createAmbariTask(anyLong(), anyLong(), eq("component2"),
+      anyString(), eq(AmbariContext.TaskType.START), anyBoolean())).andReturn(hostRoleCommandStartComponent2).times(1);
+
+    expect(hostRoleCommandStartComponent1.getTaskId()).andReturn(3L).anyTimes();
+    expect(hostRoleCommandStartComponent1.getRoleCommand()).andReturn(RoleCommand.START).atLeastOnce();
+    expect(hostRoleCommandStartComponent1.getRole()).andReturn(Role.DATANODE).atLeastOnce();
+    expect(hostRoleCommandStartComponent1.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
+
+    expect(hostRoleCommandStartComponent2.getTaskId()).andReturn(4L).anyTimes();
+    expect(hostRoleCommandStartComponent2.getRoleCommand()).andReturn(RoleCommand.START).atLeastOnce();
+    expect(hostRoleCommandStartComponent2.getRole()).andReturn(Role.NAMENODE).atLeastOnce();
+    expect(hostRoleCommandStartComponent2.getStatus()).andReturn(HostRoleStatus.COMPLETED).atLeastOnce();
+
+
+    ambariContext.setConfigurationOnCluster(capture(updateClusterConfigRequestCapture));
+    expectLastCall().times(3);
+    ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
+    expectLastCall().once();
+
+    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
+    expect(executor.submit(anyObject(AsyncCallableService.class))).andReturn(mockFuture);
+
+    persistedTopologyRequest = new PersistedTopologyRequest(1, request);
+    expect(persistedState.getAllRequests()).andReturn(Collections.<ClusterTopology,
+      List<LogicalRequest>>emptyMap()).once();
+    expect(persistedState.persistTopologyRequest(request)).andReturn(persistedTopologyRequest).once();
+    persistedState.persistLogicalRequest((LogicalRequest) anyObject(), anyLong());
+    expectLastCall().once();
+
+    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory, logicalRequest,
+      configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse, executor,
+      persistedState, securityConfigurationFactory, credentialStoreService, clusterController, resourceProvider,
+      mockFuture, managementController, clusters, cluster, hostRoleCommandInstallComponent3,
+      hostRoleCommandInstallComponent4, hostRoleCommandStartComponent1, hostRoleCommandStartComponent2,
+      serviceComponentInfo, clientComponentInfo);
+
+    Class clazz = TopologyManager.class;
+
+    f = clazz.getDeclaredField("executor");
+    f.setAccessible(true);
+    f.set(topologyManager, executor);
+
+    EasyMockSupport.injectMocks(topologyManager);
+  }
+
+  @After
+  public void tearDown() {
+    verify(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
+      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
+      requestStatusResponse, executor, persistedState, mockFuture,
+      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4,
+      hostRoleCommandStartComponent1, hostRoleCommandStartComponent2);
+
+    reset(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
+      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
+      requestStatusResponse, executor, persistedState, mockFuture,
+      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4,
+      hostRoleCommandStartComponent1, hostRoleCommandStartComponent2);
+  }
+
+  @Test
+  public void testProvisionCluster() throws Exception {
+    topologyManager.provisionCluster(request);
+    LogicalRequest request = topologyManager.getRequest(1);
+    assertEquals(request.getHostRequests().size(), 3);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/930613ec/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
index 78d5538..afc0065 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
@@ -65,6 +65,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.START_ONLY;
 import static org.easymock.EasyMock.anyBoolean;
 import static org.easymock.EasyMock.anyLong;
 import static org.easymock.EasyMock.anyObject;
@@ -292,6 +293,8 @@ public class ClusterInstallWithoutStartTest {
     expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
     expect(group1.containsMasterComponent()).andReturn(true).anyTimes();
     expect(group1.getComponentNames()).andReturn(group1Components).anyTimes();
+    expect(group1.getComponentNames(START_ONLY)).andReturn(Collections.<String>emptyList()).anyTimes();
+
     expect(group1.getComponents("service1")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
     expect(group1.getComponents("service2")).andReturn(group1ServiceComponents.get("service1")).anyTimes();
     expect(group1.getConfiguration()).andReturn(topoGroup1Config).anyTimes();
@@ -303,6 +306,7 @@ public class ClusterInstallWithoutStartTest {
     expect(group2.getCardinality()).andReturn("test cardinality").anyTimes();
     expect(group2.containsMasterComponent()).andReturn(false).anyTimes();
     expect(group2.getComponentNames()).andReturn(group2Components).anyTimes();
+    expect(group2.getComponentNames(START_ONLY)).andReturn(Collections.<String>emptyList()).anyTimes();
     expect(group2.getComponents("service1")).andReturn(group2ServiceComponents.get("service1")).anyTimes();
     expect(group2.getComponents("service2")).andReturn(group2ServiceComponents.get("service2")).anyTimes();
     expect(group2.getConfiguration()).andReturn(topoGroup2Config).anyTimes();
@@ -334,7 +338,6 @@ public class ClusterInstallWithoutStartTest {
     expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();
     expect(ambariContext.getClusterId(CLUSTER_NAME)).andReturn(CLUSTER_ID).anyTimes();
     expect(ambariContext.getClusterName(CLUSTER_ID)).andReturn(CLUSTER_NAME).anyTimes();
-    expect(ambariContext.shouldSkipInstallTasks()).andReturn(false).anyTimes();
     // so only INITIAL config
     expect(ambariContext.createConfigurationRequests(capture(configRequestPropertiesCapture))).
       andReturn(Collections.singletonList(configurationRequest));


Mime
View raw message