ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [1/2] ambari git commit: AMBARI-21552 - Pass Repository ID To Upgrade Prechecks (jonathanhurley)
Date Sat, 22 Jul 2017 03:49:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 348f44e7b -> eb598e855


http://git-wip-us.apache.org/repos/asf/ambari/blob/eb598e85/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
index 65505fa..29bc300 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.models.HostComponentSummary;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -39,6 +40,7 @@ import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
@@ -61,12 +63,23 @@ public class ServicesUpCheckTest {
   private final Clusters clusters = Mockito.mock(Clusters.class);
   private AmbariMetaInfo ambariMetaInfo = Mockito.mock(AmbariMetaInfo.class);
 
+  final RepositoryVersionEntity m_repositoryVersion = Mockito.mock(RepositoryVersionEntity.class);
+
+  /**
+   *
+   */
+  @Before
+  public void setup() {
+    Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.0.0-1234");
+    Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new StackId("HDP", "2.2"));
+  }
+
   @Test
   public void testIsApplicable() throws Exception {
     PrereqCheckRequest checkRequest = new PrereqCheckRequest("c1");
-    checkRequest.setRepositoryVersion("HDP-2.2.0.0");
     checkRequest.setSourceStackId(new StackId("HDP", "2.2"));
-    checkRequest.setTargetStackId(new StackId("HDP", "2.2"));
+    checkRequest.setTargetRepositoryVersion(m_repositoryVersion);
+
     ServicesUpCheck suc = new ServicesUpCheck();
     Configuration config = Mockito.mock(Configuration.class);
     suc.config = config;
@@ -116,7 +129,7 @@ public class ServicesUpCheckTest {
     final Service tezService = Mockito.mock(Service.class);
     final Service amsService = Mockito.mock(Service.class);
 
-    HashMap<String, Service> clusterServices = new HashMap<String, Service>();
+    HashMap<String, Service> clusterServices = new HashMap<>();
     clusterServices.put("HDFS", hdfsService);
     clusterServices.put("TEZ", tezService);
     clusterServices.put("AMBARI_METRICS", amsService);
@@ -148,7 +161,7 @@ public class ServicesUpCheckTest {
 
     // Put Components inside Services
     // HDFS
-    Map<String, ServiceComponent> hdfsComponents = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> hdfsComponents = new HashMap<>();
 
     ServiceComponent nameNode = Mockito.mock(ServiceComponent.class);
     Mockito.when(nameNode.getName()).thenReturn("NAMENODE");
@@ -175,7 +188,7 @@ public class ServicesUpCheckTest {
     Mockito.when(hdfsService.getServiceComponents()).thenReturn(hdfsComponents);
 
     // TEZ
-    Map<String, ServiceComponent> tezComponents = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> tezComponents = new HashMap<>();
 
     ServiceComponent tezClient = Mockito.mock(ServiceComponent.class);
     Mockito.when(tezClient.getName()).thenReturn("TEZ_CLIENT");
@@ -187,7 +200,7 @@ public class ServicesUpCheckTest {
     Mockito.when(tezService.getServiceComponents()).thenReturn(tezComponents);
 
     // AMS
-    Map<String, ServiceComponent> amsComponents = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> amsComponents = new HashMap<>();
 
     ServiceComponent metricsCollector = Mockito.mock(ServiceComponent.class);
     Mockito.when(metricsCollector.getName()).thenReturn("METRICS_COLLECTOR");
@@ -223,7 +236,7 @@ public class ServicesUpCheckTest {
     Mockito.when(hcsMetricsCollector.getHostId()).thenReturn(Long.valueOf(1));
     Mockito.when(hcsMetricsMonitor.getHostId()).thenReturn(Long.valueOf(1));
 
-    List<HostComponentSummary> allHostComponentSummaries = new ArrayList<HostComponentSummary>();
+    List<HostComponentSummary> allHostComponentSummaries = new ArrayList<>();
     allHostComponentSummaries.add(hcsNameNode);
     allHostComponentSummaries.add(hcsDataNode1);
     allHostComponentSummaries.add(hcsDataNode2);

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb598e85/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
index 5c423b5..5cb666b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
@@ -50,6 +50,8 @@ public class YarnTimelineServerStatePreservingCheckTest {
 
   private final YarnTimelineServerStatePreservingCheck m_check = new YarnTimelineServerStatePreservingCheck();
 
+  final RepositoryVersionEntity m_repositoryVersion = Mockito.mock(RepositoryVersionEntity.class);
+
   /**
    *
    */
@@ -64,6 +66,9 @@ public class YarnTimelineServerStatePreservingCheckTest {
     };
     Configuration config = Mockito.mock(Configuration.class);
     m_check.config = config;
+
+    Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.3.0.0-1234");
+    Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new StackId("HDP", "2.3"));
   }
 
   /**
@@ -89,7 +94,7 @@ public class YarnTimelineServerStatePreservingCheckTest {
         m_check.getClass().getName())).thenReturn(checkProperties);
 
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
-    request.setRepositoryVersion("2.3.0.0");
+    request.setTargetRepositoryVersion(m_repositoryVersion);
     request.setPrerequisiteCheckConfig(prerequisiteCheckConfig);
 
     // YARN not installed

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb598e85/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
index 2a48fa6..3de20e4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
@@ -121,9 +121,9 @@ public class PreUpgradeCheckResourceProviderTest {
     expect(targetStackId.getStackName()).andReturn("Stack100").anyTimes();
     expect(targetStackId.getStackVersion()).andReturn("1.1").anyTimes();
 
-    expect(repoDao.findByStackNameAndVersion("Stack100", "Repo100")).andReturn(repo).anyTimes();
+    expect(repoDao.findByPK(1L)).andReturn(repo).anyTimes();
     expect(repo.getStackId()).andReturn(targetStackId).atLeastOnce();
-    expect(upgradeHelper.suggestUpgradePack("Cluster100", "1.0", "Repo100", Direction.UPGRADE,
UpgradeType.NON_ROLLING, "upgrade_pack11")).andReturn(upgradePack);
+    expect(upgradeHelper.suggestUpgradePack("Cluster100", currentStackId, targetStackId,
Direction.UPGRADE, UpgradeType.NON_ROLLING, "upgrade_pack11")).andReturn(upgradePack);
 
     List<AbstractCheckDescriptor> upgradeChecksToRun = new LinkedList<>();
     List<String> prerequisiteChecks = new LinkedList<>();
@@ -147,7 +147,7 @@ public class PreUpgradeCheckResourceProviderTest {
     Predicate predicate = builder.property(PreUpgradeCheckResourceProvider.UPGRADE_CHECK_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").and()
         .property(PreUpgradeCheckResourceProvider.UPGRADE_CHECK_UPGRADE_PACK_PROPERTY_ID).equals("upgrade_pack11").and()
         .property(PreUpgradeCheckResourceProvider.UPGRADE_CHECK_UPGRADE_TYPE_PROPERTY_ID).equals(UpgradeType.NON_ROLLING).and()
-        .property(PreUpgradeCheckResourceProvider.UPGRADE_CHECK_REPOSITORY_VERSION_PROPERTY_ID).equals("Repo100").toPredicate();
+        .property(PreUpgradeCheckResourceProvider.UPGRADE_CHECK_TARGET_REPOSITORY_VERSION_ID_ID).equals("1").toPredicate();
 
 
     System.out.println("PreUpgradeCheckResourceProvider - " + provider);

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb598e85/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index 8cf7373..f0b884b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -191,15 +191,15 @@ public class UpgradeHelperTest extends EasyMockSupport {
   @Test
   public void testSuggestUpgradePack() throws Exception{
     final String clusterName = "c1";
-    final String upgradeFromVersion = "2.1.1";
-    final String upgradeToVersion = "2.2.0";
+    final StackId sourceStackId = new StackId("HDP", "2.1.1");
+    final StackId targetStackId = new StackId("HDP", "2.2.0");
     final Direction upgradeDirection = Direction.UPGRADE;
     final UpgradeType upgradeType = UpgradeType.ROLLING;
 
     makeCluster();
     try {
       String preferredUpgradePackName = "upgrade_test";
-      UpgradePack up = m_upgradeHelper.suggestUpgradePack(clusterName, upgradeFromVersion,
upgradeToVersion, upgradeDirection, upgradeType, preferredUpgradePackName);
+      UpgradePack up = m_upgradeHelper.suggestUpgradePack(clusterName, sourceStackId, targetStackId,
upgradeDirection, upgradeType, preferredUpgradePackName);
       assertEquals(upgradeType, up.getType());
     } catch (AmbariException e){
       assertTrue(false);
@@ -1734,8 +1734,8 @@ public class UpgradeHelperTest extends EasyMockSupport {
   @Test
   public void testRollingUpgradesCanUseAdvancedGroupings() throws Exception {
     final String clusterName = "c1";
-    final String upgradeFromVersion = "2.1.1";
-    final String upgradeToVersion = "2.2.0";
+    final StackId sourceStackId = new StackId("HDP", "2.1.1");
+    final StackId targetStackId = new StackId("HDP", "2.2.0");
     final Direction upgradeDirection = Direction.UPGRADE;
     final UpgradeType upgradeType = UpgradeType.ROLLING;
 
@@ -1743,8 +1743,8 @@ public class UpgradeHelperTest extends EasyMockSupport {
 
     // grab the right pack
     String preferredUpgradePackName = "upgrade_grouping_rolling";
-    UpgradePack upgradePack = m_upgradeHelper.suggestUpgradePack(clusterName, upgradeFromVersion,
-        upgradeToVersion, upgradeDirection, upgradeType, preferredUpgradePackName);
+    UpgradePack upgradePack = m_upgradeHelper.suggestUpgradePack(clusterName, sourceStackId,
+        targetStackId, upgradeDirection, upgradeType, preferredUpgradePackName);
 
     assertEquals(upgradeType, upgradePack.getType());
 


Mime
View raw message