Search in sources :

Example 31 with DescribeFreeIpaResponse

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

the class StackToDescribeFreeIpaResponseConverterTest method convertTest.

@ParameterizedTest(name = "tunnel={0}")
@EnumSource(Tunnel.class)
@NullSource
void convertTest(Tunnel tunnel) {
    FreeIpaServerResponse freeIpaServerResponse = new FreeIpaServerResponse();
    Stack stack = createStack(tunnel);
    ImageEntity image = new ImageEntity();
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain(DOMAIN);
    UserSyncStatus userSyncStatus = new UserSyncStatus();
    when(authenticationResponseConverter.convert(stack.getStackAuthentication())).thenReturn(STACK_AUTHENTICATION_RESPONSE);
    when(imageSettingsResponseConverter.convert(image)).thenReturn(IMAGE_SETTINGS_RESPONSE);
    when(freeIpaServerResponseConverter.convert(freeIpa)).thenReturn(freeIpaServerResponse);
    when(instanceGroupConverter.convert(stack.getInstanceGroups(), true)).thenReturn(INSTANCE_GROUP_RESPONSES);
    when(userSyncStatusConverter.convert(userSyncStatus)).thenReturn(USERSYNC_STATUS_RESPONSE);
    when(balancedDnsAvailabilityChecker.isBalancedDnsAvailable(stack)).thenReturn(true);
    when(stackToAvailabilityStatusConverter.convert(stack)).thenReturn(AvailabilityStatus.AVAILABLE);
    DescribeFreeIpaResponse result = underTest.convert(stack, image, freeIpa, Optional.of(userSyncStatus), true);
    assertThat(result).returns(NAME, DescribeFreeIpaResponse::getName).returns(ENV_CRN, DescribeFreeIpaResponse::getEnvironmentCrn).returns(RESOURCE_CRN, DescribeFreeIpaResponse::getCrn).returns(CLOUD_PLATFORM, DescribeFreeIpaResponse::getCloudPlatform).returns(STACK_AUTHENTICATION_RESPONSE, DescribeFreeIpaResponse::getAuthentication).returns(IMAGE_SETTINGS_RESPONSE, DescribeFreeIpaResponse::getImage).returns(freeIpaServerResponse, DescribeFreeIpaResponse::getFreeIpa).returns(INSTANCE_GROUP_RESPONSES, DescribeFreeIpaResponse::getInstanceGroups).returns(STATUS, DescribeFreeIpaResponse::getStatus).returns(STATUS_REASON, DescribeFreeIpaResponse::getStatusReason).returns(STATUS_STRING, DescribeFreeIpaResponse::getStatusString).returns(APP_VERSION, DescribeFreeIpaResponse::getAppVersion).returns(VARIANT, DescribeFreeIpaResponse::getVariant).returns(USERSYNC_STATUS_RESPONSE, DescribeFreeIpaResponse::getUserSyncStatus).returns(tunnel, DescribeFreeIpaResponse::getTunnel);
    assertThat(freeIpaServerResponse).returns(Set.of(SERVER_IP), FreeIpaServerResponse::getServerIp).returns(FREEIPA_HOST, FreeIpaServerResponse::getFreeIpaHost).returns(GATEWAY_PORT, FreeIpaServerResponse::getFreeIpaPort);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) FreeIpaServerResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerResponse) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Stack(com.sequenceiq.freeipa.entity.Stack) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) NullSource(org.junit.jupiter.params.provider.NullSource)

Example 32 with DescribeFreeIpaResponse

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

the class FreeIpaV1ControllerTest method describeAllInternal.

@Test
void describeAllInternal() {
    List<DescribeFreeIpaResponse> response = List.of(new DescribeFreeIpaResponse());
    when(describeService.describeAll(anyString(), anyString())).thenReturn(response);
    assertEquals(response, underTest.describeAllInternal(ENVIRONMENT_CRN, ACCOUNT_ID));
    verify(describeService).describeAll(ENVIRONMENT_CRN, ACCOUNT_ID);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 33 with DescribeFreeIpaResponse

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

the class FreeIpaV1ControllerTest method describeAll.

@Test
void describeAll() {
    List<DescribeFreeIpaResponse> response = List.of(new DescribeFreeIpaResponse());
    when(describeService.describeAll(anyString(), anyString())).thenReturn(response);
    assertEquals(response, underTest.describeAll(ENVIRONMENT_CRN));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 34 with DescribeFreeIpaResponse

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

the class FreeipaService method checkFreeipaRunning.

@Retryable(value = CloudbreakServiceException.class, maxAttempts = 3, backoff = @Backoff(delay = 200))
public boolean checkFreeipaRunning(String envCrn) {
    DescribeFreeIpaResponse freeipa = freeipaClientService.getByEnvironmentCrn(envCrn);
    if (freeipa == null || freeipa.getAvailabilityStatus() == null || freeipa.getAvailabilityStatus() == AvailabilityStatus.UNKNOWN) {
        String message = "Freeipa availability cannot be determined currently.";
        LOGGER.info(message);
        throw new CloudbreakServiceException(message);
    } else if (!freeipa.getAvailabilityStatus().isAvailable()) {
        String message = "Freeipa should be in Available state but currently is " + freeipa.getStatus().name();
        LOGGER.info(message);
        return false;
    } else {
        return true;
    }
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Retryable(org.springframework.retry.annotation.Retryable)

Example 35 with DescribeFreeIpaResponse

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

the class FreeIpaPollerServiceTest method testStopAttachedFreeipaInstancesWhenFreeipaStopped.

@Test
void testStopAttachedFreeipaInstancesWhenFreeipaStopped() {
    DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse();
    freeipaResponse.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    freeipaResponse.setStatus(Status.STOPPED);
    when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse));
    when(freeipaPollerProvider.stopPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish);
    underTest.stopAttachedFreeipaInstances(ENV_ID, ENV_CRN);
    verify(freeIpaService, times(0)).stopFreeIpa(ENV_CRN);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) AttemptResults(com.dyngr.core.AttemptResults) Test(org.junit.jupiter.api.Test)

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