Search in sources :

Example 1 with NetworkScaleV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request in project cloudbreak by hortonworks.

the class DistroXScaleV1RequestToStackScaleV4RequestConverter method setStackNetworkScaleRequest.

private void setStackNetworkScaleRequest(NetworkScaleV1Request networkScaleV1Request, StackScaleV4Request stackScaleV4Request) {
    if (networkScaleV1Request != null) {
        NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
        networkScaleV4Request.setPreferredSubnetIds(networkScaleV1Request.getPreferredSubnetIds());
        stackScaleV4Request.setStackNetworkScaleV4Request(networkScaleV4Request);
    }
}
Also used : NetworkScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request)

Example 2 with NetworkScaleV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request in project cloudbreak by hortonworks.

the class StackCommonServiceTest method testPutScalingInWorkspaceWhenThereIsPreferredAzAndStackProvisionedInMultipleSubnetButScalingIsNotSupportedOnPlatform.

@Test
public void testPutScalingInWorkspaceWhenThereIsPreferredAzAndStackProvisionedInMultipleSubnetButScalingIsNotSupportedOnPlatform() throws TransactionService.TransactionExecutionException {
    Stack stack = new Stack();
    stack.setCloudPlatform(AwsConstants.AWS_PLATFORM.value());
    String variant = AwsConstants.AwsVariant.AWS_NATIVE_VARIANT.name();
    stack.setPlatformVariant(variant);
    when(transactionService.required(any(Supplier.class))).thenReturn(stack);
    NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
    networkScaleV4Request.setPreferredSubnetIds(List.of(SUBNET_ID));
    StackScaleV4Request updateRequest = new StackScaleV4Request();
    updateRequest.setStackNetworkScaleV4Request(networkScaleV4Request);
    UpdateStackV4Request updateStackV4Request = new UpdateStackV4Request();
    InstanceGroupAdjustmentV4Request instanceGroupAdjustment = new InstanceGroupAdjustmentV4Request();
    instanceGroupAdjustment.setScalingAdjustment(1);
    updateStackV4Request.setInstanceGroupAdjustment(instanceGroupAdjustment);
    when(stackScaleV4RequestToUpdateStackV4RequestConverter.convert(any())).thenReturn(updateStackV4Request);
    when(cloudParameterCache.isUpScalingSupported(anyString())).thenReturn(Boolean.FALSE);
    BadRequestException actual = assertThrows(BadRequestException.class, () -> underTest.putScalingInWorkspace(STACK_NAME, WORKSPACE_ID, updateRequest));
    assertEquals(actual.getMessage(), "Upscaling is not supported on AWS cloudplatform");
}
Also used : NetworkScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request) StackScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request) UpdateStackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.UpdateStackV4Request) InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Supplier(java.util.function.Supplier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with NetworkScaleV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request in project cloudbreak by hortonworks.

the class StackCommonServiceTest method testValidateNetworkScaleRequestWhenThereIsPreferredAzAndStackProvisionedToASingleSubnet.

@Test
public void testValidateNetworkScaleRequestWhenThereIsPreferredAzAndStackProvisionedToASingleSubnet() {
    Stack stack = new Stack();
    String variant = AwsConstants.AwsVariant.AWS_NATIVE_VARIANT.name();
    stack.setPlatformVariant(variant);
    when(multiAzValidator.supportedVariant(variant)).thenReturn(Boolean.TRUE);
    when(multiAzValidator.collectSubnetIds(any())).thenReturn(Set.of(SUBNET_ID));
    NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
    networkScaleV4Request.setPreferredSubnetIds(List.of(SUBNET_ID));
    Assertions.assertThrows(BadRequestException.class, () -> underTest.validateNetworkScaleRequest(stack, networkScaleV4Request));
    Mockito.verify(multiAzValidator, times(1)).supportedVariant(variant);
    Mockito.verify(multiAzValidator, times(1)).collectSubnetIds(any());
}
Also used : NetworkScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 4 with NetworkScaleV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request in project cloudbreak by hortonworks.

the class StackCommonServiceTest method testvalidateNetworkScaleRequestWhenVariantIsNotSupportedForMultiAzButAzHasBeenPreferredInTheRequest.

@Test
public void testvalidateNetworkScaleRequestWhenVariantIsNotSupportedForMultiAzButAzHasBeenPreferredInTheRequest() {
    Stack stack = new Stack();
    String variant = AwsConstants.AwsVariant.AWS_VARIANT.name();
    stack.setPlatformVariant(variant);
    when(multiAzValidator.supportedVariant(variant)).thenReturn(Boolean.FALSE);
    NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
    networkScaleV4Request.setPreferredSubnetIds(List.of(SUBNET_ID));
    Assertions.assertThrows(BadRequestException.class, () -> underTest.validateNetworkScaleRequest(stack, networkScaleV4Request));
    Mockito.verify(multiAzValidator, times(1)).supportedVariant(variant);
    Mockito.verify(multiAzValidator, times(0)).collectSubnetIds(any());
}
Also used : NetworkScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkScaleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkScaleV4Request)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 Test (org.junit.jupiter.api.Test)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 InstanceGroupAdjustmentV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request)1 UpdateStackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.UpdateStackV4Request)1 StackScaleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Supplier (java.util.function.Supplier)1