Search in sources :

Example 6 with BlueprintPreparationObject

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

the class HbaseConfigProviderTest method testCustomTextManipulationWhenThereAreMissingHbaseClients.

@Test
public void testCustomTextManipulationWhenThereAreMissingHbaseClients() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-kerberized-test.bp");
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().build();
    Set<String> masters = Sets.newHashSet("master", "slave_1", "slave_2", "compute");
    Set<String> clients = Sets.newHashSet("slave_1", "slave_2", "compute_1");
    Set<String> missing = Sets.newHashSet("master", "compute");
    when(blueprintProcessor.getHostGroupsWithComponent("HBASE_MASTER")).thenReturn(masters);
    when(blueprintProcessor.getHostGroupsWithComponent("HBASE_CLIENT")).thenReturn(clients);
    when(blueprintProcessor.addComponentToHostgroups("HBASE_CLIENT", missing)).thenReturn(blueprintProcessor);
    when(blueprintProcessor.asText()).thenReturn(blueprintText);
    when(blueprintProcessorFactory.get(anyString())).thenReturn(blueprintProcessor);
    String result = underTest.customTextManipulation(object, blueprintProcessor).asText();
    Assert.assertEquals(blueprintText, result);
    verify(blueprintProcessor, times(1)).getHostGroupsWithComponent("HBASE_MASTER");
    verify(blueprintProcessor, times(1)).getHostGroupsWithComponent("HBASE_CLIENT");
    verify(blueprintProcessor, times(1)).addComponentToHostgroups("HBASE_CLIENT", missing);
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with BlueprintPreparationObject

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

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosOnKerberizedBlueprint.

@Test
public void testExtendBlueprintWithKerberosOnKerberizedBlueprint() throws IOException {
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-kerberized-test.bp");
    Blueprint blueprint = TestUtil.blueprint("name", expectedBlueprint);
    Stack stack = TestUtil.stack();
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, TestUtil.kerberosConfig());
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(BlueprintTestUtil.generalClusterConfigs()).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : 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 8 with BlueprintPreparationObject

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

the class KerberosBlueprintServiceTest method testExtendBlueprintWithKerberosCustomConfig.

@Test
public void testExtendBlueprintWithKerberosCustomConfig() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized.bp");
    Blueprint blueprint = TestUtil.blueprint("name", blueprintText);
    Stack stack = TestUtil.stack();
    KerberosConfig kerberosConfig = new KerberosConfig();
    kerberosConfig.setDescriptor("{\"kerberos-env\":{\"properties\":{\"install_packages\":false,\"realm\":\"REALM.BP\",\"kdc_type\":\"mit-kdc\"," + "\"kdc_hosts\":\"kdc_host.bp\",\"admin_server_host\":\"admin_server_host.bp\",\"encryption_types\":\"enc_types.bp\",\"ldap_url\":\"\"," + "\"container_dn\":\"\"}}}");
    kerberosConfig.setKrb5Conf("{\"krb5-conf\":{\"properties\":{\"domains\":\".domains.bp\",\"manage_krb5_conf\":\"true\",\"content\":\"content.bp\"}}}");
    kerberosConfig.setTcpAllowed(true);
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L, kerberosConfig);
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withKerberosConfig(cluster.getKerberosConfig()).withGeneralClusterConfigs(BlueprintTestUtil.generalClusterConfigs()).build();
    BlueprintTextProcessor b = new BlueprintTextProcessor(blueprint.getBlueprintText());
    String actualBlueprint = underTest.customTextManipulation(object, b).asText();
    String expectedBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-not-kerberized-custom-config-expected.bp");
    JsonNode expectedNode = JsonUtil.readTree(expectedBlueprint);
    JsonNode resultNode = JsonUtil.readTree(actualBlueprint);
    Assert.assertEquals(expectedNode, resultNode);
}
Also used : 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 9 with BlueprintPreparationObject

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

the class CentralBlueprintUpdaterNegativeInputTest method testForMissingBlueprintsBlockInBlueprint.

@Test
public void testForMissingBlueprintsBlockInBlueprint() throws IOException {
    expectedException.expect(BlueprintProcessingException.class);
    BlueprintPreparationObject model = getExtendedPreparedBlueprintBuilder("missing-blueprints-block.bp").build();
    getUnderTest().getBlueprintText(model);
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Example 10 with BlueprintPreparationObject

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

the class CentralBlueprintUpdaterNegativeInputTest method testInvalidJsonInput.

@Test
public void testInvalidJsonInput() throws IOException {
    expectedException.expect(BlueprintProcessingException.class);
    BlueprintPreparationObject model = getExtendedPreparedBlueprintBuilder("invalid-json.bp").build();
    getUnderTest().getBlueprintText(model);
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Aggregations

BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)28 Test (org.junit.Test)24 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)11 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)8 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)5 Matchers.anyString (org.mockito.Matchers.anyString)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 HashMap (java.util.HashMap)2 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)1 GeneratedBlueprintResponse (com.sequenceiq.cloudbreak.api.model.GeneratedBlueprintResponse)1 HostgroupConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations)1 SiteConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations)1 HdfConfigs (com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs)1 TestFile (com.sequenceiq.cloudbreak.blueprint.testrepeater.TestFile)1