ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-21800. Some services had issue coming up after express upgrade on IOP clusters. (unit test fixes) (jonathanhurley)
Date Thu, 24 Aug 2017 14:02:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 42e1b1007 -> 2d1659f17


AMBARI-21800. Some services had issue coming up after express upgrade on IOP clusters. (unit
test fixes) (jonathanhurley)


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

Branch: refs/heads/branch-2.6
Commit: 2d1659f1794d54d1f8172ed5a48af54ba8d860bd
Parents: 42e1b10
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Thu Aug 24 09:58:44 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Thu Aug 24 09:59:30 2017 -0400

----------------------------------------------------------------------
 .../server/metadata/RoleCommandOrderTest.java   | 45 ++++++++++++--------
 .../ambari/server/metadata/RoleGraphTest.java   |  9 +++-
 .../server/stageplanner/TestStagePlanner.java   |  5 +++
 .../server/topology/AmbariContextTest.java      |  3 ++
 4 files changed, 42 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2d1659f1/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
index a8eadb6..7613c17 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
@@ -18,6 +18,15 @@
 
 package org.apache.ambari.server.metadata;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.sql.SQLException;
@@ -55,14 +64,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 
 import junit.framework.Assert;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
 
 public class RoleCommandOrderTest {
 
@@ -95,7 +96,8 @@ public class RoleCommandOrderTest {
     ClusterImpl cluster = createMock(ClusterImpl.class);
     Service service = createMock(Service.class);
     expect(cluster.getClusterId()).andReturn(1L);
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
+    expect(cluster.getClusterName()).andReturn("c1");
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
     expect(cluster.getService("GLUSTERFS")).andReturn(service);
     expect(cluster.getService("HDFS")).andReturn(null);
     expect(cluster.getService("YARN")).andReturn(null);
@@ -138,12 +140,13 @@ public class RoleCommandOrderTest {
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
     Service hdfsService = createMock(Service.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
     expect(cluster.getService("YARN")).andReturn(null).atLeastOnce();
     expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(null);
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
 
     replay(cluster);
     replay(hdfsService);
@@ -181,13 +184,14 @@ public class RoleCommandOrderTest {
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
     Service hdfsService = createMock(Service.class);
     ServiceComponent journalnodeSC = createMock(ServiceComponent.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
     expect(cluster.getService("YARN")).andReturn(null);
     expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(journalnodeSC);
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
 
     replay(cluster);
     replay(hdfsService);
@@ -222,8 +226,9 @@ public class RoleCommandOrderTest {
     ServiceComponentHost sch2 = createMock(ServiceComponentHostImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
 
-    Map<String, ServiceComponentHost> hostComponents = new HashMap<String, ServiceComponentHost>();
+    Map<String, ServiceComponentHost> hostComponents = new HashMap<>();
     hostComponents.put("1",sch1);
     hostComponents.put("2",sch2);
 
@@ -234,7 +239,7 @@ public class RoleCommandOrderTest {
     expect(cluster.getService("HDFS")).andReturn(null);
     expect(yarnService.getServiceComponent("RESOURCEMANAGER")).andReturn(resourcemanagerSC).anyTimes();
     expect(resourcemanagerSC.getServiceComponentHosts()).andReturn(hostComponents).anyTimes();
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
 
     replay(cluster, yarnService, sch1, sch2, resourcemanagerSC);
 
@@ -274,6 +279,7 @@ public class RoleCommandOrderTest {
     ServiceComponentHost sch2 = createMock(ServiceComponentHostImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
 
     Map<String, ServiceComponentHost> hostComponents = new HashMap<>();
     hostComponents.put("1", sch1);
@@ -286,7 +292,7 @@ public class RoleCommandOrderTest {
     expect(cluster.getService("HDFS")).andReturn(null);
     expect(yarnService.getServiceComponent("RESOURCEMANAGER")).andReturn(resourcemanagerSC).anyTimes();
     expect(resourcemanagerSC.getServiceComponentHosts()).andReturn(hostComponents).anyTimes();
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
 
     replay(cluster, yarnService, sch1, sch2, resourcemanagerSC);
 
@@ -373,13 +379,14 @@ public class RoleCommandOrderTest {
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
     Service hdfsService = createMock(Service.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
     expect(cluster.getService("YARN")).andReturn(null);
     expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(null);
     //There is no rco file in this stack, should use default
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.5"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.5"));
 
     replay(cluster);
     replay(hdfsService);
@@ -405,6 +412,7 @@ public class RoleCommandOrderTest {
     Service hbaseService = createMock(Service.class);
     expect(cluster.getService("HBASE")).andReturn(hbaseService).atLeastOnce();
     expect(cluster.getClusterId()).andReturn(1L);
+    expect(cluster.getClusterName()).andReturn("c1");
     expect(hbaseService.getCluster()).andReturn(cluster).anyTimes();
 
     ServiceComponent hbaseMaster = createMock(ServiceComponent.class);
@@ -414,7 +422,7 @@ public class RoleCommandOrderTest {
         "HBASE_MASTER", hbaseMaster);
     expect(hbaseService.getServiceComponents()).andReturn(hbaseComponents).anyTimes();
 
-    Map<String, Service> installedServices = new HashMap<String, Service>();
+    Map<String, Service> installedServices = new HashMap<>();
     installedServices.put("HDFS", hdfsService);
     installedServices.put("HBASE", hbaseService);
     expect(cluster.getServices()).andReturn(installedServices).atLeastOnce();
@@ -424,7 +432,7 @@ public class RoleCommandOrderTest {
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
     expect(cluster.getService("YARN")).andReturn(null);
     expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(null);
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.5"));
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.0.5"));
 
     //replay
     replay(cluster, hdfsService, hbaseService, hbaseMaster, namenode);
@@ -460,6 +468,7 @@ public class RoleCommandOrderTest {
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null).atLeastOnce();
     expect(cluster.getClusterId()).andReturn(1L).atLeastOnce();
+    expect(cluster.getClusterName()).andReturn("c1").atLeastOnce();
     Service hdfsService = createMock(Service.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
@@ -467,7 +476,7 @@ public class RoleCommandOrderTest {
     expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(null);
 
     // There is no rco file in this stack, should use default
-    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.2.0")).atLeastOnce();
+    expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP", "2.2.0")).atLeastOnce();
 
     replay(cluster);
     replay(hdfsService);

http://git-wip-us.apache.org/repos/asf/ambari/blob/2d1659f1/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleGraphTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleGraphTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleGraphTest.java
index 39b7ed4..c67d072 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleGraphTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleGraphTest.java
@@ -19,6 +19,9 @@
 package org.apache.ambari.server.metadata;
 
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.List;
@@ -48,8 +51,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 
 import junit.framework.Assert;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class RoleGraphTest {
 
@@ -76,7 +77,9 @@ public class RoleGraphTest {
   public void testValidateOrder() throws AmbariException {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     when(cluster.getClusterId()).thenReturn(1L);
+    when(cluster.getClusterName()).thenReturn("c1");
 
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
@@ -163,7 +166,9 @@ public class RoleGraphTest {
   public void testGetOrderedHostRoleCommands() throws AmbariException {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     when(cluster.getClusterId()).thenReturn(1L);
+    when(cluster.getClusterName()).thenReturn("c1");
 
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph roleGraph = roleGraphFactory.createNew(rco);

http://git-wip-us.apache.org/repos/asf/ambari/blob/2d1659f1/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
index 3e592b2..32161b9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
@@ -77,6 +77,7 @@ public class TestStagePlanner {
   public void testSingleStagePlan() throws AmbariException {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
 
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
@@ -97,6 +98,7 @@ public class TestStagePlanner {
   public void testMultiStagePlan() {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
@@ -122,6 +124,7 @@ public class TestStagePlanner {
   public void testRestartStagePlan() {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
@@ -151,6 +154,7 @@ public class TestStagePlanner {
   public void testManyStages() {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
@@ -202,6 +206,7 @@ public class TestStagePlanner {
   public void testDependencyOrderedStageCreate() {
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
     RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     rg.setCommandExecutionType(CommandExecutionType.DEPENDENCY_ORDERED);

http://git-wip-us.apache.org/repos/asf/ambari/blob/2d1659f1/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
index 44c948b..d129048 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
@@ -718,6 +718,7 @@ public class AmbariContextTest {
     RepositoryVersionEntity repositoryVersion = createNiceMock(RepositoryVersionEntity.class);
     expect(repositoryVersion.getId()).andReturn(1L).atLeastOnce();
     expect(repositoryVersion.getVersion()).andReturn("1.1.1.1").atLeastOnce();
+    expect(repositoryVersion.getType()).andReturn(RepositoryType.STANDARD).atLeastOnce();
 
     expect(repositoryVersionDAO.findByStack(EasyMock.anyObject(StackId.class))).andReturn(
         Collections.<RepositoryVersionEntity>emptyList()).atLeastOnce();
@@ -752,10 +753,12 @@ public class AmbariContextTest {
     RepositoryVersionEntity repositoryVersion1 = createNiceMock(RepositoryVersionEntity.class);
     expect(repositoryVersion1.getId()).andReturn(1L).atLeastOnce();
     expect(repositoryVersion1.getVersion()).andReturn("1.1.1.1").atLeastOnce();
+    expect(repositoryVersion1.getType()).andReturn(RepositoryType.STANDARD).atLeastOnce();
 
     RepositoryVersionEntity repositoryVersion2 = createNiceMock(RepositoryVersionEntity.class);
     expect(repositoryVersion2.getId()).andReturn(2L).atLeastOnce();
     expect(repositoryVersion2.getVersion()).andReturn("1.1.2.2").atLeastOnce();
+    expect(repositoryVersion2.getType()).andReturn(RepositoryType.STANDARD).atLeastOnce();
 
     expect(repositoryVersionDAO.findByStack(EasyMock.anyObject(StackId.class))).andReturn(
         Arrays.asList(repositoryVersion1, repositoryVersion2)).atLeastOnce();


Mime
View raw message