use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath in project cloudbreak by hortonworks.
the class FreeIpaScalingServiceTest method testUpscaleIfValidationFailsThenErrorThrown.
@Test
public void testUpscaleIfValidationFailsThenErrorThrown() {
Stack stack = mock(Stack.class);
Set<InstanceMetaData> allInstances = createValidImSet();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
UpscaleRequest request = createUpscaleRequest();
doThrow(new BadRequestException("validation failed")).when(validationService).validateStackForUpscale(allInstances, stack, new ScalingPath(AvailabilityType.TWO_NODE_BASED, AvailabilityType.HA));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.upscale(ACCOUNT_ID, request));
assertEquals(exception.getMessage(), "validation failed");
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath in project cloudbreak by hortonworks.
the class FreeIpaScalingService method upscale.
public UpscaleResponse upscale(String accountId, UpscaleRequest request) {
Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(request.getEnvironmentCrn(), accountId);
Set<InstanceMetaData> allInstances = stack.getNotDeletedInstanceMetaDataSet();
AvailabilityType originalAvailabilityType = AvailabilityType.getByInstanceCount(allInstances.size());
logRequest(OperationType.UPSCALE, request, originalAvailabilityType);
validationService.validateStackForUpscale(allInstances, stack, new ScalingPath(originalAvailabilityType, request.getTargetAvailabilityType()));
return triggerUpscale(request, stack, originalAvailabilityType);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath in project cloudbreak by hortonworks.
the class FreeIpaScalingValidationServiceTest method createScalingPath.
private ScalingPath createScalingPath(boolean allowed) {
AvailabilityType originalAvailabilityType = AvailabilityType.NON_HA;
AvailabilityType targetAvailabilityType = AvailabilityType.HA;
return allowed ? new ScalingPath(originalAvailabilityType, targetAvailabilityType) : new ScalingPath(targetAvailabilityType, originalAvailabilityType);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath in project cloudbreak by hortonworks.
the class FreeIpaScalingServiceTest method testDownscaleIfValidationFailsThenErrorThrown.
@Test
public void testDownscaleIfValidationFailsThenErrorThrown() {
Stack stack = mock(Stack.class);
Set<InstanceMetaData> allInstances = createValidImSet();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
DownscaleRequest request = createDownscaleRequest();
doThrow(new BadRequestException("validation failed")).when(validationService).validateStackForDownscale(allInstances, stack, new ScalingPath(AvailabilityType.TWO_NODE_BASED, AvailabilityType.NON_HA));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.downscale(ACCOUNT_ID, request));
assertEquals(exception.getMessage(), "validation failed");
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath in project cloudbreak by hortonworks.
the class FreeIpaScalingService method downscale.
public DownscaleResponse downscale(String accountId, DownscaleRequest request) {
Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(request.getEnvironmentCrn(), accountId);
Set<InstanceMetaData> allInstances = stack.getNotDeletedInstanceMetaDataSet();
AvailabilityType originalAvailabilityType = AvailabilityType.getByInstanceCount(allInstances.size());
logRequest(OperationType.DOWNSCALE, request, originalAvailabilityType);
validationService.validateStackForDownscale(allInstances, stack, new ScalingPath(originalAvailabilityType, request.getTargetAvailabilityType()));
return triggerDownscale(request, stack, originalAvailabilityType);
}
Aggregations