Search in sources :

Example 6 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KerberosBlueprintExtendTest method testAddKerberosConfigToKerberosConfiguredBlueprintWithDescriptorNotForced.

@Test
public void testAddKerberosConfigToKerberosConfiguredBlueprintWithDescriptorNotForced() throws IOException {
    String json = FileReaderUtils.readFileFromClasspath("extend-blueprint/multi-node-hdfs-yarn-default-kerb_descriptor.json");
    String expected = FileReaderUtils.readFileFromClasspath("extend-blueprint/multi-node-hdfs-yarn-default-kerb_descriptor_fixed.json");
    BlueprintTextProcessor b = new BlueprintTextProcessor(json);
    String result = underTest.extendBlueprintWithKerberos(b, kerberosEnv, "node.dc1.consul,node.consul", false, null, false).asText();
    JsonNode expectedNode = JsonUtil.readTree(expected);
    JsonNode resultNode = JsonUtil.readTree(result);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 7 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KerberosBlueprintExtendTest method testAddKerberosConfigToKerberosConfiguredBlueprintWithDescriptorForced.

@Test
public void testAddKerberosConfigToKerberosConfiguredBlueprintWithDescriptorForced() throws IOException {
    String json = FileReaderUtils.readFileFromClasspath("extend-blueprint/multi-node-hdfs-yarn-default-kerb_descriptor.json");
    String expected = FileReaderUtils.readFileFromClasspath("extend-blueprint/multi-node-hdfs-yarn-default-kerb_descriptor_forced_fixed.json");
    BlueprintTextProcessor b = new BlueprintTextProcessor(json);
    String result = underTest.extendBlueprintWithKerberos(b, kerberosEnv, "node.dc1.consul,node.consul", false, null, true).asText();
    JsonNode expectedNode = JsonUtil.readTree(expected);
    JsonNode resultNode = JsonUtil.readTree(result);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 8 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosManagedKerberos.

@Test
public void testExtendBlueprintWithKerberosManagedKerberos() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized.bp");
    Blueprint blueprint = TestUtil.blueprint("name", blueprintText);
    Stack stack = TestUtil.stack();
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, TestUtil.kerberosConfig());
    GeneralClusterConfigs generalClusterConfigs = BlueprintTestUtil.generalClusterConfigs();
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of("test-1-1"));
    generalClusterConfigs.setGatewayInstanceMetadataPresented(false);
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(generalClusterConfigs).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized-cloudbreak-managed-expected.bp");
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) JsonNode(com.fasterxml.jackson.databind.JsonNode) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 9 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosExisting.

@Test
public void testExtendBlueprintWithKerberosExisting() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized.bp");
    Blueprint blueprint = TestUtil.blueprint("name", blueprintText);
    KerberosConfig kerberosConfig = new KerberosConfig();
    kerberosConfig.setPrincipal("principal.conf");
    kerberosConfig.setPrincipal("passwd.conf");
    kerberosConfig.setUrl("url.conf");
    kerberosConfig.setAdminUrl("adminUrl.conf");
    kerberosConfig.setRealm("realm.conf");
    kerberosConfig.setLdapUrl("ldapUrl.conf");
    kerberosConfig.setContainerDn("containerDn.conf");
    kerberosConfig.setTcpAllowed(true);
    Stack stack = TestUtil.stack();
    GeneralClusterConfigs generalClusterConfigs = BlueprintTestUtil.generalClusterConfigs();
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of("test-1-1"));
    generalClusterConfigs.setGatewayInstanceMetadataPresented(false);
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, kerberosConfig);
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(generalClusterConfigs).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized-existing-expected.bp");
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) JsonNode(com.fasterxml.jackson.databind.JsonNode) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 10 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class HadoopConfigurationServiceTest method testConfigure.

@Test
public void testConfigure() throws IOException {
    BlueprintPreparationObject source = Builder.builder().build();
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(configService.getHostGroupConfiguration(blueprintTextProcessor, source.getHostgroupViews())).thenReturn(emptyMap());
    when(configService.getComponentsByHostGroup(blueprintTextProcessor, source.getHostgroupViews())).thenReturn(emptyMap());
    when(blueprintTextProcessor.extendBlueprintHostGroupConfiguration(any(HostgroupConfigurations.class), anyBoolean())).thenReturn(blueprintTextProcessor);
    when(blueprintTextProcessor.extendBlueprintGlobalConfiguration(any(SiteConfigurations.class), anyBoolean())).thenReturn(blueprintTextProcessor);
    BlueprintTextProcessor actual = underTest.customTextManipulation(source, blueprintTextProcessor);
    Assert.assertEquals(blueprintTextProcessor, actual);
}
Also used : HostgroupConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) SiteConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Aggregations

BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)12 Test (org.junit.Test)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)6 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 BlueprintProcessorFactory (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)2 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Component (org.springframework.stereotype.Component)2 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 GATEWAY (com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY)1