Search in sources :

Example 66 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class RepairInstancesServiceTest method testRepairInstancesWithNoneSpecified.

@Test
void testRepairInstancesWithNoneSpecified() {
    Stack stack = createStack(Status.UNHEALTHY, List.of(InstanceStatus.CREATED, InstanceStatus.UNREACHABLE));
    List<String> instanceIds = List.of("i-2");
    OperationStatus operationStatus = new OperationStatus();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(stack);
    when(healthDetailsService.getHealthDetails(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(createHealthDetails(InstanceStatus.CREATED, InstanceStatus.UNREACHABLE));
    when(operationService.startOperation(any(), any(), any(), any())).thenReturn(createOperation());
    when(operationToOperationStatusConverter.convert(any())).thenReturn(operationStatus);
    when(entitlementService.freeIpaHaRepairEnabled(any())).thenReturn(Boolean.TRUE);
    when(stackUpdater.updateStackStatus(anyLong(), any(), any())).thenReturn(stack);
    RepairInstancesRequest request = new RepairInstancesRequest();
    request.setEnvironmentCrn(ENVIRONMENT_ID1);
    assertEquals(operationStatus, underTest.repairInstances(ACCOUNT_ID, request));
    ArgumentCaptor acAcceptable = ArgumentCaptor.forClass(Acceptable.class);
    verify(flowManager).notify(eq("REPAIR_TRIGGER_EVENT"), (Acceptable) acAcceptable.capture());
    assertTrue(acAcceptable.getValue() instanceof RepairEvent);
    RepairEvent repairEvent = (RepairEvent) acAcceptable.getValue();
    assertEquals(instanceIds, repairEvent.getRepairInstanceIds());
    verify(stackUpdater).updateStackStatus(eq(STACK_ID), eq(DetailedStackStatus.REPAIR_REQUESTED), any());
}
Also used : ArgumentCaptor(org.mockito.ArgumentCaptor) OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) RepairEvent(com.sequenceiq.freeipa.flow.freeipa.repair.event.RepairEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RepairInstancesRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.repair.RepairInstancesRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 67 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class ChildEnvironmentServiceTest method findMultipleParentStackByChildEnvironmentCrnWithListsEvenIfTerminatedWithLIst.

@Test
void findMultipleParentStackByChildEnvironmentCrnWithListsEvenIfTerminatedWithLIst() {
    List<Stack> stackList = List.of(new Stack());
    when(repository.findMultipleParentByEnvironmentCrnEvenIfTerminatedWithList(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stackList);
    List<Stack> result = underTest.findMultipleParentStackByChildEnvironmentCrnEvenIfTerminatedWithList(ENVIRONMENT_CRN, ACCOUNT_ID);
    assertEquals(stackList, result);
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 68 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class ChildEnvironmentServiceTest method findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated.

@Test
void findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated() {
    Optional<Stack> stack = Optional.of(new Stack());
    when(repository.findParentByEnvironmentCrnAndCrnWthListsEvenIfTerminated(ENVIRONMENT_CRN, ACCOUNT_ID, FREEIPA_CRN)).thenReturn(stack);
    Optional<Stack> result = underTest.findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated(ENVIRONMENT_CRN, ACCOUNT_ID, FREEIPA_CRN);
    assertEquals(stack, result);
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 69 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testGetPathWithStackWithServiceNameRegistered.

@Test
public void testGetPathWithStackWithServiceNameRegistered() {
    when(clusterProxyConfiguration.getClusterProxyBasePath()).thenReturn("basePath");
    Stack stack = getAStack();
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain("ipadom");
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    ReadConfigResponse readConfigResponse = new ReadConfigResponse();
    ReadConfigService service = new ReadConfigService();
    service.setName("registered");
    readConfigResponse.setServices(List.of(service));
    when(clusterProxyRegistrationClient.readConfig(STACK_RESOURCE_CRN)).thenReturn(readConfigResponse);
    String result = underTest.getProxyPath(stack, Optional.of("registered"));
    assertEquals("basePath/proxy/resourceCrn/registered", result);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ReadConfigService(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigService) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 70 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method getAStack.

private Stack getAStack() {
    Stack stack = new Stack();
    stack.setAccountId(TEST_ACCOUNT_ID);
    stack.setResourceCrn(STACK_RESOURCE_CRN);
    SecurityConfig securityConfig = new SecurityConfig();
    stack.setSecurityConfig(securityConfig);
    return stack;
}
Also used : SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) Stack(com.sequenceiq.freeipa.entity.Stack)

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