|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
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;
|
|
@@ -6185,6 +6186,92 @@ public class BlueprintConfigurationProcessorTest {
|
|
|
assertEquals(expectedValue, newValue);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testMultipleHostTopologyUpdaterWithYamlPropertySingleHostValue() throws Exception {
|
|
|
+ // Given
|
|
|
+ String component = "test_component";
|
|
|
+ BlueprintConfigurationProcessor.MultipleHostTopologyUpdater mhtu = new BlueprintConfigurationProcessor.MultipleHostTopologyUpdater(component);
|
|
|
+
|
|
|
+ String propertyOriginalValue1 = "['%HOSTGROUP::group_1%']";
|
|
|
+ String propertyOriginalValue2 = "[%HOSTGROUP::group_1%]";
|
|
|
+
|
|
|
+ // When
|
|
|
+ String updatedValue1 = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue1, null, ImmutableList.<String>of("host1:100"));
|
|
|
+ String updatedValue2 = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue2, null, ImmutableList.<String>of("host1:100"));
|
|
|
+
|
|
|
+ // Then
|
|
|
+ assertEquals("host1:100", updatedValue1);
|
|
|
+
|
|
|
+ assertEquals("host1:100", updatedValue2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testMultipleHostTopologyUpdaterWithYamlPropertyMultiHostValue() throws Exception {
|
|
|
+ // Given
|
|
|
+ String component = "test_component";
|
|
|
+ BlueprintConfigurationProcessor.MultipleHostTopologyUpdater mhtu = new BlueprintConfigurationProcessor.MultipleHostTopologyUpdater(component);
|
|
|
+
|
|
|
+ String propertyOriginalValue1 = "['%HOSTGROUP::group_1%', '%HOSTGROUP::group_2%']";
|
|
|
+ String propertyOriginalValue2 = "[%HOSTGROUP::group_1%, %HOSTGROUP::group_2%]";
|
|
|
+
|
|
|
+ // When
|
|
|
+ String updatedValue1 = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue1, null, ImmutableList.<String>of("host1:100", "host2:200"));
|
|
|
+ String updatedValue2 = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue2, null, ImmutableList.<String>of("host1:100", "host2:200"));
|
|
|
+
|
|
|
+ // Then
|
|
|
+ assertEquals("host1:100,host2:200", updatedValue1);
|
|
|
+
|
|
|
+ assertEquals("host1:100,host2:200", updatedValue2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testMultipleHostTopologyUpdaterWithSingleHostWithSuffixValue() throws Exception {
|
|
|
+ // Given
|
|
|
+ String component = "test_component";
|
|
|
+ BlueprintConfigurationProcessor.MultipleHostTopologyUpdater mhtu = new BlueprintConfigurationProcessor.MultipleHostTopologyUpdater(component);
|
|
|
+
|
|
|
+ String propertyOriginalValue = "http://%HOSTGROUP::group_1%#";
|
|
|
+
|
|
|
+ // When
|
|
|
+ String updatedValue = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue, null, ImmutableList.<String>of("host1:100"));
|
|
|
+
|
|
|
+ // Then
|
|
|
+ assertEquals("http://host1:100#", updatedValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testMultipleHostTopologyUpdaterWithMultiHostWithSuffixValue() throws Exception {
|
|
|
+ // Given
|
|
|
+ String component = "test_component";
|
|
|
+ BlueprintConfigurationProcessor.MultipleHostTopologyUpdater mhtu = new BlueprintConfigurationProcessor.MultipleHostTopologyUpdater(component);
|
|
|
+
|
|
|
+ String propertyOriginalValue = "http://%HOSTGROUP::group_1,HOSTGROUP::group_2%/resource";
|
|
|
+
|
|
|
+ // When
|
|
|
+ String updatedValue = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue, null, ImmutableList.<String>of("host1:100", "host2:200"));
|
|
|
+
|
|
|
+ // Then
|
|
|
+ assertEquals("http://host1:100,host2:200/resource", updatedValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testMultipleHostTopologyUpdaterWithMultiHostValue() throws Exception {
|
|
|
+ // Given
|
|
|
+ String component = "test_component";
|
|
|
+ BlueprintConfigurationProcessor.MultipleHostTopologyUpdater mhtu = new BlueprintConfigurationProcessor.MultipleHostTopologyUpdater(component);
|
|
|
+
|
|
|
+ String propertyOriginalValue = "%HOSTGROUP::group_1%:11,%HOSTGROUP::group_2%:11";
|
|
|
+
|
|
|
+ // When
|
|
|
+ String updatedValue = mhtu.resolveHostGroupPlaceholder(propertyOriginalValue, null, ImmutableList.<String>of("host1:100", "host2:200"));
|
|
|
+
|
|
|
+ // Then
|
|
|
+ assertEquals("host1:100,host2:200", updatedValue);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private Map<String, AdvisedConfiguration> createAdvisedConfigMap() {
|
|
|
Map<String, AdvisedConfiguration> advMap = new HashMap<String, AdvisedConfiguration>();
|