Search in sources :

Example 1 with Cluster

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

the class BlueprintTemplateProcessorTest method testMustacheGeneratorForDruidRDS.

@Test
public void testMustacheGeneratorForDruidRDS() 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("\"druid.metadata.storage.type\": \"postgresql\""));
    assertTrue(result.contains("\"druid.metadata.storage.connector.connectURI\": \"jdbc:postgresql://10.1.1.1:5432/druid\""));
    assertTrue(result.contains("\"druid.metadata.storage.connector.user\": \"heyitsme\""));
    assertTrue(result.contains("\"druid.metadata.storage.connector.password\": \"iamsoosecure\""));
}
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 2 with Cluster

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

the class BlueprintTemplateProcessorTest method testMustacheGeneratorWithSimpleUseCase.

@Test
public void testMustacheGeneratorWithSimpleUseCase() 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");
    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())).build();
    String result = underTest.process(testBlueprint, blueprintPreparationObject, Maps.newHashMap());
    assertTrue(result.contains("testbucket"));
    assertTrue(result.contains("{{ zookeeper_quorum }}"));
    assertTrue(result.contains("{{default('/configurations/hadoop-env/hdfs_log_dir_prefix', '/var/log/hadoop')}}"));
    assertTrue(result.contains(cluster.getName()));
    assertTrue(result.contains("jdbc:postgresql://10.1.1.1:5432/ranger"));
    assertTrue(result.contains("cn=users,dc=example,dc=org"));
    assertTrue(result.contains("ldap://localhost:389"));
}
Also used : 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 3 with Cluster

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

the class BlueprintTemplateProcessorTest method testMustacheGeneratorForCustomRDSType.

@Test
public void testMustacheGeneratorForCustomRDSType() throws Exception {
    String testBlueprint = FileReaderUtils.readFileFromClasspath("blueprints-jackson/bp-mustache-test.bp");
    Cluster cluster = cluster();
    cluster.getRdsConfigs().add(rdsConfig("customRds"));
    BlueprintStackInfo blueprintStackInfo = new BlueprintStackInfo("hdp", "2.4");
    BlueprintPreparationObject blueprintPreparationObject = BlueprintPreparationObject.Builder.builder().withBlueprintView(new BlueprintView(testBlueprint, blueprintStackInfo.getVersion(), blueprintStackInfo.getType())).withRdsConfigs(cluster.getRdsConfigs()).withGeneralClusterConfigs(generalClusterConfigs(cluster)).build();
    String result = underTest.process(testBlueprint, blueprintPreparationObject, Maps.newHashMap());
    assertTrue(result.contains("\"custom.metadata.storage.type\": \"postgresql\""));
    assertTrue(result.contains("\"custom.metadata.storage.engine\": \"postgres\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.connectURI\": \"jdbc:postgresql://10.1.1.1:5432/customRds\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.host\": \"10.1.1.1\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.connectionHost\": \"10.1.1.1:5432\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.user\": \"heyitsme\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.password\": \"iamsoosecure\""));
    assertTrue(result.contains("\"custom.metadata.storage.connector.databasename\": \"customRds\""));
}
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 4 with Cluster

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

the class BlueprintTemplateProcessorTest method cluster.

private Cluster cluster() {
    Cluster cluster = TestUtil.cluster();
    Set<RDSConfig> rdsConfigSet = new HashSet<>();
    rdsConfigSet.add(rdsConfig(RdsType.DRUID.name().toLowerCase()));
    RDSConfig hiveRds = rdsConfig(RdsType.HIVE.name().toLowerCase());
    rdsConfigSet.add(hiveRds);
    rdsConfigSet.add(rdsConfig(RdsType.RANGER.name().toLowerCase()));
    cluster.setRdsConfigs(rdsConfigSet);
    Map<String, String> inputs = new HashMap<>();
    inputs.put("S3_BUCKET", "testbucket");
    try {
        cluster.setBlueprintInputs(new Json(inputs));
    } catch (JsonProcessingException ignored) {
        cluster.setBlueprintInputs(null);
    }
    return cluster;
}
Also used : HashMap(java.util.HashMap) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashSet(java.util.HashSet)

Example 5 with Cluster

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

the class BlueprintValidatorTest method testKnoxWithKerberosAndNonGwHasKnox.

@Test
public void testKnoxWithKerberosAndNonGwHasKnox() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectNode rootNode = jsonNodeFactory.objectNode();
    ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
    addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "gateway2", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, KNOX);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    cluster.setGateway(gateway);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("In case of Knox and Kerberos each 'Ambari Server' node must include the 'KNOX_GATEWAY' service. " + "The following host groups are missing the service: gateway1,gateway2");
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN exception thrown
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) 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