Search in sources :

Example 16 with BlueprintPreparationObject

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

the class MysqlConfigProviderTest method testRemoveComponentFromBlueprintWhenBlueprintContainsMysqlServerThenShouldReturnTrue.

@Test
public void testRemoveComponentFromBlueprintWhenBlueprintContainsMysqlServerThenShouldReturnTrue() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-kerberized-test.bp");
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withRdsConfigs(Sets.newHashSet(TestUtil.rdsConfig(RdsType.HIVE))).build();
    when(blueprintProcessor.removeComponentFromBlueprint("MYSQL_SERVER")).thenReturn(blueprintProcessor);
    when(blueprintProcessor.asText()).thenReturn(blueprintText);
    when(blueprintProcessorFactory.get(anyString())).thenReturn(blueprintProcessor);
    Assert.assertEquals(blueprintText, underTest.customTextManipulation(object, blueprintProcessor).asText());
    verify(blueprintProcessor, times(1)).removeComponentFromBlueprint("MYSQL_SERVER");
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 17 with BlueprintPreparationObject

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

the class MysqlConfigProviderTest method testAdditionalCriteriaWhenBlueprintContainsMysqlServerThenShouldReturnTrue.

@Test
public void testAdditionalCriteriaWhenBlueprintContainsMysqlServerThenShouldReturnTrue() throws IOException {
    String blueprintText = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-kerberized-test.bp");
    BlueprintPreparationObject object = BlueprintPreparationObject.Builder.builder().withRdsConfigs(Sets.newHashSet(TestUtil.rdsConfig(RdsType.HIVE))).build();
    when(blueprintProcessor.componentExistsInBlueprint("MYSQL_SERVER")).thenReturn(true);
    when(blueprintProcessor.asText()).thenReturn(blueprintText);
    when(blueprintProcessorFactory.get(anyString())).thenReturn(blueprintProcessor);
    Assert.assertTrue(underTest.additionalCriteria(object, blueprintText));
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 18 with BlueprintPreparationObject

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

the class BlueprintTemplateProcessorTest method testMustacheGeneratorForHiveRDS.

@Test
public void testMustacheGeneratorForHiveRDS() 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("\"javax.jdo.option.ConnectionURL\": \"jdbc:postgresql://10.1.1.1:5432/hive\""));
    assertTrue(result.contains("\"javax.jdo.option.ConnectionUserName\": \"heyitsme\""));
    assertTrue(result.contains("\"javax.jdo.option.ConnectionPassword\": \"iamsoosecure\""));
    assertTrue(result.contains("\"javax.jdo.option.ConnectionDriverName\": \"org.postgresql.Driver\""));
    assertTrue(result.contains("\"hive_database_type\": \"postgres\""));
    assertTrue(result.contains("\"hive_database\": \"Existing postgresql Database\","));
}
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 19 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject 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 20 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject 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)

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