Search in sources :

Example 6 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaInstanceUtil method getInstanceIds.

public List<String> getInstanceIds(FreeIpaTestDto freeIpaTestDto, FreeIpaClient freeIpaClient, String hostGroupName) {
    DescribeFreeIpaResponse describeFreeIpaResponse = freeIpaClient.getDefaultClient().getFreeIpaV1Endpoint().describe(freeIpaTestDto.getRequest().getEnvironmentCrn());
    List<InstanceGroupResponse> instanceGroupResponses = describeFreeIpaResponse.getInstanceGroups();
    InstanceGroupResponse instanceGroupResponse = instanceGroupResponses.stream().filter(instanceGroup -> instanceGroup.getName().equals(hostGroupName)).findFirst().orElse(null);
    return Objects.requireNonNull(instanceGroupResponse).getMetaData().stream().map(InstanceMetaDataResponse::getInstanceId).collect(Collectors.toList());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)

Example 7 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaCreationHandlerTest method shouldAttachFreeIpaInCaseOfChildEnvironment.

@Test
public void shouldAttachFreeIpaInCaseOfChildEnvironment() throws Exception {
    DescribeFreeIpaResponse describeFreeIpaResponse = mock(DescribeFreeIpaResponse.class);
    EnvironmentDto environmentDto = aYarnEnvironmentDtoWithParentEnvironment();
    Environment environment = anEnvironmentWithParent();
    ArgumentCaptor<AddDnsZoneForSubnetsRequest> addDnsZoneForSubnetsRequestArgumentCaptor = ArgumentCaptor.forClass(AddDnsZoneForSubnetsRequest.class);
    when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
    when(freeIpaService.describe(PARENT_ENVIRONMENT_CRN)).thenReturn(Optional.of(describeFreeIpaResponse));
    victim.accept(new Event<>(environmentDto));
    ArgumentCaptor<AttachChildEnvironmentRequest> attachChildEnvironmentRequestArgumentCaptor = ArgumentCaptor.forClass(AttachChildEnvironmentRequest.class);
    verify(dnsV1Endpoint).addDnsZoneForSubnets(addDnsZoneForSubnetsRequestArgumentCaptor.capture());
    verify(freeIpaService).attachChildEnvironment(attachChildEnvironmentRequestArgumentCaptor.capture());
    verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Headers.class));
    assertEquals(PARENT_ENVIRONMENT_CRN, addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getEnvironmentCrn());
    assertEquals(Collections.singletonList(YARN_NETWORK_CIDR), addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getSubnets());
    assertEquals(ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getChildEnvironmentCrn());
    assertEquals(PARENT_ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getParentEnvironmentCrn());
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) AddDnsZoneForSubnetsRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetsRequest) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Headers(reactor.bus.Event.Headers) Environment(com.sequenceiq.environment.environment.domain.Environment) AttachChildEnvironmentRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.attachchildenv.AttachChildEnvironmentRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaCreationRetrievalTaskTest method testCheckStatusWithFailedState.

@Test
void testCheckStatusWithFailedState() {
    FreeIpaPollerObject freeIpaPollerObject = new FreeIpaPollerObject(ENV_ID, ENV_CRN);
    DescribeFreeIpaResponse freeIpa = new DescribeFreeIpaResponse();
    freeIpa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    freeIpa.setStatus(DELETE_IN_PROGRESS);
    freeIpa.setName(FREE_IPA_NAME);
    freeIpa.setCrn(FREE_IPA_CRN);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeIpa));
    assertThrows(FreeIpaOperationFailedException.class, () -> underTest.checkStatus(freeIpaPollerObject));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 9 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaCreationRetrievalTaskTest method testCheckStatusWithDeleteInProgressState.

@Test
void testCheckStatusWithDeleteInProgressState() {
    FreeIpaPollerObject freeIpaPollerObject = new FreeIpaPollerObject(ENV_ID, ENV_CRN);
    DescribeFreeIpaResponse freeIpa = new DescribeFreeIpaResponse();
    freeIpa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    freeIpa.setStatus(DELETE_IN_PROGRESS);
    freeIpa.setName(FREE_IPA_NAME);
    freeIpa.setCrn(FREE_IPA_CRN);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeIpa));
    assertThrows(FreeIpaOperationFailedException.class, () -> underTest.checkStatus(freeIpaPollerObject));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 10 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaAcceptedStatuses.

@ParameterizedTest
@EnumSource(value = Status.class, names = { "AVAILABLE", "UPGRADE_CCM_FAILED" }, mode = EnumSource.Mode.INCLUDE)
void testFreeIpaAcceptedStatuses(Status status) {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(status);
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    Optional<DescribeFreeIpaResponse> freeipaOpt = Optional.of(freeipa);
    when(freeIpaService.describe(any())).thenReturn(freeipaOpt);
    underTest.accept(mockEnvironmentDtoEvent);
    verify(freeIpaPollerService).waitForCcmUpgrade(TEST_ENV_ID, TEST_ENV_CRN);
    UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_TUNNEL_UPDATE_EVENT");
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)60 Test (org.junit.jupiter.api.Test)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)8 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)7 InstanceGroupResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)6 AttemptResults (com.dyngr.core.AttemptResults)5 Stack (com.sequenceiq.freeipa.entity.Stack)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)3 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)3 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)3 InstanceMetaDataResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse)3 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 Environment (com.sequenceiq.environment.environment.domain.Environment)2