Search in sources :

Example 1 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class StackToDescribeFreeIpaResponseConverter method convert.

public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, Optional<UserSyncStatus> userSyncStatus, Boolean includeAllInstances) {
    DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse();
    describeFreeIpaResponse.setName(stack.getName());
    describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn());
    describeFreeIpaResponse.setCrn(stack.getResourceCrn());
    describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform());
    describeFreeIpaResponse.setVariant(stack.getPlatformvariant());
    describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication()));
    Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i)));
    Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f)));
    describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack));
    describeFreeIpaResponse.setPlacement(convertToPlacementResponse(stack));
    describeFreeIpaResponse.setTunnel(stack.getTunnel());
    describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups(), includeAllInstances));
    describeFreeIpaResponse.setAvailabilityStatus(stackToAvailabilityStatusConverter.convert(stack));
    describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus());
    describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString());
    describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason());
    decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups());
    decorateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa);
    describeFreeIpaResponse.setAppVersion(stack.getAppVersion());
    decorateWithCloudStorageAndTelemetry(stack, describeFreeIpaResponse);
    userSyncStatus.ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u)));
    return describeFreeIpaResponse;
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)

Example 2 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class UsedImagesTest method verifyImagesAreUsed.

private <T extends CloudbreakTestDto> T verifyImagesAreUsed(TestContext testContext, T testDto) {
    testContext.given(UsedImagesTestDto.class).when(utilTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
        List<UsedImageStacksV4Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
        UsedImageStacksV4Response usedImageStacksV4Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(sdxImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("SDX image is NOT in use with ID:: %s", sdxImageUuid)));
        LOGGER.info("Used SDX image ID:: {}", usedImageStacksV4Response.getImage().getImageId());
        return usedImagesTestDto;
    }).given(FreeipaUsedImagesTestDto.class).when(freeIpaTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
        List<UsedImageStacksV1Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
        UsedImageStacksV1Response usedImageStacksV1Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(freeipaImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("FreeIpa image is NOT in use with ID:: %s", freeipaImageUuid)));
        LOGGER.info("Used FreeIpa image ID:: {}", usedImageStacksV1Response.getImage().getImageId());
        return usedImagesTestDto;
    }).validate();
    return testDto;
}
Also used : ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) FreeipaUsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaUsedImagesTestDto) UsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.util.UsedImagesTestDto) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UUID(java.util.UUID) UsedImageStacksV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImageStacksV4Response) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) UtilTestClient(com.sequenceiq.it.cloudbreak.client.UtilTestClient) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) UsedImageStacksV1Response(com.sequenceiq.freeipa.api.v1.util.model.UsedImageStacksV1Response) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) UsedImageStacksV1Response(com.sequenceiq.freeipa.api.v1.util.model.UsedImageStacksV1Response) FreeipaUsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaUsedImagesTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) List(java.util.List) UsedImageStacksV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImageStacksV4Response)

Example 3 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class FreeIpaDescribeServiceTest method describeAll.

@Test
void describeAll() {
    DescribeFreeIpaResponse describeResponse = mock(DescribeFreeIpaResponse.class);
    ImageEntity image = mock(ImageEntity.class);
    FreeIpa freeIpa = mock(FreeIpa.class);
    UserSyncStatus userSyncStatus = mock(UserSyncStatus.class);
    when(stackService.findMultipleByEnvironmentCrnAndAccountIdEvenIfTerminatedWithList(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID))).thenReturn(Collections.singletonList(stack));
    when(imageService.getByStack(any())).thenReturn(image);
    when(freeIpaService.findByStackId(any())).thenReturn(freeIpa);
    when(userSyncStatusService.findByStack(any())).thenReturn(Optional.of(userSyncStatus));
    when(stackToDescribeFreeIpaResponseConverter.convert(any(), any(), any(), any(), any())).thenReturn(describeResponse);
    when(entitlementService.isFreeIpaRebuildEnabled(eq(ACCOUNT_ID))).thenReturn(true);
    assertEquals(List.of(describeResponse), underTest.describeAll(ENVIRONMENT_CRN, ACCOUNT_ID));
}
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) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Test(org.junit.jupiter.api.Test)

Example 4 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testFindTargetImagesNoNewerImage.

@Test
public void testFindTargetImagesNoNewerImage() {
    Stack stack = new Stack();
    ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
    Image image = createImage("2021-07-01");
    ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
    when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setDate("2021-08-21");
    currentImage.setId("111-222");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertTrue(targetImages.isEmpty());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with Image

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testFindTargetImagesImageWithSameId.

@Test
public void testFindTargetImagesImageWithSameId() {
    Stack stack = new Stack();
    ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
    Image image = createImage("2021-09-01");
    ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
    when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setDate("2021-08-21");
    currentImage.setId("1234-456");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertTrue(targetImages.isEmpty());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)32 Test (org.junit.jupiter.api.Test)28 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)27 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)21 Stack (com.sequenceiq.freeipa.entity.Stack)16 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 ImageInfoResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse)9 ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)7 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)4 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 FreeIpaVersions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions)3 List (java.util.List)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 Backup (com.sequenceiq.freeipa.api.model.Backup)2 Versions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions)2 UsedImagesListV1Response (com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response)2 UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)2 ImageNotFoundException (com.sequenceiq.freeipa.service.image.ImageNotFoundException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1