Search in sources :

Example 1 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class StackToStackV4RequestConverter method getInstanceGroups.

private List<InstanceGroupV4Request> getInstanceGroups(Stack stack) {
    List<InstanceGroupV4Request> ret = new ArrayList<>();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        InstanceGroupV4Request instanceGroupV4Request = instanceGroupToInstanceGroupV4RequestConverter.convert(instanceGroup);
        collectInformationsFromActualHostgroup(stack.getCluster(), instanceGroup, instanceGroupV4Request);
        ret.add(instanceGroupV4Request);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 2 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class InstanceGroupV4RequestToHostGroupConverterTest method testConvertWhenHostNameUpperCase.

@Test
public void testConvertWhenHostNameUpperCase() {
    InstanceGroupV4Request source = new InstanceGroupV4Request();
    source.setName("MixEdName");
    source.setTemplate(new InstanceTemplateV4Request());
    HostGroup actual = underTest.convert(source);
    assertEquals(actual.getName(), "mixedname");
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test)

Example 3 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class InstanceGroupV4RequestToInstanceGroupConverterTest method testConvertWhenHostNameUpperCase.

@Test
public void testConvertWhenHostNameUpperCase() {
    InstanceGroupV4Request source = new InstanceGroupV4Request();
    source.setName("MixEdName");
    source.setTemplate(new InstanceTemplateV4Request());
    when(providerParameterCalculator.get(source)).thenReturn(mock(Mappable.class));
    when(instanceTemplateV4RequestToTemplateConverter.convert(any())).thenReturn(new Template());
    InstanceGroup actual = underTest.convert(source, "variant");
    assertEquals(actual.getGroupName(), "mixedname");
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Mappable(com.sequenceiq.cloudbreak.common.mappable.Mappable) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Template(com.sequenceiq.cloudbreak.domain.Template) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 4 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class StackCreatorServiceRecipeValidationTest method getInstanceGroupWithRecipe.

private InstanceGroupV4Request getInstanceGroupWithRecipe(String instanceGroupName, Set<String> recipeNames) {
    InstanceGroupV4Request request = new InstanceGroupV4Request();
    request.setName(instanceGroupName);
    request.setRecipeNames(recipeNames);
    return request;
}
Also used : InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 5 with InstanceGroupV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request in project cloudbreak by hortonworks.

the class StackCreatorServiceTest method shouldThrowBadRequestWhenRecipeIsMissing.

@Test
public void shouldThrowBadRequestWhenRecipeIsMissing() {
    User user = new User();
    Workspace workspace = new Workspace();
    workspace.setId(WORKSPACE_ID);
    StackV4Request stackRequest = new StackV4Request();
    InstanceGroupV4Request instanceGroupV4Request = new InstanceGroupV4Request();
    instanceGroupV4Request.setName(INSTANCE_GROUP);
    instanceGroupV4Request.setRecipeNames(Set.of(RECIPE_NAME));
    stackRequest.setInstanceGroups(List.of(instanceGroupV4Request));
    doNothing().when(nodeCountLimitValidator).validateProvision(any());
    doThrow(new NotFoundException("missing recipe")).when(recipeService).get(NameOrCrn.ofName(RECIPE_NAME), WORKSPACE_ID);
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.createStack(user, workspace, stackRequest, false));
    assertThat(badRequestException).hasMessage("The given recipe does not exist for the instance group \"INSTANCE_GROUP\": RECIPE_NAME");
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)51 Test (org.junit.jupiter.api.Test)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)22 InstanceTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request)18 ArrayList (java.util.ArrayList)8 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)5 InstanceGroupNetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)4 SecurityGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.securitygroup.SecurityGroupV4Request)4 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)2 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)2 SecurityRuleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.SecurityRuleV4Request)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)2 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)2 List (java.util.List)2 Test (org.junit.Test)2 Strings (com.google.common.base.Strings)1