|
@@ -20,7 +20,9 @@ package org.apache.ambari.server.upgrade;
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
@@ -41,6 +43,8 @@ import org.apache.ambari.server.orm.entities.StackEntity;
|
|
|
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.ServiceComponentHost;
|
|
|
+import org.apache.ambari.server.state.StackId;
|
|
|
import org.apache.ambari.server.state.stack.OsFamily;
|
|
|
import org.easymock.Capture;
|
|
|
import org.easymock.EasyMock;
|
|
@@ -51,12 +55,14 @@ import org.junit.Test;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.google.inject.AbstractModule;
|
|
|
import com.google.inject.Binder;
|
|
|
import com.google.inject.Guice;
|
|
|
import com.google.inject.Injector;
|
|
|
import com.google.inject.Module;
|
|
|
import com.google.inject.Provider;
|
|
|
import com.google.inject.persist.PersistService;
|
|
|
+import org.apache.ambari.server.AmbariException;
|
|
|
|
|
|
import static org.easymock.EasyMock.anyObject;
|
|
|
import static org.easymock.EasyMock.anyString;
|
|
@@ -108,6 +114,7 @@ public class UpgradeCatalog222Test {
|
|
|
Method updateAlerts = UpgradeCatalog222.class.getDeclaredMethod("updateAlerts");
|
|
|
Method updateStormConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateStormConfigs");
|
|
|
Method updateAMSConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateAMSConfigs");
|
|
|
+ Method updateHiveConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateHiveConfig");
|
|
|
Method updateHostRoleCommands = UpgradeCatalog222.class.getDeclaredMethod("updateHostRoleCommands");
|
|
|
|
|
|
|
|
@@ -116,6 +123,7 @@ public class UpgradeCatalog222Test {
|
|
|
.addMockedMethod(updateAlerts)
|
|
|
.addMockedMethod(updateStormConfigs)
|
|
|
.addMockedMethod(updateAMSConfigs)
|
|
|
+ .addMockedMethod(updateHiveConfigs)
|
|
|
.addMockedMethod(updateHostRoleCommands)
|
|
|
.createMock();
|
|
|
|
|
@@ -129,6 +137,8 @@ public class UpgradeCatalog222Test {
|
|
|
expectLastCall().once();
|
|
|
upgradeCatalog222.updateHostRoleCommands();
|
|
|
expectLastCall().once();
|
|
|
+ upgradeCatalog222.updateHiveConfig();
|
|
|
+ expectLastCall().once();
|
|
|
|
|
|
replay(upgradeCatalog222);
|
|
|
|
|
@@ -137,6 +147,75 @@ public class UpgradeCatalog222Test {
|
|
|
verify(upgradeCatalog222);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testHiveSiteUpdateConfigs() throws AmbariException {
|
|
|
+ EasyMockSupport easyMockSupport = new EasyMockSupport();
|
|
|
+ final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
|
|
|
+ final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
|
|
|
+ final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
|
|
|
+
|
|
|
+ final Config hiveSiteConfigs = easyMockSupport.createNiceMock(Config.class);
|
|
|
+ final Config AtlasSiteConfigs = easyMockSupport.createNiceMock(Config.class);
|
|
|
+
|
|
|
+ final ServiceComponentHost atlasHost = easyMockSupport.createNiceMock(ServiceComponentHost.class);
|
|
|
+ final List<ServiceComponentHost> atlasHosts = new ArrayList<>();
|
|
|
+ atlasHosts.add(atlasHost);
|
|
|
+
|
|
|
+ StackId stackId = new StackId("HDP","2.3");
|
|
|
+
|
|
|
+ final Map<String, String> propertiesAtlasSiteConfigs = new HashMap<String, String>() {{
|
|
|
+ put("atlas.enableTLS", "true");
|
|
|
+ put("atlas.server.https.port", "21443");
|
|
|
+ }};
|
|
|
+
|
|
|
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
|
|
|
+ @Override
|
|
|
+ protected void configure() {
|
|
|
+ bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
|
|
|
+ bind(Clusters.class).toInstance(mockClusters);
|
|
|
+ bind(EntityManager.class).toInstance(entityManager);
|
|
|
+ bind(ServiceComponentHost.class).toInstance(atlasHost);
|
|
|
+
|
|
|
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
|
|
|
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(mockClusterExpected.getCurrentStackVersion()).andReturn(stackId).once();
|
|
|
+ expect(mockClusterExpected.getServiceComponentHosts("ATLAS", "ATLAS_SERVER")).andReturn(atlasHosts).once();
|
|
|
+ expect(atlasHost.getHostName()).andReturn("c6401").once();
|
|
|
+ expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
|
|
|
+ expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
|
|
|
+ put("normal", mockClusterExpected);
|
|
|
+ }}).atLeastOnce();
|
|
|
+ expect(mockClusterExpected.getDesiredConfigByType("hive-site")).andReturn(hiveSiteConfigs).atLeastOnce();
|
|
|
+ expect(mockClusterExpected.getDesiredConfigByType("application-properties")).andReturn(AtlasSiteConfigs).anyTimes();
|
|
|
+ expect(AtlasSiteConfigs.getProperties()).andReturn(propertiesAtlasSiteConfigs).anyTimes();
|
|
|
+
|
|
|
+ UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
|
|
|
+ .withConstructor(Injector.class)
|
|
|
+ .withArgs(mockInjector)
|
|
|
+ .addMockedMethod("updateConfigurationPropertiesForCluster", Cluster.class, String.class,
|
|
|
+ Map.class, boolean.class, boolean.class)
|
|
|
+ .createMock();
|
|
|
+
|
|
|
+ Map<String, String> expectedUpdates = new HashMap<>();
|
|
|
+ expectedUpdates.put("atlas.hook.hive.minThreads", "1");
|
|
|
+ expectedUpdates.put("atlas.hook.hive.maxThreads", "1");
|
|
|
+ expectedUpdates.put("atlas.cluster.name", "primary");
|
|
|
+ expectedUpdates.put("atlas.rest.address", "https://c6401:21443");
|
|
|
+
|
|
|
+ upgradeCatalog222.updateConfigurationPropertiesForCluster(mockClusterExpected, "hive-site", expectedUpdates,
|
|
|
+ false, false);
|
|
|
+ expectLastCall().once();
|
|
|
+
|
|
|
+ easyMockSupport.replayAll();
|
|
|
+ replay(upgradeCatalog222);
|
|
|
+ upgradeCatalog222.updateHiveConfig();
|
|
|
+ easyMockSupport.verifyAll();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Test
|
|
|
public void testAmsSiteUpdateConfigs() throws Exception{
|
|
|
|