Search in sources :

Example 1 with Blueprint

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

the class BlueprintValidatorTest method testHostGroupScalingThrowsBadRequestExceptionWhenNodeCountIsMoreThanMax.

@Test
public void testHostGroupScalingThrowsBadRequestExceptionWhenNodeCountIsMoreThanMax() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    JsonNode blueprintJsonTree = createJsonTree();
    InstanceGroup instanceGroup = createInstanceGroup(GROUP3, 3);
    HostGroup hostGroup = createHostGroup(instanceGroup.getGroupName(), instanceGroup);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("The node count '4' for hostgroup 'group3' cannot be less than '1' or more than '3' because of 'mastercomp3' component");
    // WHEN
    underTest.validateHostGroupScalingRequest(blueprint, hostGroup, 1);
// THEN throw exception
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 2 with Blueprint

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

the class BlueprintValidatorTest method testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenNotEnoughGroupDefinedInBlueprint.

@Test
public void testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenNotEnoughGroupDefinedInBlueprint() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = createInstanceGroups();
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNode blueprintJsonTree = createJsonTreeWithNotEnoughGroup();
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage(Matchers.startsWith("The host groups in the validation"));
    // WHEN
    underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN throw exception
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 3 with Blueprint

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

the class BlueprintValidatorTest method testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenComponentIsLessThanMin.

@Test
public void testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenComponentIsLessThanMin() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = createInstanceGroups();
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    instanceGroups.add(createInstanceGroup("gateway", 1));
    JsonNode blueprintJsonTree = createJsonTreeWithComponentIsLess();
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("Incorrect number of 'slavecomp2' components are in '[group3]' hostgroups: count: 3, min: 5 max: 6");
    // WHEN
    underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN throw exception
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 4 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint 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)

Example 5 with Blueprint

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

the class BlueprintValidatorTest method testKnoxValidationWithNoGateway.

@Test
public void testKnoxValidationWithNoGateway() 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

Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)71 Test (org.junit.Test)29 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)22 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)22 Stack (com.sequenceiq.cloudbreak.domain.Stack)16 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)7 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)6 List (java.util.List)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)4 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)4 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)4