|
@@ -18,11 +18,16 @@
|
|
|
|
|
|
package org.apache.ambari.server.controller.internal;
|
|
package org.apache.ambari.server.controller.internal;
|
|
|
|
|
|
-import com.google.common.collect.ImmutableList;
|
|
|
|
-import com.google.common.collect.ImmutableMap;
|
|
|
|
-import com.google.common.collect.ImmutableSet;
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
-import com.google.common.collect.Maps;
|
|
|
|
|
|
+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.Set;
|
|
|
|
+
|
|
import org.apache.ambari.server.state.PropertyDependencyInfo;
|
|
import org.apache.ambari.server.state.PropertyDependencyInfo;
|
|
import org.apache.ambari.server.state.ServiceInfo;
|
|
import org.apache.ambari.server.state.ServiceInfo;
|
|
import org.apache.ambari.server.state.ValueAttributesInfo;
|
|
import org.apache.ambari.server.state.ValueAttributesInfo;
|
|
@@ -45,15 +50,11 @@ import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
-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.Set;
|
|
|
|
|
|
+import com.google.common.collect.ImmutableList;
|
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
|
+import com.google.common.collect.ImmutableSet;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
|
import static junit.framework.Assert.assertEquals;
|
|
import static junit.framework.Assert.assertEquals;
|
|
import static junit.framework.Assert.assertFalse;
|
|
import static junit.framework.Assert.assertFalse;
|
|
@@ -176,6 +177,9 @@ public class BlueprintConfigurationProcessorTest {
|
|
}
|
|
}
|
|
|
|
|
|
expect(stack.getCardinality("MYSQL_SERVER")).andReturn(new Cardinality("0-1")).anyTimes();
|
|
expect(stack.getCardinality("MYSQL_SERVER")).andReturn(new Cardinality("0-1")).anyTimes();
|
|
|
|
+
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
}
|
|
}
|
|
|
|
|
|
@After
|
|
@After
|
|
@@ -3978,6 +3982,83 @@ public class BlueprintConfigurationProcessorTest {
|
|
assertEquals("jdbc:mysql://myHost.com/hive?createDatabaseIfNotExist=true", updatedVal);
|
|
assertEquals("jdbc:mysql://myHost.com/hive?createDatabaseIfNotExist=true", updatedVal);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testAddExcludedProperties() throws Exception {
|
|
|
|
+ reset(stack);
|
|
|
|
+
|
|
|
|
+ // defaults from init() method that we need
|
|
|
|
+ expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
|
|
+ expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
|
|
+ expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+
|
|
|
|
+ // customized stack calls for this test only
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes("FALCON")).andReturn(Collections.singleton("oozie-site")).anyTimes();
|
|
|
|
+ expect(stack.getConfigurationProperties("FALCON", "oozie-site")).andReturn(Collections.singletonMap("oozie.service.ELService.ext.functions.coord-job-submit-instances", "testValue")).anyTimes();
|
|
|
|
+
|
|
|
|
+ Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
|
|
|
|
+ Configuration clusterConfig = new Configuration(properties, Collections.<String, Map<String, Map<String, String>>>emptyMap());
|
|
|
|
+
|
|
|
|
+ Collection<String> hgComponents = new HashSet<String>();
|
|
|
|
+ hgComponents.add("FALCON_SERVER");
|
|
|
|
+ hgComponents.add("FALCON_CLIENT");
|
|
|
|
+ List<String> hosts = new ArrayList<String>();
|
|
|
|
+ hosts.add("c6401.apache.ambari.org");
|
|
|
|
+ hosts.add("serverTwo");
|
|
|
|
+ TestHostGroup group1 = new TestHostGroup("host_group_1", hgComponents, hosts);
|
|
|
|
+
|
|
|
|
+ Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
|
|
|
|
+ hostGroups.add(group1);
|
|
|
|
+
|
|
|
|
+ ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
|
|
|
|
+ BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
|
|
|
|
+
|
|
|
|
+ updater.doUpdateForClusterCreate();
|
|
|
|
+
|
|
|
|
+ assertEquals("Falcon Broker URL property not properly exported",
|
|
|
|
+ "testValue", clusterConfig.getPropertyValue("oozie-site", "oozie.service.ELService.ext.functions.coord-job-submit-instances"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testAddExcludedPropertiesAreOverwrittenByBlueprintConfigs() throws Exception {
|
|
|
|
+ reset(stack);
|
|
|
|
+
|
|
|
|
+ // defaults from init() method that we need
|
|
|
|
+ expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
|
|
+ expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
|
|
+ expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+ expect(stack.getConfigurationPropertiesWithMetadata(anyObject(String.class), anyObject(String.class))).andReturn(Collections.<String, Stack.ConfigProperty>emptyMap()).anyTimes();
|
|
|
|
+
|
|
|
|
+ // customized stack calls for this test only
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes("FALCON")).andReturn(Collections.singleton("oozie-site")).anyTimes();
|
|
|
|
+ expect(stack.getConfigurationProperties("FALCON", "oozie-site")).andReturn(Collections.singletonMap("oozie.service.ELService.ext.functions.coord-job-submit-instances", "testValue")).anyTimes();
|
|
|
|
+
|
|
|
|
+ Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
|
|
|
|
+ Map<String, String> typeProps = new HashMap<String, String>();
|
|
|
|
+ typeProps.put("oozie.service.ELService.ext.functions.coord-job-submit-instances", "overridedValue");
|
|
|
|
+ properties.put("oozie-site", typeProps);
|
|
|
|
+
|
|
|
|
+ Configuration clusterConfig = new Configuration(properties, Collections.<String, Map<String, Map<String, String>>>emptyMap());
|
|
|
|
+
|
|
|
|
+ Collection<String> hgComponents = new HashSet<String>();
|
|
|
|
+ hgComponents.add("FALCON_SERVER");
|
|
|
|
+ hgComponents.add("FALCON_CLIENT");
|
|
|
|
+ List<String> hosts = new ArrayList<String>();
|
|
|
|
+ hosts.add("c6401.apache.ambari.org");
|
|
|
|
+ hosts.add("serverTwo");
|
|
|
|
+ TestHostGroup group1 = new TestHostGroup("host_group_1", hgComponents, hosts);
|
|
|
|
+
|
|
|
|
+ Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
|
|
|
|
+ hostGroups.add(group1);
|
|
|
|
+
|
|
|
|
+ ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
|
|
|
|
+ BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
|
|
|
|
+
|
|
|
|
+ updater.doUpdateForClusterCreate();
|
|
|
|
+
|
|
|
|
+ assertEquals("Falcon Broker URL property not properly exported",
|
|
|
|
+ "overridedValue", clusterConfig.getPropertyValue("oozie-site", "oozie.service.ELService.ext.functions.coord-job-submit-instances"));
|
|
|
|
+ }
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testFalconConfigClusterUpdate() throws Exception {
|
|
public void testFalconConfigClusterUpdate() throws Exception {
|
|
final String expectedHostName = "c6401.apache.ambari.org";
|
|
final String expectedHostName = "c6401.apache.ambari.org";
|
|
@@ -4152,6 +4233,8 @@ public class BlueprintConfigurationProcessorTest {
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
|
|
// customized stack calls for this test only
|
|
// customized stack calls for this test only
|
|
expect(stack.getServiceForConfigType("hive-site")).andReturn("HIVE").atLeastOnce();
|
|
expect(stack.getServiceForConfigType("hive-site")).andReturn("HIVE").atLeastOnce();
|
|
@@ -4227,6 +4310,8 @@ public class BlueprintConfigurationProcessorTest {
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
|
|
// customized stack calls for this test only
|
|
// customized stack calls for this test only
|
|
// simulate the case of the stack object throwing a RuntimeException, to indicate a config error
|
|
// simulate the case of the stack object throwing a RuntimeException, to indicate a config error
|
|
@@ -4304,6 +4389,8 @@ public class BlueprintConfigurationProcessorTest {
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
|
|
// customized stack calls for this test only
|
|
// customized stack calls for this test only
|
|
expect(stack.getServiceForConfigType("hive-site")).andReturn("HIVE").atLeastOnce();
|
|
expect(stack.getServiceForConfigType("hive-site")).andReturn("HIVE").atLeastOnce();
|
|
@@ -4390,7 +4477,10 @@ public class BlueprintConfigurationProcessorTest {
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
|
|
- // customized stack calls for this test only
|
|
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
+
|
|
|
|
+ // customized stack calls for this test only
|
|
expect(stack.getServiceForConfigType("hbase-site")).andReturn("HBASE").atLeastOnce();
|
|
expect(stack.getServiceForConfigType("hbase-site")).andReturn("HBASE").atLeastOnce();
|
|
expect(stack.getConfigurationPropertiesWithMetadata("HBASE", "hbase-site")).andReturn(mapOfMetadata).atLeastOnce();
|
|
expect(stack.getConfigurationPropertiesWithMetadata("HBASE", "hbase-site")).andReturn(mapOfMetadata).atLeastOnce();
|
|
|
|
|
|
@@ -4455,6 +4545,8 @@ public class BlueprintConfigurationProcessorTest {
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getName()).andReturn("testStack").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.getVersion()).andReturn("1").anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes();
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
|
|
// customized stack calls for this test only
|
|
// customized stack calls for this test only
|
|
expect(stack.getServiceForConfigType("hbase-site")).andReturn("HBASE").atLeastOnce();
|
|
expect(stack.getServiceForConfigType("hbase-site")).andReturn("HBASE").atLeastOnce();
|
|
@@ -5688,6 +5780,10 @@ public class BlueprintConfigurationProcessorTest {
|
|
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
|
|
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
|
|
reset(stack);
|
|
reset(stack);
|
|
expect(stack.getConfiguration(bp.getServices())).andReturn(createStackDefaults()).anyTimes();
|
|
expect(stack.getConfiguration(bp.getServices())).andReturn(createStackDefaults()).anyTimes();
|
|
|
|
+
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
+
|
|
replay(stack);
|
|
replay(stack);
|
|
// WHEN
|
|
// WHEN
|
|
Set<String> configTypeUpdated = configProcessor.doUpdateForClusterCreate();
|
|
Set<String> configTypeUpdated = configProcessor.doUpdateForClusterCreate();
|
|
@@ -5741,6 +5837,10 @@ public class BlueprintConfigurationProcessorTest {
|
|
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
|
|
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
|
|
reset(stack);
|
|
reset(stack);
|
|
expect(stack.getConfiguration(bp.getServices())).andReturn(createStackDefaults()).anyTimes();
|
|
expect(stack.getConfiguration(bp.getServices())).andReturn(createStackDefaults()).anyTimes();
|
|
|
|
+
|
|
|
|
+ Set<String> emptySet = Collections.emptySet();
|
|
|
|
+ expect(stack.getExcludedConfigurationTypes(anyObject(String.class))).andReturn(emptySet).anyTimes();
|
|
|
|
+
|
|
replay(stack);
|
|
replay(stack);
|
|
// WHEN
|
|
// WHEN
|
|
configProcessor.doUpdateForClusterCreate();
|
|
configProcessor.doUpdateForClusterCreate();
|