Search in sources :

Example 41 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testImageCatalogFilterNullImages.

@Test
public void testImageCatalogFilterNullImages() throws CloudbreakImageCatalogException {
    String path = getPath(CB_IMAGE_CATALOG_FILTER_NULL_IMAGES_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    CloudbreakImageCatalogV3 imageCatalogV2 = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_FILTER_NULL_IMAGES_JSON).getImageCatalog();
    assertEquals(1L, imageCatalogV2.getImages().getBaseImages().get(0).getImageSetsByProvider().values().size());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.jupiter.api.Test)

Example 42 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testImageCatalogFilterNothing.

@Test
public void testImageCatalogFilterNothing() throws CloudbreakImageCatalogException, IOException {
    String path = getPath(CB_IMAGE_CATALOG_RC_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    CloudbreakImageCatalogV3 actualCatalog = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_RC_JSON).getImageCatalog();
    List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
    assertEquals(RC_IMAGE_CATALOG_OS_TYPES, actualOsTypes);
    ObjectMapper objectMapper = new ObjectMapper();
    CloudbreakImageCatalogV3 expectedCatalog = objectMapper.readValue(Paths.get(path, CB_IMAGE_CATALOG_RC_JSON).toFile(), CloudbreakImageCatalogV3.class);
    assertEquals(mapToUuid(expectedCatalog.getImages().getBaseImages()), mapToUuid(actualCatalog.getImages().getBaseImages()));
    assertEquals(mapToUuid(expectedCatalog.getImages().getCdhImages()), mapToUuid(actualCatalog.getImages().getCdhImages()));
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 43 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testHttpImageCatalogValid.

@Test
public void testHttpImageCatalogValid() throws CloudbreakImageCatalogException, IOException {
    String path = getPath(CB_IMAGE_CATALOG_VALID_JSON);
    String catalogUrl = "http";
    when(restClientFactory.getOrCreateDefault()).thenReturn(clientMock);
    when(clientMock.target(catalogUrl)).thenReturn(webTargetMock);
    when(webTargetMock.request()).thenReturn(builderMock);
    when(builderMock.get()).thenReturn(responseMock);
    when(responseMock.getStatusInfo()).thenReturn(statusTypeMock);
    when(statusTypeMock.getFamily()).thenReturn(Response.Status.Family.SUCCESSFUL);
    when(responseMock.readEntity(String.class)).thenReturn(Files.readString(Paths.get(path, CB_IMAGE_CATALOG_V2_JSON)));
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    CloudbreakImageCatalogV3 actualCatalog = underTest.getImageCatalogWrapper(catalogUrl).getImageCatalog();
    CloudbreakImageCatalogV3 expectedCatalog = objectMapper.readValue(Paths.get(path, CB_IMAGE_CATALOG_V2_JSON).toFile(), CloudbreakImageCatalogV3.class);
    assertEquals(mapToUuid(expectedCatalog.getImages().getBaseImages()), mapToUuid(actualCatalog.getImages().getBaseImages()));
    assertEquals(mapToUuid(expectedCatalog.getImages().getCdhImages()), mapToUuid(actualCatalog.getImages().getCdhImages()));
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.jupiter.api.Test)

Example 44 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testFreeipaImageCatalogFilterToRedhat7.

@Test
public void testFreeipaImageCatalogFilterToRedhat7() throws CloudbreakImageCatalogException, IOException {
    String path = getPath(FREEIPA_IMAGE_CATALOG_V3_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_REDHAT7_FILTER);
    CloudbreakImageCatalogV3 actualCatalog = underTest.getImageCatalogWrapper(FREEIPA_IMAGE_CATALOG_V3_JSON).getImageCatalog();
    assertEquals(mapToUuid(Collections.emptyList()), mapToUuid(actualCatalog.getImages().getBaseImages()));
    assertEquals(mapToUuid(Collections.emptyList()), mapToUuid(actualCatalog.getImages().getCdhImages()));
    assertEquals(1, actualCatalog.getImages().getFreeIpaImages().size());
    assertEquals("81851893-8340-411d-afb7-e1b55107fb10", actualCatalog.getImages().getFreeIpaImages().get(0).getUuid());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.jupiter.api.Test)

Example 45 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testImageCatalogWithoutBaseImages.

@Test
public void testImageCatalogWithoutBaseImages() throws CloudbreakImageCatalogException {
    String path = getPath(CB_IMAGE_CATALOG_WITHOUT_BASE_IMAGES);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    CloudbreakImageCatalogV3 imageCatalogV2 = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_WITHOUT_BASE_IMAGES).getImageCatalog();
    assertNotNull(imageCatalogV2.getImages().getBaseImages());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.jupiter.api.Test)

Aggregations

CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)48 Test (org.junit.jupiter.api.Test)21 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)17 Test (org.junit.Test)14 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)10 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)8 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)8 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)6 CloudbreakVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion)5 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)5 StatedImages (com.sequenceiq.cloudbreak.service.image.StatedImages)5 Image (com.sequenceiq.cloudbreak.cloud.model.Image)4 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)4 List (java.util.List)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Versions (com.sequenceiq.cloudbreak.cloud.model.catalog.Versions)3 ImageFilter (com.sequenceiq.cloudbreak.service.image.ImageFilter)3 ImageCatalogWrapper (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogWrapper)3