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);
}
}
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");
}
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());
}
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());
}
Aggregations