Updated Branches: refs/heads/trunk 08d5fcff9 -> f603882f8
AMBARI-3704. Verify that Stop All/Start All/Start/Stop service does not move a host component out of maintenance. Add unit tests (dsen) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/f603882f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/f603882f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/f603882f Branch: refs/heads/trunk Commit: f603882f81142fe84634c8272026623869134deb Parents: 08d5fcf Author: Dmitry Sen <[email protected]> Authored: Wed Nov 6 18:09:38 2013 +0200 Committer: Dmitry Sen <[email protected]> Committed: Wed Nov 6 18:09:38 2013 +0200 ---------------------------------------------------------------------- .../AmbariManagementControllerTest.java | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f603882f/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java index f014cdf..f332d70 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java @@ -7783,8 +7783,16 @@ public class AmbariManagementControllerTest { componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", null, null)); amc.createHostComponents(componentHostRequests); namenodes = cluster.getService("HDFS").getServiceComponent("NAMENODE").getServiceComponentHosts(); - org.junit.Assert.assertEquals(2, namenodes.size()); + assertEquals(2, namenodes.size()); + // make INSTALLED again + componentHost = namenodes.get("host1"); + componentHost.handleEvent(new ServiceComponentHostInstallEvent(componentHost.getServiceComponentName(), componentHost.getHostName(), System.currentTimeMillis(), "HDP-1.2.0")); + componentHost.handleEvent(new ServiceComponentHostOpSucceededEvent(componentHost.getServiceComponentName(), componentHost.getHostName(), System.currentTimeMillis())); + componentHostRequests.clear(); + componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", null, "INSTALLED")); + amc.updateHostComponents(componentHostRequests, mapRequestProps, true); + assertEquals(State.INSTALLED, namenodes.get("host1").getState()); // make unknown ServiceComponentHost sch = null; @@ -7802,6 +7810,21 @@ public class AmbariManagementControllerTest { amc.updateHostComponents(componentHostRequests, mapRequestProps, false); org.junit.Assert.assertEquals(State.MAINTENANCE, sch.getState()); + // ServiceComponentHost remains in maintenance after service stop + assertEquals(sch.getServiceComponentName(),"DATANODE"); + serviceRequests.clear(); + serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "INSTALLED")); + ServiceResourceProviderTest.updateServices(amc, serviceRequests, + mapRequestProps, true, false); + assertEquals(State.MAINTENANCE, sch.getState()); + + // ServiceComponentHost remains in maintenance after service start + serviceRequests.clear(); + serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "STARTED")); + ServiceResourceProviderTest.updateServices(amc, serviceRequests, + mapRequestProps, true, false); + assertEquals(State.MAINTENANCE, sch.getState()); + // confirm delete componentHostRequests.clear(); componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", null, null));
