Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ public class BlueprintImplTest {
Map<String, Map<String, String>> properties = new HashMap<>();
Map<String, String> hdfsProps = new HashMap<>();
Configuration configuration = new Configuration(properties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION);
org.apache.ambari.server.configuration.Configuration serverConfig;

@Before
public void setup() {
public void setup() throws NoSuchFieldException, IllegalAccessException {
properties.put("hdfs-site", hdfsProps);
hdfsProps.put("foo", "val");
hdfsProps.put("bar", "val");
Expand Down Expand Up @@ -104,11 +105,12 @@ public void setup() {
requiredService2Properties.add(new Stack.ConfigProperty("category2", "prop2", null));
expect(stack.getRequiredConfigurationProperties("HDFS")).andReturn(requiredHDFSProperties).anyTimes();
expect(stack.getRequiredConfigurationProperties("SERVICE2")).andReturn(requiredService2Properties).anyTimes();

serverConfig = setupConfigurationWithGPLLicense(true);
}

@Test
public void testValidateConfigurations__basic_positive() throws Exception {
org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(true);
expect(group1.getCardinality()).andReturn("1").atLeastOnce();
expect(group1.getComponents()).andReturn(Arrays.asList(new Component("c1"), new Component("c2"))).atLeastOnce();
expect(group2.getCardinality()).andReturn("1").atLeastOnce();
Expand Down Expand Up @@ -138,7 +140,6 @@ public void testValidateConfigurations__hostGroupConfig() throws Exception {
group2Props.put("category2", group2Category2Props);
group2Category2Props.put("prop2", "val");

org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(true);
// set config for group2 which contains a required property
Configuration group2Configuration = new Configuration(group2Props, EMPTY_ATTRIBUTES, configuration);
expect(group2.getConfiguration()).andReturn(group2Configuration).atLeastOnce();
Expand Down Expand Up @@ -178,6 +179,7 @@ public void testValidateConfigurations__hostGroupConfigForNameNodeHAPositive() t
Configuration group2Configuration = new Configuration(group2Props, EMPTY_ATTRIBUTES, configuration);
expect(group2.getConfiguration()).andReturn(group2Configuration).atLeastOnce();


expect(group1.getCardinality()).andReturn("1").atLeastOnce();
expect(group1.getComponents()).andReturn(Arrays.asList(new Component("NAMENODE"),new Component("ZKFC"))).atLeastOnce();
expect(group2.getCardinality()).andReturn("1").atLeastOnce();
Expand All @@ -198,13 +200,13 @@ public void testValidateConfigurations__hostGroupConfigForNameNodeHAPositive() t
properties.put("hadoop-env", hadoopProps);
hadoopProps.put("dfs_ha_initial_namenode_active", "%HOSTGROUP::group1%");
hadoopProps.put("dfs_ha_initial_namenode_standby", "%HOSTGROUP::group2%");
replay(stack, group1, group2);
replay(stack, group1, group2, serverConfig);

Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, configuration, null);
blueprint.validateRequiredProperties();
BlueprintEntity entity = blueprint.toEntity();

verify(stack, group1, group2);
verify(stack, group1, group2, serverConfig);
assertTrue(entity.getSecurityType() == SecurityType.NONE);
assertTrue(entity.getSecurityDescriptorReference() == null);
}
Expand Down Expand Up @@ -240,10 +242,10 @@ public void testValidateConfigurations__hostGroupConfigForNameNodeHAInCorrectHos
properties.put("hadoop-env", hadoopProps);
hadoopProps.put("dfs_ha_initial_namenode_active", "%HOSTGROUP::group2%");
hadoopProps.put("dfs_ha_initial_namenode_standby", "%HOSTGROUP::group3%");
replay(stack, group1, group2);
replay(stack, group1, group2, serverConfig);
Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, configuration, null);
blueprint.validateRequiredProperties();
verify(stack, group1, group2);
verify(stack, group1, group2, serverConfig);
}
@Test(expected= IllegalArgumentException.class)
public void testValidateConfigurations__hostGroupConfigForNameNodeHAMappedSameHostGroup() throws Exception {
Expand Down Expand Up @@ -276,18 +278,17 @@ public void testValidateConfigurations__hostGroupConfigForNameNodeHAMappedSameHo
properties.put("hadoop-env", hadoopProps);
hadoopProps.put("dfs_ha_initial_namenode_active", "%HOSTGROUP::group2%");
hadoopProps.put("dfs_ha_initial_namenode_standby", "%HOSTGROUP::group2%");
replay(stack, group1, group2);
replay(stack, group1, group2, serverConfig);
Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, configuration, null);
blueprint.validateRequiredProperties();
verify(stack, group1, group2);
verify(stack, group1, group2, serverConfig);
}
@Test(expected = InvalidTopologyException.class)
public void testValidateConfigurations__secretReference() throws InvalidTopologyException,
GPLLicenseNotAcceptedException, NoSuchFieldException, IllegalAccessException {
Map<String, Map<String, String>> group2Props = new HashMap<>();
Map<String, String> group2Category2Props = new HashMap<>();

org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(true);
group2Props.put("category2", group2Category2Props);
group2Category2Props.put("prop2", "val");
hdfsProps.put("secret", "SECRET:hdfs-site:1:test");
Expand All @@ -307,7 +308,7 @@ public void testValidateConfigurations__gplIsNotAllowedCodecsProperty() throws I
}});
Configuration lzoUsageConfiguration = new Configuration(lzoProperties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION);

org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(false);
serverConfig = setupConfigurationWithGPLLicense(false);
replay(stack, group1, group2, serverConfig);

Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, lzoUsageConfiguration, null);
Expand All @@ -324,7 +325,7 @@ public void testValidateConfigurations__gplIsNotAllowedLZOProperty() throws Inva
}});
Configuration lzoUsageConfiguration = new Configuration(lzoProperties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION);

org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(false);
serverConfig = setupConfigurationWithGPLLicense(false);
replay(stack, group1, group2, serverConfig);

Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, lzoUsageConfiguration, null);
Expand All @@ -342,7 +343,6 @@ public void testValidateConfigurations__gplISAllowed() throws InvalidTopologyExc
}});
Configuration lzoUsageConfiguration = new Configuration(lzoProperties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION);

org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(true);
expect(group2.getConfiguration()).andReturn(EMPTY_CONFIGURATION).atLeastOnce();
replay(stack, group1, group2, serverConfig);

Expand Down