|
@@ -8302,6 +8302,89 @@ public class AmbariManagementControllerTest {
|
|
controller.deleteHostComponents(schRequests);
|
|
controller.deleteHostComponents(schRequests);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testDeleteHostComponentInDecomissionState() throws Exception {
|
|
|
|
+ String clusterName = "foo1";
|
|
|
|
+ createCluster(clusterName);
|
|
|
|
+ clusters.getCluster(clusterName)
|
|
|
|
+ .setDesiredStackVersion(new StackId("HDP-1.3.1"));
|
|
|
|
+ String serviceName = "HDFS";
|
|
|
|
+ String mapred = "MAPREDUCE";
|
|
|
|
+ createService(clusterName, serviceName, null);
|
|
|
|
+ createService(clusterName, mapred, null);
|
|
|
|
+ String componentName1 = "NAMENODE";
|
|
|
|
+ String componentName2 = "DATANODE";
|
|
|
|
+ String componentName3 = "HDFS_CLIENT";
|
|
|
|
+ String componentName4 = "JOBTRACKER";
|
|
|
|
+ String componentName5 = "TASKTRACKER";
|
|
|
|
+ String componentName6 = "MAPREDUCE_CLIENT";
|
|
|
|
+
|
|
|
|
+ createServiceComponent(clusterName, serviceName, componentName1, State.INIT);
|
|
|
|
+ createServiceComponent(clusterName, serviceName, componentName2, State.INIT);
|
|
|
|
+ createServiceComponent(clusterName, serviceName, componentName3, State.INIT);
|
|
|
|
+ createServiceComponent(clusterName, mapred, componentName4, State.INIT);
|
|
|
|
+ createServiceComponent(clusterName, mapred, componentName5, State.INIT);
|
|
|
|
+ createServiceComponent(clusterName, mapred, componentName6, State.INIT);
|
|
|
|
+
|
|
|
|
+ String host1 = "h1";
|
|
|
|
+
|
|
|
|
+ addHost(host1, clusterName);
|
|
|
|
+
|
|
|
|
+ createServiceComponentHost(clusterName, serviceName, componentName1, host1, null);
|
|
|
|
+ createServiceComponentHost(clusterName, serviceName, componentName2, host1, null);
|
|
|
|
+ createServiceComponentHost(clusterName, serviceName, componentName3, host1, null);
|
|
|
|
+ createServiceComponentHost(clusterName, mapred, componentName4, host1, null);
|
|
|
|
+ createServiceComponentHost(clusterName, mapred, componentName5, host1, null);
|
|
|
|
+ createServiceComponentHost(clusterName, mapred, componentName6, host1, null);
|
|
|
|
+
|
|
|
|
+ // Install
|
|
|
|
+ installService(clusterName, serviceName, false, false);
|
|
|
|
+ installService(clusterName, mapred, false, false);
|
|
|
|
+
|
|
|
|
+ Cluster cluster = clusters.getCluster(clusterName);
|
|
|
|
+ Service s1 = cluster.getService(serviceName);
|
|
|
|
+ Service s2 = cluster.getService(mapred);
|
|
|
|
+ ServiceComponent sc1 = s1.getServiceComponent(componentName1);
|
|
|
|
+ sc1.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+
|
|
|
|
+ Set<ServiceComponentHostRequest> schRequests = new HashSet<ServiceComponentHostRequest>();
|
|
|
|
+ // delete HC
|
|
|
|
+ schRequests.clear();
|
|
|
|
+ schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, null));
|
|
|
|
+ try {
|
|
|
|
+ controller.deleteHostComponents(schRequests);
|
|
|
|
+ Assert.fail("Expect failure while deleting.");
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ Assert.assertTrue(ex.getMessage().contains(
|
|
|
|
+ "Host Component cannot be removed"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sc1.getServiceComponentHosts().values().iterator().next().setDesiredState(State.STARTED);
|
|
|
|
+ sc1.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+ ServiceComponent sc2 = s1.getServiceComponent(componentName2);
|
|
|
|
+ sc2.getServiceComponentHosts().values().iterator().next().setState(State.INSTALLED);
|
|
|
|
+ sc2.getServiceComponentHosts().values().iterator().next().setMaintenanceState(MaintenanceState.ON);
|
|
|
|
+ sc2.getServiceComponentHosts().values().iterator().next().setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);
|
|
|
|
+ ServiceComponent sc3 = s1.getServiceComponent(componentName3);
|
|
|
|
+ sc3.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+ ServiceComponent sc4 = s2.getServiceComponent(componentName4);
|
|
|
|
+ sc4.getServiceComponentHosts().values().iterator().next().setDesiredState(State.STARTED);
|
|
|
|
+ sc4.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+ ServiceComponent sc5 = s2.getServiceComponent(componentName5);
|
|
|
|
+ sc5.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+ ServiceComponent sc6 = s2.getServiceComponent(componentName6);
|
|
|
|
+ sc6.getServiceComponentHosts().values().iterator().next().setState(State.STARTED);
|
|
|
|
+
|
|
|
|
+ schRequests.clear();
|
|
|
|
+ //schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, null));
|
|
|
|
+ ServiceComponentHostRequest schr2 = new ServiceComponentHostRequest(clusterName, serviceName, componentName2, host1, null);
|
|
|
|
+ schr2.setAdminState("DECOMMISSIONED");
|
|
|
|
+ schRequests.add(schr2);
|
|
|
|
+ controller.deleteHostComponents(schRequests);
|
|
|
|
+ ServiceComponentHost sch = sc1.getServiceComponentHost(host1);
|
|
|
|
+ assertTrue(sch.isRestartRequired());
|
|
|
|
+ }
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testDeleteHost() throws Exception {
|
|
public void testDeleteHost() throws Exception {
|
|
String clusterName = "foo1";
|
|
String clusterName = "foo1";
|