ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From magyari_san...@apache.org
Subject [1/2] ambari git commit: AMBARI-18553. Provision actions to happen based only on specified dependencies (magyari_sandor)
Date Thu, 20 Oct 2016 16:09:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d9bc653a0 -> 5fdc9f97e


http://git-wip-us.apache.org/repos/asf/ambari/blob/5fdc9f97/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 a03f05b..a2a098f 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,18 +18,8 @@
 
 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.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -38,12 +28,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import junit.framework.Assert;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
-import org.apache.ambari.server.metadata.RoleCommandOrder.RoleCommandPair;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.Service;
@@ -65,9 +52,20 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
+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 {
 
   private Injector injector;
+  private RoleCommandOrderProvider roleCommandOrderProvider;
 
   private final static String TEST_RCO_DATA_FILE = "test_rco_data.json";
 
@@ -75,6 +73,7 @@ public class RoleCommandOrderTest {
   public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
+    roleCommandOrderProvider = injector.getInstance(RoleCommandOrderProvider.class);
   }
 
   @After
@@ -90,18 +89,19 @@ public class RoleCommandOrderTest {
   @Test
   public void testInitializeAtGLUSTERFSCluster() throws AmbariException {
 
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
+
     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.getService("GLUSTERFS")).andReturn(service);
     expect(cluster.getService("HDFS")).andReturn(null);
     expect(cluster.getService("YARN")).andReturn(null);
     replay(cluster);
 
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
+
     Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies();
-    assertTrue("Dependencies are empty before initialization", deps.size() == 0);
-    rco.initialize(cluster);
     assertTrue("Dependencies are loaded after initialization", deps.size() > 0);
     verify(cluster);
 	// Check that HDFS components are not present in dependencies
@@ -133,10 +133,9 @@ public class RoleCommandOrderTest {
   @Test
   public void testInitializeAtHDFSCluster() throws AmbariException {
 
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
-
+    expect(cluster.getClusterId()).andReturn(1L);
     Service hdfsService = createMock(Service.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
@@ -147,9 +146,8 @@ public class RoleCommandOrderTest {
     replay(cluster);
     replay(hdfsService);
 
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies();
-    assertTrue("Dependencies are empty before initialization", deps.size() == 0);
-    rco.initialize(cluster);
     assertTrue("Dependencies are loaded after initialization", deps.size() > 0);
     verify(cluster);
     verify(hdfsService);
@@ -177,10 +175,10 @@ public class RoleCommandOrderTest {
    */
   @Test
   public void testInitializeAtHaHDFSCluster() throws AmbariException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
+
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
-
+    expect(cluster.getClusterId()).andReturn(1L);
     Service hdfsService = createMock(Service.class);
     ServiceComponent journalnodeSC = createMock(ServiceComponent.class);
 
@@ -192,9 +190,8 @@ public class RoleCommandOrderTest {
     replay(cluster);
     replay(hdfsService);
 
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies();
-    assertTrue("Dependencies are empty before initialization", deps.size() == 0);
-    rco.initialize(cluster);
     assertTrue("Dependencies are loaded after initialization", deps.size() > 0);
     verify(cluster);
     verify(hdfsService);
@@ -217,12 +214,12 @@ public class RoleCommandOrderTest {
 
   @Test
   public void testInitializeAtHaRMCluster() throws AmbariException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
+
     ClusterImpl cluster = createMock(ClusterImpl.class);
     ServiceComponentHost sch1 = createMock(ServiceComponentHostImpl.class);
     ServiceComponentHost sch2 = createMock(ServiceComponentHostImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
-
+    expect(cluster.getClusterId()).andReturn(1L);
 
     Map<String, ServiceComponentHost> hostComponents = new HashMap<String, ServiceComponentHost>();
     hostComponents.put("1",sch1);
@@ -239,9 +236,8 @@ public class RoleCommandOrderTest {
 
     replay(cluster, yarnService, sch1, sch2, resourcemanagerSC);
 
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies();
-    assertTrue("Dependencies are empty before initialization", deps.size() == 0);
-    rco.initialize(cluster);
     assertTrue("Dependencies are loaded after initialization", deps.size() > 0);
     verify(cluster, yarnService);
     // Check that GLUSTERFS components are not present in dependencies
@@ -262,7 +258,7 @@ public class RoleCommandOrderTest {
     assertNotNull(rmRoleCommandPairs);
     boolean isZookeeperStartPresent = false;
     for (RoleCommandPair pair : rmRoleCommandPairs) {
-      if (pair.cmd == RoleCommand.START && pair.getRole() == Role.ZOOKEEPER_SERVER)
{
+      if (pair.getCmd() == RoleCommand.START && pair.getRole() == Role.ZOOKEEPER_SERVER)
{
         isZookeeperStartPresent = true;
       }
     }
@@ -271,12 +267,11 @@ public class RoleCommandOrderTest {
 
   @Test
   public void testMissingRestartDependenciesAdded() throws Exception {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = createMock(ClusterImpl.class);
     ServiceComponentHost sch1 = createMock(ServiceComponentHostImpl.class);
     ServiceComponentHost sch2 = createMock(ServiceComponentHostImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
-
+    expect(cluster.getClusterId()).andReturn(1L);
 
     Map<String, ServiceComponentHost> hostComponents = new HashMap<>();
     hostComponents.put("1", sch1);
@@ -293,7 +288,7 @@ public class RoleCommandOrderTest {
 
     replay(cluster, yarnService, sch1, sch2, resourcemanagerSC);
 
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
     verify(cluster, yarnService);
 
@@ -372,10 +367,10 @@ public class RoleCommandOrderTest {
 
   @Test
   public void testInitializeDefault() throws IOException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
+
     ClusterImpl cluster = createMock(ClusterImpl.class);
     expect(cluster.getService("GLUSTERFS")).andReturn(null);
-
+    expect(cluster.getClusterId()).andReturn(1L);
     Service hdfsService = createMock(Service.class);
 
     expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
@@ -387,7 +382,7 @@ public class RoleCommandOrderTest {
     replay(cluster);
     replay(hdfsService);
 
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
     verify(cluster);
     verify(hdfsService);
@@ -395,7 +390,6 @@ public class RoleCommandOrderTest {
 
   @Test
   public void testTransitiveServices() throws AmbariException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = createMock(ClusterImpl.class);
 
     Service hdfsService = createMock(Service.class);
@@ -408,6 +402,7 @@ public class RoleCommandOrderTest {
 
     Service hbaseService = createMock(Service.class);
     expect(cluster.getService("HBASE")).andReturn(hbaseService).atLeastOnce();
+    expect(cluster.getClusterId()).andReturn(1L);
     expect(hbaseService.getCluster()).andReturn(cluster).anyTimes();
 
     ServiceComponent hbaseMaster = createMock(ServiceComponent.class);
@@ -432,7 +427,7 @@ public class RoleCommandOrderTest {
     //replay
     replay(cluster, hdfsService, hbaseService, hbaseMaster, namenode);
 
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
     Set<Service> transitiveServices = rco.getTransitiveServices(
         cluster.getService("HBASE"), RoleCommand.START);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fdc9f97/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 8bead43..28aef22 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,10 +19,6 @@
 package org.apache.ambari.server.metadata;
 
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import junit.framework.Assert;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
@@ -41,15 +37,20 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
-public class RoleGraphTest {
+import junit.framework.Assert;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
+public class RoleGraphTest {
 
   private Injector injector;
+  private RoleCommandOrderProvider roleCommandOrderProvider;
 
   @Before
   public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
+    roleCommandOrderProvider = injector.getInstance(RoleCommandOrderProvider.class);
   }
 
   @After
@@ -59,12 +60,11 @@ public class RoleGraphTest {
 
   @Test
   public void testValidateOrder() throws AmbariException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = mock(ClusterImpl.class);
-
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    when(cluster.getClusterId()).thenReturn(1L);
 
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
     RoleGraphNode datanode_upgrade = new RoleGraphNode(Role.DATANODE, RoleCommand.UPGRADE);
     RoleGraphNode hdfs_client_upgrade = new RoleGraphNode(Role.HDFS_CLIENT, RoleCommand.UPGRADE);
@@ -133,7 +133,7 @@ public class RoleGraphTest {
     when(cluster.getService("HDFS")).thenReturn(hdfsServiceMock);
     when(hdfsServiceMock.getServiceComponent("JOURNALNODE")).thenReturn(jnComponentMock);
 
-    rco.initialize(cluster);
+    rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     Assert.assertEquals(1, rco.order(nn_start, jn_start));
     Assert.assertEquals(1, rco.order(nn_start, zk_server_start));
     Assert.assertEquals(1, rco.order(zkfc_start, nn_start));

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fdc9f97/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 d26816c..7a37224 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
@@ -26,9 +26,11 @@ import java.util.List;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.actionmanager.CommandExecutionType;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.metadata.RoleCommandOrder;
+import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.StackId;
@@ -48,20 +50,21 @@ import com.google.inject.persist.PersistService;
 public class TestStagePlanner {
 
   private Injector injector;
-  private static StageFactory stageFactory;
 
   @Inject
-  StageUtils stageUtils;
-
+  private StageFactory stageFactory;
+  @Inject
+  private RoleCommandOrderProvider roleCommandOrderProvider;
   @Inject
-  RoleGraphFactory roleGraphFactory;
+  private StageUtils stageUtils;
+  @Inject
+  private RoleGraphFactory roleGraphFactory;
 
   @Before
   public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     injector.injectMembers(this);
-    stageFactory = injector.getInstance(StageFactory.class);
   }
 
   @After
@@ -71,11 +74,10 @@ public class TestStagePlanner {
 
   @Test
   public void testSingleStagePlan() throws AmbariException {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
 
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
 
     RoleGraph rg = roleGraphFactory.createNew(rco);
     String hostname = "dummy";
@@ -87,15 +89,14 @@ public class TestStagePlanner {
     }
     assertEquals(1, outStages.size());
     assertEquals(stage.getExecutionCommands(hostname), outStages.get(0)
-        .getExecutionCommands(hostname));
+      .getExecutionCommands(hostname));
   }
 
   @Test
   public void testMultiStagePlan() {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
@@ -118,23 +119,22 @@ public class TestStagePlanner {
 
   @Test
   public void testRestartStagePlan() {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
-    Stage stage = stageFactory.createNew(1, "/tmp", "cluster1", 1L,  "execution command wrapper
test",
-            "clusterHostInfo", "commandParamsStage", "hostParamsStage");
+    Stage stage = stageFactory.createNew(1, "/tmp", "cluster1", 1L, "execution command wrapper
test",
+      "clusterHostInfo", "commandParamsStage", "hostParamsStage");
     stage.setStageId(1);
     stage.addServerActionCommand("RESTART", null, Role.HIVE_METASTORE,
-            RoleCommand.CUSTOM_COMMAND, "cluster1",
-            new ServiceComponentHostServerActionEvent("host2", System.currentTimeMillis()),
-            null, "command detail", null, null, false, false);
+      RoleCommand.CUSTOM_COMMAND, "cluster1",
+      new ServiceComponentHostServerActionEvent("host2", System.currentTimeMillis()),
+      null, "command detail", null, null, false, false);
     stage.addServerActionCommand("RESTART", null, Role.MYSQL_SERVER,
-            RoleCommand.CUSTOM_COMMAND, "cluster1",
-            new ServiceComponentHostServerActionEvent("host2", System.currentTimeMillis()),
-            null, "command detail", null, null, false, false);
+      RoleCommand.CUSTOM_COMMAND, "cluster1",
+      new ServiceComponentHostServerActionEvent("host2", System.currentTimeMillis()),
+      null, "command detail", null, null, false, false);
     System.out.println(stage.toString());
 
     rg.build(stage);
@@ -148,10 +148,9 @@ public class TestStagePlanner {
 
   @Test
   public void testManyStages() {
-    RoleCommandOrder rco = injector.getInstance(RoleCommandOrder.class);
     ClusterImpl cluster = mock(ClusterImpl.class);
     when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
-    rco.initialize(cluster);
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
     RoleGraph rg = roleGraphFactory.createNew(rco);
     long now = System.currentTimeMillis();
     Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
@@ -180,14 +179,14 @@ public class TestStagePlanner {
         RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
             "host6", now), "cluster1", "OOZIE", false, false);
     stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
-        RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
-            "host7", now), "cluster1", "WEBHCAT", false, false);
+      RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
+        "host7", now), "cluster1", "WEBHCAT", false, false);
     stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
-        RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
-            "host4", now), "cluster1", "GANGLIA", false, false);
+      RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
+        "host4", now), "cluster1", "GANGLIA", false, false);
     stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
-        RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
-            "host9", now), "cluster1", "GANGLIA", false, false);
+      RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
+        "host9", now), "cluster1", "GANGLIA", false, false);
     System.out.println(stage.toString());
     rg.build(stage);
     System.out.println(rg.stringifyGraph());
@@ -197,4 +196,56 @@ public class TestStagePlanner {
     }
     assertEquals(4, outStages.size());
   }
+
+  @Test
+  public void testDependencyOrderedStageCreate() {
+    ClusterImpl cluster = mock(ClusterImpl.class);
+    when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.0.6"));
+    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
+    RoleGraph rg = roleGraphFactory.createNew(rco);
+    rg.setCommandExecutionType(CommandExecutionType.DEPENDENCY_ORDERED);
+    long now = System.currentTimeMillis();
+    Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
+    stage.addHostRoleExecutionCommand("host11", Role.SECONDARY_NAMENODE,
+      RoleCommand.START, new ServiceComponentHostStartEvent("SECONDARY_NAMENODE",
+        "host11", now), "cluster1", "HDFS", false, false);
+    stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
+        "host2", now), "cluster1", "HBASE", false, false);
+    stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
+        "host3", now), "cluster1", "ZOOKEEPER", false, false);
+    stage.addHostRoleExecutionCommand("host4", Role.DATANODE,
+      RoleCommand.START, new ServiceComponentHostStartEvent("DATANODE",
+        "host4", now), "cluster1", "HDFS", false, false);
+    stage.addHostRoleExecutionCommand("host4", Role.HBASE_REGIONSERVER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
+        "host4", now), "cluster1", "HBASE", false, false);
+    stage.addHostRoleExecutionCommand("host4", Role.TASKTRACKER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("TASKTRACKER",
+        "host4", now), "cluster1", "MAPREDUCE", false, false);
+    stage.addHostRoleExecutionCommand("host5", Role.JOBTRACKER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("JOBTRACKER",
+        "host5", now), "cluster1", "MAPREDUCE", false, false);
+    stage.addHostRoleExecutionCommand("host6", Role.OOZIE_SERVER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
+        "host6", now), "cluster1", "OOZIE", false, false);
+    stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
+        "host7", now), "cluster1", "WEBHCAT", false, false);
+    stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
+      RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
+        "host4", now), "cluster1", "GANGLIA", false, false);
+    stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
+      RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
+        "host9", now), "cluster1", "GANGLIA", false, false);
+    System.out.println(stage.toString());
+    rg.build(stage);
+    System.out.println(rg.stringifyGraph());
+    List<Stage> outStages = rg.getStages();
+    for (Stage s : outStages) {
+      System.out.println(s.toString());
+    }
+    assertEquals(1, outStages.size());
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fdc9f97/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
index f40e0a1..99bd312 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
@@ -48,7 +48,6 @@ import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.security.authorization.Users;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.stageplanner.RoleGraphFactory;
-import org.apache.ambari.server.stageplanner.RoleGraphFactoryImpl;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ConfigFactory;
@@ -260,7 +259,7 @@ public class ClusterEffectiveVersionTest extends EasyMockSupport {
       binder.bind(ExecutionScheduler.class).toInstance(EasyMock.createNiceMock(ExecutionScheduler.class));
       binder.bind(RequestFactory.class).toInstance(EasyMock.createNiceMock(RequestFactory.class));
       binder.bind(StageFactory.class).toInstance(EasyMock.createNiceMock(StageFactory.class));
-      binder.bind(RoleGraphFactory.class).toInstance(EasyMock.createNiceMock(RoleGraphFactoryImpl.class));
+      binder.bind(RoleGraphFactory.class).toInstance(EasyMock.createNiceMock(RoleGraphFactory.class));
       binder.bind(AbstractRootServiceResponseFactory.class).toInstance(EasyMock.createNiceMock(AbstractRootServiceResponseFactory.class));
       binder.bind(ConfigFactory.class).toInstance(EasyMock.createNiceMock(ConfigFactory.class));
       binder.bind(ConfigGroupFactory.class).toInstance(EasyMock.createNiceMock(ConfigGroupFactory.class));


Mime
View raw message