Search in sources :

Example 11 with ImageCatalog

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

the class ImageService method generateImageCatalogForStack.

public ImageCatalog generateImageCatalogForStack(Stack stack) {
    final Image image = getImageForStack(stack);
    final Images images = new Images(List.of(copyImageWithAdvertisedFlag(image)));
    return new ImageCatalog(images, null);
}
Also used : Images(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)

Example 12 with ImageCatalog

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

the class ImageServiceTest method testGenerateForStack.

@Test
void testGenerateForStack() throws NoSuchFieldException {
    ReflectionUtils.setField(ImageService.class.getDeclaredField("freeIpaVersion"), underTest, FREEIPA_VERSION);
    Stack stack = new Stack();
    stack.setRegion(DEFAULT_REGION);
    stack.setCloudPlatform(DEFAULT_PLATFORM);
    ImageEntity imageEntity = new ImageEntity();
    imageEntity.setImageId(IMAGE_UUID);
    imageEntity.setOs(DEFAULT_OS);
    imageEntity.setImageCatalogName(IMAGE_CATALOG);
    imageEntity.setImageCatalogUrl(IMAGE_CATALOG_URL);
    when(imageRepository.getByStack(stack)).thenReturn(imageEntity);
    when(imageProviderFactory.getImageProvider(IMAGE_CATALOG)).thenReturn(imageProvider);
    Image image = new Image(123L, "now", "desc", DEFAULT_OS, IMAGE_UUID, Map.of(), "os", Map.of(), true);
    ImageWrapper imageWrapper = new ImageWrapper(image, IMAGE_CATALOG_URL, IMAGE_CATALOG);
    when(imageProvider.getImage(any(), any(), any())).thenReturn(Optional.of(imageWrapper));
    ImageCatalog result = underTest.generateImageCatalogForStack(stack);
    verify(imageProvider).getImage(imageSettingsRequestCaptor.capture(), eq(DEFAULT_REGION), eq(DEFAULT_PLATFORM));
    assertThat(imageSettingsRequestCaptor.getValue()).returns(IMAGE_CATALOG, ImageSettingsBase::getCatalog).returns(IMAGE_UUID, ImageSettingsBase::getId);
    assertThat(result.getImages().getFreeipaImages()).containsExactly(image);
    assertThat(result.getVersions()).isNull();
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImageSettingsBase(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 13 with ImageCatalog

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

the class FreeIpaImageProviderTest method setup.

@BeforeEach
public void setup() throws Exception {
    ImageCatalog imageCatalog = setupImageCatalogProvider(CUSTOM_IMAGE_CATALOG_URL, CATALOG_FILE);
    imageCatalog.getImages().getFreeipaImages().get(0);
    ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "defaultOs", DEFAULT_OS, null);
    ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "defaultCatalogUrl", DEFAULT_CATALOG_URL, null);
    ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "freeIpaVersion", DEFAULT_VERSION, null);
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with ImageCatalog

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

the class ImageCatalogGeneratorServiceTest method generate.

@Test
void generate() {
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    ImageCatalog imageCatalog = new ImageCatalog(null, null);
    when(imageService.generateImageCatalogForStack(stack)).thenReturn(imageCatalog);
    GenerateImageCatalogResponse result = underTest.generate(ENVIRONMENT_CRN, ACCOUNT_ID);
    Assertions.assertThat(result.getImageCatalog()).isEqualTo(imageCatalog);
}
Also used : GenerateImageCatalogResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.imagecatalog.GenerateImageCatalogResponse) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 15 with ImageCatalog

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

the class ImageCatalogProviderTest method testImageCatalogFilterNothing.

@Test
public void testImageCatalogFilterNothing() {
    String path = getPath(IMAGE_CATALOG_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    ImageCatalog actualCatalog = underTest.getImageCatalog(IMAGE_CATALOG_JSON);
    List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
    assertEquals(IMAGE_CATALOG_OS_TYPES, actualOsTypes);
    List<String> expectedIds = List.of("61851893-8340-411d-afb7-e1b55107fb10", "71851893-8340-411d-afb7-e1b55107fb10", "81851893-8340-411d-afb7-e1b55107fb10", "91851893-8340-411d-afb7-e1b55107fb10");
    assertEquals(expectedIds, mapToUuid(actualCatalog.getImages().getFreeipaImages()));
    assertEquals(List.of("61851893-8340-411d-afb7-e1b55107fb10", "71851893-8340-411d-afb7-e1b55107fb10"), actualCatalog.getVersions().getFreeIpaVersions().get(0).getImageIds());
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Test(org.junit.Test)

Aggregations

ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)16 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)7 FreeIpaVersions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions)5 Test (org.junit.Test)5 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)3 Images (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images)2 Versions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions)2 GenerateImageCatalogResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.imagecatalog.GenerateImageCatalogResponse)2 Test (org.junit.jupiter.api.Test)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 ImageSettingsBase (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase)1 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1