use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaScalingValidationServiceTest method testDownscaleIfPathIsPermittedThenValidationPasses.
@Test
public void testDownscaleIfPathIsPermittedThenValidationPasses() {
Stack stack = mock(Stack.class);
Set<InstanceMetaData> validImSet = createValidImSet(3);
when(stack.isAvailable()).thenReturn(true);
when(allowedScalingPaths.getPaths()).thenReturn(createAllowedScalingPaths());
assertDoesNotThrow(() -> underTest.validateStackForDownscale(validImSet, stack, createScalingPath(true)));
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaScalingValidationServiceTest method testUpscaleIfMoreInstancesExistsThenValidationFails.
@Test
public void testUpscaleIfMoreInstancesExistsThenValidationFails() {
Stack stack = mock(Stack.class);
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.validateStackForUpscale(createValidImSet(4), stack, null));
assertEquals("Upscaling currently only available for FreeIPA installation with 1 or 2 instances", exception.getMessage());
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method getDeletedStack.
private Stack getDeletedStack() {
Stack stack = new Stack();
stack.setResourceCrn(ENVIRONMENT_ID);
InstanceGroup instanceGroup = new InstanceGroup();
stack.getInstanceGroups().add(instanceGroup);
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceStatus(InstanceStatus.TERMINATED);
instanceMetaData.setInstanceId(INSTANCE_ID1);
instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
instanceMetaData.setDiscoveryFQDN(HOST1);
return stack;
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method getStackTwoInstances.
private Stack getStackTwoInstances(InstanceMetaData im1, InstanceMetaData im2) {
Stack stack = new Stack();
stack.setResourceCrn(ENVIRONMENT_ID);
InstanceGroup instanceGroup = new InstanceGroup();
stack.getInstanceGroups().add(instanceGroup);
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
instanceGroup.setInstanceMetaData(Set.of(im1, im2));
return stack;
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaUpgradeCcmServiceTest method upgradeCcmTestWhenAvailableAndOperationRunning.
@Test
void upgradeCcmTestWhenAvailableAndOperationRunning() {
Stack stack = createStack(Status.AVAILABLE);
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
Operation operation = createOperation(OperationState.RUNNING);
when(operationService.startOperation(ACCOUNT_ID, OperationType.UPGRADE_CCM, List.of(ENVIRONMENT_CRN), List.of())).thenReturn(operation);
when(operationConverter.convert(operation)).thenReturn(operationStatus);
OperationStatus result = underTest.upgradeCcm(ENVIRONMENT_CRN, ACCOUNT_ID);
assertThat(result).isSameAs(operationStatus);
ArgumentCaptor<UpgradeCcmFlowChainTriggerEvent> eventCaptor = ArgumentCaptor.forClass(UpgradeCcmFlowChainTriggerEvent.class);
verify(flowManager).notify(eq(UPGRADE_CCM_CHAIN_TRIGGER_EVENT), eventCaptor.capture());
UpgradeCcmFlowChainTriggerEvent event = eventCaptor.getValue();
assertThat(event.getOldTunnel()).isEqualTo(Tunnel.CCM);
assertThat(event.getOperationId()).isEqualTo(OPERATION_ID);
assertThat(event.getResourceId()).isEqualTo(STACK_ID);
}
Aggregations