Search in sources :

Example 46 with Stack

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)));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 47 with Stack

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());
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 48 with Stack

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;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 49 with 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;
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 50 with 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);
}
Also used : OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) UpgradeCcmFlowChainTriggerEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23