Search in sources :

Example 6 with Image

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

the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDate.

@Test
public void testFindTargetImagesCurrentImageMissingDate() {
    Stack stack = new Stack();
    stack.setCloudPlatform("AWS");
    stack.setRegion("reg");
    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")));
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    Image currentImageFromCatalog = createImage("2021-08-01");
    ImageWrapper currentImageWrapperFromCatalog = new ImageWrapper(currentImageFromCatalog, "asdf", "Asdf");
    when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenReturn(currentImageWrapperFromCatalog);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setId("222-333");
    currentImage.setCatalog("cat");
    currentImage.setCatalogName("catName");
    currentImage.setOs("zOs");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertEquals(1, targetImages.size());
    ImageInfoResponse imageInfoResponse = targetImages.get(0);
    assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
    assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
    assertEquals(image.getDate(), imageInfoResponse.getDate());
    assertEquals(image.getUuid(), imageInfoResponse.getId());
    assertEquals(image.getOs(), imageInfoResponse.getOs());
    ImageSettingsRequest settingsRequest = captor.getValue();
    assertEquals(currentImage.getCatalog(), settingsRequest.getCatalog());
    assertEquals(currentImage.getId(), settingsRequest.getId());
    assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
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 7 with Image

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

the class FreeIpaImageProviderTest method testGetImagesGivenIdInputFound.

@Test
public void testGetImagesGivenIdInputFound() {
    ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, null, null);
    List<ImageWrapper> images = underTest.getImages(is, DEFAULT_REGION, DEFAULT_PLATFORM);
    assertEquals(1, images.size());
    ImageWrapper imageWrapper = images.get(0);
    assertEquals(DEFAULT_CATALOG_URL, imageWrapper.getCatalogUrl());
    assertNull(imageWrapper.getCatalogName());
    Image image = imageWrapper.getImage();
    assertEquals(DEFAULT_OS, image.getOs());
    assertEquals(LATEST_DATE, image.getDate());
    assertEquals(IMAGE_UUID, image.getUuid());
}
Also used : 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) Test(org.junit.jupiter.api.Test)

Example 8 with Image

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

the class FreeIpaImageProviderTest method testGetImageGivenUuidInputFoundWithNotDefaultOs.

@Test
public void testGetImageGivenUuidInputFoundWithNotDefaultOs() {
    ImageSettingsRequest is = setupImageSettingsRequest(NON_DEFAULT_OS_IMAGE_UUID, null, null);
    Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
    assertEquals(NON_DEFAULT_OS_IMAGE_UUID, image.getUuid());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Test(org.junit.jupiter.api.Test)

Example 9 with Image

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

the class FreeIpaImageProviderTest method testGetImageGivenAllInputNonExistentOS.

@Test
public void testGetImageGivenAllInputNonExistentOS() {
    ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, CUSTOM_IMAGE_CATALOG_URL, NON_EXISTING_OS);
    Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
    assertEquals(DEFAULT_OS, image.getOs());
    assertEquals(LATEST_DATE, image.getDate());
    assertEquals(IMAGE_UUID, image.getUuid());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Test(org.junit.jupiter.api.Test)

Example 10 with Image

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

the class FreeIpaImageProviderTest method testGetImageGivenIdInputFound.

@Test
public void testGetImageGivenIdInputFound() {
    ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, null, null);
    Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
    assertEquals(DEFAULT_OS, image.getOs());
    assertEquals(LATEST_DATE, image.getDate());
    assertEquals(IMAGE_UUID, image.getUuid());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) 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