|
@@ -18,45 +18,13 @@
|
|
|
|
|
|
package org.apache.ambari.server.controller;
|
|
|
|
|
|
-import static org.easymock.EasyMock.capture;
|
|
|
-import static org.easymock.EasyMock.createNiceMock;
|
|
|
-import static org.easymock.EasyMock.createStrictMock;
|
|
|
-import static org.easymock.EasyMock.expect;
|
|
|
-import static org.easymock.EasyMock.replay;
|
|
|
-import static org.easymock.EasyMock.verify;
|
|
|
-import static org.hamcrest.CoreMatchers.is;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertFalse;
|
|
|
-import static org.junit.Assert.assertNotNull;
|
|
|
-import static org.junit.Assert.assertNull;
|
|
|
-import static org.junit.Assert.assertSame;
|
|
|
-import static org.junit.Assert.assertThat;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
-import static org.junit.Assert.fail;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.StringReader;
|
|
|
-import java.lang.reflect.Type;
|
|
|
-import java.net.ConnectException;
|
|
|
-import java.net.MalformedURLException;
|
|
|
-import java.net.UnknownHostException;
|
|
|
-import java.text.MessageFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Properties;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-import javax.persistence.EntityManager;
|
|
|
-
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
+import com.google.inject.AbstractModule;
|
|
|
+import com.google.inject.Guice;
|
|
|
+import com.google.inject.Injector;
|
|
|
+import com.google.inject.persist.PersistService;
|
|
|
import junit.framework.Assert;
|
|
|
-
|
|
|
import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.ClusterNotFoundException;
|
|
|
import org.apache.ambari.server.DuplicateResourceException;
|
|
@@ -96,7 +64,30 @@ import org.apache.ambari.server.orm.dao.HostDAO;
|
|
|
import org.apache.ambari.server.orm.entities.ExecutionCommandEntity;
|
|
|
import org.apache.ambari.server.security.authorization.Users;
|
|
|
import org.apache.ambari.server.serveraction.ServerAction;
|
|
|
-import org.apache.ambari.server.state.*;
|
|
|
+import org.apache.ambari.server.state.Cluster;
|
|
|
+import org.apache.ambari.server.state.Clusters;
|
|
|
+import org.apache.ambari.server.state.Config;
|
|
|
+import org.apache.ambari.server.state.ConfigFactory;
|
|
|
+import org.apache.ambari.server.state.ConfigHelper;
|
|
|
+import org.apache.ambari.server.state.ConfigImpl;
|
|
|
+import org.apache.ambari.server.state.Host;
|
|
|
+import org.apache.ambari.server.state.HostComponentAdminState;
|
|
|
+import org.apache.ambari.server.state.HostState;
|
|
|
+import org.apache.ambari.server.state.MaintenanceState;
|
|
|
+import org.apache.ambari.server.state.RepositoryInfo;
|
|
|
+import org.apache.ambari.server.state.RepositoryVersionState;
|
|
|
+import org.apache.ambari.server.state.SecurityType;
|
|
|
+import org.apache.ambari.server.state.Service;
|
|
|
+import org.apache.ambari.server.state.ServiceComponent;
|
|
|
+import org.apache.ambari.server.state.ServiceComponentFactory;
|
|
|
+import org.apache.ambari.server.state.ServiceComponentHost;
|
|
|
+import org.apache.ambari.server.state.ServiceComponentHostFactory;
|
|
|
+import org.apache.ambari.server.state.ServiceFactory;
|
|
|
+import org.apache.ambari.server.state.ServiceInfo;
|
|
|
+import org.apache.ambari.server.state.ServiceOsSpecific;
|
|
|
+import org.apache.ambari.server.state.StackId;
|
|
|
+import org.apache.ambari.server.state.StackInfo;
|
|
|
+import org.apache.ambari.server.state.State;
|
|
|
import org.apache.ambari.server.state.configgroup.ConfigGroup;
|
|
|
import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
|
|
|
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
|
|
@@ -118,12 +109,41 @@ import org.junit.rules.ExpectedException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.reflect.TypeToken;
|
|
|
-import com.google.inject.AbstractModule;
|
|
|
-import com.google.inject.Guice;
|
|
|
-import com.google.inject.Injector;
|
|
|
-import com.google.inject.persist.PersistService;
|
|
|
+import javax.persistence.EntityManager;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.StringReader;
|
|
|
+import java.lang.reflect.Type;
|
|
|
+import java.net.ConnectException;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.UnknownHostException;
|
|
|
+import java.text.MessageFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+import static org.easymock.EasyMock.capture;
|
|
|
+import static org.easymock.EasyMock.createNiceMock;
|
|
|
+import static org.easymock.EasyMock.createStrictMock;
|
|
|
+import static org.easymock.EasyMock.expect;
|
|
|
+import static org.easymock.EasyMock.replay;
|
|
|
+import static org.easymock.EasyMock.verify;
|
|
|
+import static org.hamcrest.CoreMatchers.is;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertFalse;
|
|
|
+import static org.junit.Assert.assertNotNull;
|
|
|
+import static org.junit.Assert.assertNull;
|
|
|
+import static org.junit.Assert.assertSame;
|
|
|
+import static org.junit.Assert.assertThat;
|
|
|
+import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
|
|
|
public class AmbariManagementControllerTest {
|
|
|
|
|
@@ -5151,6 +5171,8 @@ public class AmbariManagementControllerTest {
|
|
|
// Create and attach config
|
|
|
Map<String, String> configs = new HashMap<String, String>();
|
|
|
configs.put("a", "b");
|
|
|
+ Map<String, String> configs2 = new HashMap<String, String>();
|
|
|
+ configs2.put("c", "d");
|
|
|
|
|
|
ConfigurationRequest cr1,cr2,cr3;
|
|
|
cr1 = new ConfigurationRequest(clusterName, "core-site","version1",
|
|
@@ -5180,10 +5202,8 @@ public class AmbariManagementControllerTest {
|
|
|
startService(clusterName, serviceName2, true, false);
|
|
|
|
|
|
// Reconfigure
|
|
|
- configs.clear();
|
|
|
- configs.put("c", "d");
|
|
|
cr3 = new ConfigurationRequest(clusterName, "core-site","version122",
|
|
|
- configs, null);
|
|
|
+ configs2, null);
|
|
|
crReq = new ClusterRequest(cluster.getClusterId(), clusterName, null, null);
|
|
|
crReq.setDesiredConfig(Collections.singletonList(cr3));
|
|
|
controller.updateClusters(Collections.singleton(crReq), null);
|
|
@@ -5307,6 +5327,8 @@ public class AmbariManagementControllerTest {
|
|
|
// Create and attach config
|
|
|
Map<String, String> configs = new HashMap<String, String>();
|
|
|
configs.put("a", "b");
|
|
|
+ Map<String, String> configs2 = new HashMap<String, String>();
|
|
|
+ configs2.put("c", "d");
|
|
|
|
|
|
ConfigurationRequest cr1,cr2,cr3;
|
|
|
cr1 = new ConfigurationRequest(clusterName, "core-site","version1",
|
|
@@ -5336,10 +5358,8 @@ public class AmbariManagementControllerTest {
|
|
|
}
|
|
|
|
|
|
// Reconfigure
|
|
|
- configs.clear();
|
|
|
- configs.put("c", "d");
|
|
|
cr3 = new ConfigurationRequest(clusterName, "core-site","version122",
|
|
|
- configs, null);
|
|
|
+ configs2, null);
|
|
|
crReq = new ClusterRequest(cluster.getClusterId(), clusterName, null, null);
|
|
|
crReq.setDesiredConfig(Collections.singletonList(cr3));
|
|
|
controller.updateClusters(Collections.singleton(crReq), null);
|