Repository: ambari
Updated Branches:
  refs/heads/trunk 4fcdaae4c -> cd769e2e7


AMBARI-20984 Be able to include stack repos in blueprint (dili)


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

Branch: refs/heads/trunk
Commit: cd769e2e79de11519b333aa86c4c54e68be40996
Parents: 4fcdaae
Author: Di Li <d...@apache.org>
Authored: Tue May 23 12:03:53 2017 -0400
Committer: Di Li <d...@apache.org>
Committed: Tue May 23 12:03:53 2017 -0400

----------------------------------------------------------------------
 .../server/api/services/AmbariMetaInfo.java     |  21 ++++
 .../ambari/server/topology/Blueprint.java       |   3 +
 .../ambari/server/topology/BlueprintImpl.java   |  33 +++++-
 .../server/topology/RepositorySetting.java      | 116 +++++++++++++++++++
 .../apache/ambari/server/topology/Setting.java  |   2 +
 .../ambari/server/topology/TopologyManager.java |  49 +++++++-
 .../ClusterDeployWithStartOnlyTest.java         |   5 +-
 ...InstallWithoutStartOnComponentLevelTest.java |   5 +-
 .../ClusterInstallWithoutStartTest.java         |   7 +-
 .../ambari/server/topology/SettingTest.java     |  18 +++
 .../server/topology/TopologyManagerTest.java    |   5 +-
 11 files changed, 250 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index c655c62..b509e97 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -934,6 +934,27 @@ public class AmbariMetaInfo {
     }
   }
 
+  public void createRepo(String stackName, String stackVersion, String osType, 
String repoId, String baseUrl, String mirrorsList) throws AmbariException {
+    if (!stackRoot.exists()) {
+      throw new StackAccessException("Create repo - Stack root does not 
exist.");
+    }
+
+    if (null != baseUrl) {
+      createRepoInMetaInfo(stackName, stackVersion, osType, repoId, baseUrl, 
REPOSITORY_XML_PROPERTY_BASEURL);
+    } else if (null != mirrorsList) {
+      createRepoInMetaInfo(stackName, stackVersion, osType, repoId, 
mirrorsList, REPOSITORY_XML_PROPERTY_MIRRORSLIST);
+    }
+  }
+
+  private void createRepoInMetaInfo(String stackName, String stackVersion, 
String osType, String repoId, String value, String repositoryXmlProperty) {
+    String metaKey = generateRepoMetaKey(stackName, stackVersion, osType,
+        repoId, repositoryXmlProperty);
+    MetainfoEntity entity = new MetainfoEntity();
+    entity.setMetainfoName(metaKey);
+    entity.setMetainfoValue(value);
+    metaInfoDAO.create(entity);
+  }
+
   public File getStackRoot() {
     return stackRoot;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
index 139a1ee..99e1c75 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.topology;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.ambari.server.controller.internal.Stack;
@@ -167,4 +168,6 @@ public interface Blueprint {
    * @return entity representation of the blueprint
    */
   BlueprintEntity toEntity();
+
+  List<RepositorySetting> getRepositorySettings();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
index 826e4e5..415efd8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -56,6 +57,7 @@ public class BlueprintImpl implements Blueprint {
   private BlueprintValidator validator;
   private SecurityConfiguration security;
   private Setting setting;
+  private List<RepositorySetting> repoSettings;
 
   public BlueprintImpl(BlueprintEntity entity) throws NoSuchStackException {
     this.name = entity.getBlueprintName();
@@ -72,6 +74,7 @@ public class BlueprintImpl implements Blueprint {
     
configuration.setParentConfiguration(stack.getConfiguration(getServices()));
     validator = new BlueprintValidatorImpl(this);
     processSetting(entity.getSettings());
+    processRepoSettings();
   }
 
   public BlueprintImpl(String name, Collection<HostGroup> groups, Stack stack, 
Configuration configuration,
@@ -363,7 +366,7 @@ public class BlueprintImpl implements Blueprint {
     } catch (StackAccessException e) {
       throw new NoSuchStackException(stackEntity.getStackName(), 
stackEntity.getStackVersion());
     } catch (AmbariException e) {
-    //todo:
+      //todo:
       throw new RuntimeException("An error occurred parsing the stack 
information.", e);
     }
   }
@@ -615,4 +618,32 @@ public class BlueprintImpl implements Blueprint {
     }
     return false;
   }
+
+  /**
+   * Parse stack repo info stored in the blueprint_settings table
+   * @return set of repositories
+   * */
+  private void processRepoSettings(){
+    repoSettings = new ArrayList<RepositorySetting>();
+    if (setting != null){
+      Set<HashMap<String, String>> settingValue = 
setting.getSettingValue(Setting.SETTING_NAME_REPOSITORY_SETTINGS);
+      for (Map<String, String> setting : settingValue) {
+        RepositorySetting rs = parseRepositorySetting(setting);
+        repoSettings.add(rs);
+      }
+    }
+  }
+
+  private RepositorySetting parseRepositorySetting(Map<String, String> 
setting){
+    RepositorySetting result = new RepositorySetting();
+    result.setOperatingSystem(setting.get(RepositorySetting.OPERATING_SYSTEM));
+    
result.setOverrideStrategy(setting.get(RepositorySetting.OVERRIDE_STRATEGY));
+    result.setRepoId(setting.get(RepositorySetting.REPO_ID));
+    result.setBaseUrl(setting.get(RepositorySetting.BASE_URL));
+    return result;
+  }
+
+  public List<RepositorySetting> getRepositorySettings(){
+    return repoSettings;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositorySetting.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositorySetting.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositorySetting.java
new file mode 100644
index 0000000..35e370e
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositorySetting.java
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.topology;
+
+public class RepositorySetting {
+  /**
+   * Settings for each repo setting sections
+   */
+  public static final String OVERRIDE_STRATEGY = "override_strategy";
+  public static final String OVERRIDE_STRATEGY_ALWAYS_APPLY = "ALWAYS_APPLY";
+  public static final String OVERRIDE_STRATEGY_APPLY_WHEN_MISSING = 
"APPLY_WHEN_MISSING";
+  public static final String OPERATING_SYSTEM = "operating_system";
+  public static final String REPO_ID = "repo_id";
+  public static final String BASE_URL = "base_url";
+
+  private String overrideStrategy;
+  private String operatingSystem;
+  private String repoId;
+  private String baseUrl;
+
+  /**
+   * When specified under the "settings" section, it allows Ambari to 
overwrite existing repos stored
+   * in the metainfo table in the Ambari server database.
+   * Two override strategies
+   * ALWAYS_APPLY will override the existing repo. If repo does not exists, 
add it.
+   * APPLY_WHEN_MISSING will only add the repo info to the table if there is 
no such entries yet.
+   *
+   *   <pre>
+   *     {@code
+   *       "settings" : [
+   *       {
+   *            "repository_settings" : [
+   *            {
+   *              "override_strategy":"ALWAYS_APPLY",
+   *              "operating_system":"redhat7",
+   *              "repo_id":"HDP-2.6",
+   *              
"base_url":"http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos7/2.x/BUILDS/2.6.0.3-8";
+   *            },
+   *            {
+   *              "override_strategy":"APPLY_WHEN_MISSING",
+   *              "operating_system":"redhat7",
+   *              "repo_id": "HDP-UTILS-1.1.0.21",
+   *              "repo_name": "HDP-UTILS",
+   *              "base_url": 
"http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7";
+   *            }
+   *          ]
+   *       }]
+   *     }
+   *   </pre>
+   */
+  public String getOverrideStrategy() {
+    return overrideStrategy;
+  }
+
+  public void setOverrideStrategy(String overrideStrategy) {
+    this.overrideStrategy = overrideStrategy;
+  }
+
+  /**
+   * Get repository id
+   * */
+  public String getOperatingSystem() {
+    return operatingSystem;
+  }
+
+  public void setOperatingSystem(String operatingSystem) {
+    this.operatingSystem = operatingSystem;
+  }
+
+  /**
+   * Get repository id
+   * */
+  public String getRepoId() {
+    return repoId;
+  }
+
+  public void setRepoId(String repoId) {
+    this.repoId = repoId;
+  }
+
+  /**
+   * Get repository url
+   * */
+  public String getBaseUrl() {
+    return baseUrl;
+  }
+
+  public void setBaseUrl(String baseUrl) {
+    this.baseUrl = baseUrl;
+  }
+
+  public String toString(){
+    StringBuilder strBldr = new StringBuilder();
+    strBldr.append(OVERRIDE_STRATEGY);strBldr.append(": 
");strBldr.append(overrideStrategy);
+    strBldr.append(OPERATING_SYSTEM);strBldr.append(": 
");strBldr.append(operatingSystem);
+    strBldr.append(REPO_ID);strBldr.append(": ");strBldr.append(repoId);
+    strBldr.append(BASE_URL);strBldr.append(": ");strBldr.append(baseUrl);
+    return strBldr.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
index 555192c..df31e4b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
@@ -43,6 +43,8 @@ public class Setting {
 
   public static final String SETTING_NAME_NAME = "name";
 
+  public static final String SETTING_NAME_REPOSITORY_SETTINGS = 
"repository_settings";
+
   /**
    * When specified under the "service_settings" section, it indicates whether 
credential store
    * use is enabled for that service. Value is "true" or "false". Specify a 
value of "true"

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index f5cf498..14bc446 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -33,11 +33,10 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-import javax.inject.Inject;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariServer;
@@ -80,6 +79,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.eventbus.Subscribe;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
 import com.google.inject.Singleton;
 import com.google.inject.persist.Transactional;
 
@@ -116,6 +117,9 @@ public class TopologyManager {
   private Map<Long, ClusterTopology> clusterTopologyMap = new HashMap<>();
 
   @Inject
+  private Injector injector;
+
+  @Inject
   private StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor;
 
   @Inject
@@ -290,6 +294,11 @@ public class TopologyManager {
 
     topologyValidatorService.validateTopologyConfiguration(topology);
 
+    if (repoVersion == null){
+      //Override repos stored in the metainfo table with ones included in the 
blueprint
+      updateRepos(topology.getBlueprint().getRepositorySettings(), stack);
+    }
+
     // create resources
     ambariContext.createAmbariResources(topology, clusterName, securityType, 
repoVersion);
 
@@ -324,7 +333,6 @@ public class TopologyManager {
     addClusterConfigRequest(topology, new 
ClusterConfigurationRequest(ambariContext, topology, true,
       stackAdvisorBlueprintProcessor, securityType == SecurityType.KERBEROS));
 
-
     // Notify listeners that cluster configuration finished
     executor.submit(new Callable<Boolean>() {
       @Override
@@ -345,6 +353,41 @@ public class TopologyManager {
     return getRequestStatus(logicalRequest.getRequestId());
   }
 
+  void updateRepos(List<RepositorySetting> repoSettings, Stack stack) {
+    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+    boolean repoExists = false;
+    String stackName = stack.getName();
+    String stackVersion = stack.getVersion();
+    for (RepositorySetting repoSetting: repoSettings){
+      String repoSettingDetails = repoSetting.toString();
+      LOG.info(String.format("New repository setting: %s ", 
repoSettingDetails));
+      String operatingSystem = repoSetting.getOperatingSystem();
+      String repoId = repoSetting.getRepoId();
+      try {
+        ambariMetaInfo.getRepository(stackName, stackVersion, operatingSystem, 
repoId);
+        repoExists = true;
+      } catch (AmbariException e){
+        repoExists = false;
+      }
+      LOG.info(String.format("Repo exists: %s ", repoExists));
+      String overrideStrategy = repoSetting.getOverrideStrategy();
+      if (repoExists){
+        if 
(RepositorySetting.OVERRIDE_STRATEGY_ALWAYS_APPLY.equals(overrideStrategy)){
+          try {
+            ambariMetaInfo.updateRepo(stackName, stackVersion, 
operatingSystem, repoId, repoSetting.getBaseUrl(), null);
+          } catch (AmbariException e) {
+            LOG.error(String.format("Failed to update repo with information 
%s", repoSettingDetails), e);
+          }
+        }
+      } else {
+        try {
+          ambariMetaInfo.createRepo(stackName, stackVersion, operatingSystem, 
repoId, repoSetting.getBaseUrl(), null);
+        } catch (AmbariException e) {
+          LOG.error(String.format("Failed to insert repo with information %s", 
repoSettingDetails), e);
+        }
+      }
+    }
+  }
 
   /**
    * Saves the quick links profile to the DB as an Ambari setting. Creates a 
new setting entity or updates the existing

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/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
index c8d4d55..26ba56d 100644
--- 
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
@@ -252,6 +252,7 @@ public class ClusterDeployWithStartOnlyTest extends 
EasyMockSupport {
     expect(blueprint.getServices()).andReturn(Arrays.asList("service1", 
"service2")).anyTimes();
     expect(blueprint.getStack()).andReturn(stack).anyTimes();
     
expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes();
+    expect(blueprint.getRepositorySettings()).andReturn(new 
ArrayList<RepositorySetting>()).anyTimes();
     // don't expect toEntity()
 
     
expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site",
 "service1-env")).anyTimes();
@@ -293,7 +294,7 @@ public class ClusterDeployWithStartOnlyTest extends 
EasyMockSupport {
     
expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     
expect(request.getProvisionAction()).andReturn(ProvisionAction.START_ONLY).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
-
+    expect(request.getRepositoryVersion()).andReturn("1").anyTimes();
 
     expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
     expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
@@ -337,7 +338,7 @@ public class ClusterDeployWithStartOnlyTest extends 
EasyMockSupport {
 
     
expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
     //todo: don't ignore param
-    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), (String) isNull());
+    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), eq("1"));
     expectLastCall().once();
     expect(ambariContext.getNextRequestId()).andReturn(1L).once();
     
expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
index 4c9815c..f01cbfe 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
@@ -248,6 +248,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest 
extends EasyMockSupp
     expect(blueprint.getServices()).andReturn(Arrays.asList("service1", 
"service2")).anyTimes();
     expect(blueprint.getStack()).andReturn(stack).anyTimes();
     
expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes();
+    expect(blueprint.getRepositorySettings()).andReturn(new 
ArrayList<RepositorySetting>()).anyTimes();
     // don't expect toEntity()
 
     
expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site",
 "service1-env")).anyTimes();
@@ -289,7 +290,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest 
extends EasyMockSupp
     
expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     
expect(request.getProvisionAction()).andReturn(INSTALL_AND_START).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
-
+    expect(request.getRepositoryVersion()).andReturn("1").anyTimes();
 
     expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
     expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
@@ -339,7 +340,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest 
extends EasyMockSupp
 
     
expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
     //todo: don't ignore param
-    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), (String) isNull());
+    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), (String) eq("1"));
     expectLastCall().once();
     expect(ambariContext.getNextRequestId()).andReturn(1L).once();
     
expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/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 1bdeb1b..b2284a8 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
@@ -82,6 +82,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AmbariServer.class)
 public class ClusterInstallWithoutStartTest extends EasyMockSupport {
+
   private static final String CLUSTER_NAME = "test-cluster";
   private static final long CLUSTER_ID = 1;
   private static final String BLUEPRINT_NAME = "test-bp";
@@ -249,6 +250,7 @@ public class ClusterInstallWithoutStartTest extends 
EasyMockSupport {
     expect(blueprint.getServices()).andReturn(Arrays.asList("service1", 
"service2")).anyTimes();
     expect(blueprint.getStack()).andReturn(stack).anyTimes();
     
expect(blueprint.isValidConfigType(anyString())).andReturn(true).anyTimes();
+    expect(blueprint.getRepositorySettings()).andReturn(new 
ArrayList<RepositorySetting>()).anyTimes();
     // don't expect toEntity()
 
     
expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site",
 "service1-env")).anyTimes();
@@ -287,11 +289,10 @@ public class ClusterInstallWithoutStartTest extends 
EasyMockSupport {
     expect(request.getDescription()).andReturn("Provision Cluster 
Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-
     
expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     expect(request.getProvisionAction()).andReturn(INSTALL_ONLY).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
-
+    expect(request.getRepositoryVersion()).andReturn("1").anyTimes();
 
     expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
     expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
@@ -336,7 +337,7 @@ public class ClusterInstallWithoutStartTest extends 
EasyMockSupport {
 
     
expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
     //todo: don't ignore param
-    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), (String) isNull());
+    ambariContext.createAmbariResources(isA(ClusterTopology.class), 
eq(CLUSTER_NAME), (SecurityType) isNull(), eq("1"));
     expectLastCall().once();
     expect(ambariContext.getNextRequestId()).andReturn(1L).once();
     
expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/test/java/org/apache/ambari/server/topology/SettingTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/SettingTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/SettingTest.java
index 0007acf..ccd3b0c 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/SettingTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/SettingTest.java
@@ -40,6 +40,7 @@ public class SettingTest {
     Set<HashMap<String, String>> setting1 = new HashSet<>();
     Set<HashMap<String, String>> setting2 = new HashSet<>();
     Set<HashMap<String, String>> setting3 = new HashSet<>();
+    Set<HashMap<String, String>> setting4 = new HashSet<>();
 
     // Setting 1: Property1
     HashMap<String, String> setting1Properties1 = new HashMap<>();
@@ -58,13 +59,30 @@ public class SettingTest {
     setting2.add(setting2Properties1);
     setting2.add(setting2Properties2);
 
+    //Setting 3: Property 1
     HashMap<String, String> setting3Properties1 = new HashMap<>();
     setting1Properties1.put(Setting.SETTING_NAME_SKIP_FAILURE, "true");
     setting1.add(setting3Properties1);
 
+    //Setting 4: Property 1 and 2
+    HashMap<String, String> setting4Properties1 = new HashMap<>();
+    setting4Properties1.put(RepositorySetting.OVERRIDE_STRATEGY, 
RepositorySetting.OVERRIDE_STRATEGY_ALWAYS_APPLY);
+    setting4Properties1.put(RepositorySetting.OPERATING_SYSTEM, "redhat7");
+    setting4Properties1.put(RepositorySetting.REPO_ID, "HDP");
+    setting4Properties1.put(RepositorySetting.BASE_URL, 
"http://localhost/repo";);
+    setting4.add(setting4Properties1);
+
+    HashMap<String, String> setting4Properties2 = new HashMap<>();
+    setting4Properties2.put(RepositorySetting.OVERRIDE_STRATEGY, 
RepositorySetting.OVERRIDE_STRATEGY_ALWAYS_APPLY);
+    setting4Properties2.put(RepositorySetting.OPERATING_SYSTEM, "redhat7");
+    setting4Properties2.put(RepositorySetting.REPO_ID, "HDP-UTIL");
+    setting4Properties2.put(RepositorySetting.BASE_URL, 
"http://localhost/repo";);
+    setting4.add(setting4Properties2);
+
     properties.put(Setting.SETTING_NAME_RECOVERY_SETTINGS, setting1);
     properties.put(Setting.SETTING_NAME_SERVICE_SETTINGS, setting2);
     properties.put(Setting.SETTING_NAME_DEPLOYMENT_SETTINGS, setting3);
+    properties.put(Setting.SETTING_NAME_REPOSITORY_SETTINGS, setting4);
 
     Setting setting = new Setting(properties);
     assertEquals(properties, setting.getProperties());

http://git-wip-us.apache.org/repos/asf/ambari/blob/cd769e2e/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
index 02cc64f..06efb9e 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
@@ -100,7 +100,6 @@ public class TopologyManagerTest {
   private static final String SAMPLE_QUICKLINKS_PROFILE_2 =
       
"{\"filters\":[],\"services\":[{\"name\":\"HDFS\",\"components\":[],\"filters\":[{\"visible\":true}]}]}";
 
-
   @Rule
   public EasyMockRule mocks = new EasyMockRule(this);
 
@@ -254,6 +253,7 @@ public class TopologyManagerTest {
     expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).anyTimes();
     expect(blueprint.getServices()).andReturn(Arrays.asList("service1", 
"service2")).anyTimes();
     expect(blueprint.getStack()).andReturn(stack).anyTimes();
+    expect(blueprint.getRepositorySettings()).andReturn(new 
ArrayList<RepositorySetting>()).anyTimes();
     // don't expect toEntity()
 
     
expect(stack.getAllConfigurationTypes("service1")).andReturn(Arrays.asList("service1-site",
 "service1-env")).anyTimes();
@@ -283,9 +283,8 @@ public class TopologyManagerTest {
     expect(request.getDescription()).andReturn("Provision Cluster 
Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-
+    expect(request.getRepositoryVersion()).andReturn("1").anyTimes();
     
expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY).anyTimes();
-
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
 
 

Reply via email to