Search in sources :

Example 76 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class BlueprintTemplateProcessorTest method testMustacheGeneratorShouldEscapeNifiHtmlBasedContentsQuotes.

@Test
public void testMustacheGeneratorShouldEscapeNifiHtmlBasedContentsQuotes() throws Exception {
    String testBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-mustache-test.bp");
    Cluster cluster = cluster();
    BlueprintStackInfo blueprintStackInfo = new BlueprintStackInfo("hdp", "2.4");
    GeneralClusterConfigs generalClusterConfigs = generalClusterConfigs();
    generalClusterConfigs.setClusterName("dummyCluster");
    generalClusterConfigs.setStackName("dummyCluster");
    Map<String, Object> properties = new HashMap<>();
    properties.put("S3_BUCKET", "testbucket");
    HdfConfigs hdfConfigs = new HdfConfigs("<property name=\"Node Identity 1\">CN=hostname-2, OU=NIFI</property>", Optional.empty());
    BlueprintPreparationObject blueprintPreparationObject = BlueprintPreparationObject.Builder.builder().withRdsConfigs(cluster.getRdsConfigs()).withGateway(cluster.getGateway()).withLdapConfig(cluster.getLdapConfig()).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(new BlueprintView(testBlueprint, new Json(properties), blueprintStackInfo.getVersion(), blueprintStackInfo.getType())).withHdfConfigs(hdfConfigs).build();
    String result = underTest.process(testBlueprint, blueprintPreparationObject, Maps.newHashMap());
    assertTrue(result.contains("\"content\": \"<property name=\\\"Node Identity 1\\\">CN=hostname-2, OU=NIFI</property>\""));
    assertFalse(result.contains("\"content\": \"<property name=\"Node Identity 1\">CN=hostname-2, OU=NIFI</property>\""));
}
Also used : HdfConfigs(com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs) BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs) HashMap(java.util.HashMap) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Json(com.sequenceiq.cloudbreak.domain.json.Json) Test(org.junit.Test)

Example 77 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class BlueprintTemplateProcessorTest method testMustacheGeneratorForRangerRDS.

@Test
public void testMustacheGeneratorForRangerRDS() throws Exception {
    String testBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-mustache-test.bp");
    Cluster cluster = cluster();
    BlueprintStackInfo blueprintStackInfo = new BlueprintStackInfo("hdp", "2.4");
    BlueprintPreparationObject blueprintPreparationObject = BlueprintPreparationObject.Builder.builder().withRdsConfigs(cluster.getRdsConfigs()).withGateway(cluster.getGateway()).withLdapConfig(cluster.getLdapConfig()).withGeneralClusterConfigs(generalClusterConfigs()).withBlueprintView(new BlueprintView(testBlueprint, blueprintStackInfo.getVersion(), blueprintStackInfo.getType())).build();
    String result = underTest.process(testBlueprint, blueprintPreparationObject, Maps.newHashMap());
    assertTrue(result.contains("\"db_host\": \"10.1.1.1:5432\""));
    assertTrue(result.contains("\"db_user\": \"heyitsme\""));
    assertTrue(result.contains("\"db_password\": \"iamsoosecure\""));
    assertTrue(result.contains("\"db_name\": \"ranger\""));
    assertTrue(result.contains("\"ranger_privelege_user_jdbc_url\": \"jdbc:postgresql://10.1.1.1:5432\""));
    assertTrue(result.contains("\"ranger.jpa.jdbc.url\": \"jdbc:postgresql://10.1.1.1:5432/ranger\""));
}
Also used : BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Example 78 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster 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 79 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster 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 80 with Cluster

use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testKerberosWithoutKnox.

@Test
public void testKerberosWithoutKnox() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = createInstanceGroups();
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    instanceGroups.add(createInstanceGroup("gateway", 1));
    JsonNode blueprintJsonTree = createJsonTree();
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN no exception thrown
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Aggregations

Cluster (com.sequenceiq.cloudbreak.domain.Cluster)144 Stack (com.sequenceiq.cloudbreak.domain.Stack)68 Test (org.junit.Test)64 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)31 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)26 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)22 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)22 HashMap (java.util.HashMap)22 HashSet (java.util.HashSet)15 List (java.util.List)15 ArrayList (java.util.ArrayList)13 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)12 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)11 Matchers.anyString (org.mockito.Matchers.anyString)11 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)10 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)10 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)9 Json (com.sequenceiq.cloudbreak.domain.json.Json)9 PollingResult (com.sequenceiq.cloudbreak.service.PollingResult)9