Search in sources :

Example 11 with CloudbreakImageCatalogV3

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

the class ImageCatalogServiceDefaultNotFoundTest method testGetDefaultImageShouldThrowNotFoundException2.

@Test(expected = CloudbreakImageNotFoundException.class)
public void testGetDefaultImageShouldThrowNotFoundException2() throws Exception {
    String catalogJson = FileReaderUtils.readFileFromClasspath(DEFAULT_CDH_IMAGE_CATALOG);
    CloudbreakImageCatalogV3 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV3.class);
    when(imageCatalogProvider.getImageCatalogV3(DEFAULT_CDH_IMAGE_CATALOG)).thenReturn(catalog);
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(catalog.getVersions().getCloudbreakVersions());
    when(imageCatalog.getImageCatalogUrl()).thenReturn(DEFAULT_CDH_IMAGE_CATALOG);
    ImageFilter imageFilter = new ImageFilter(imageCatalog, Set.of(imageCatalogPlatform("aws")), "2.6", true, Set.of("centos7", "amazonlinux2"), null);
    underTest.getImagePrewarmedDefaultPreferred(imageFilter, image -> true);
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.Test)

Example 12 with CloudbreakImageCatalogV3

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

the class ImageCatalogServiceDefaultTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
    CloudbreakImageCatalogV3 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV3.class);
    when(imageCatalogProvider.getImageCatalogV3(catalogFile)).thenReturn(catalog);
    when(preferencesService.enabledPlatforms()).thenReturn(new HashSet<>(Arrays.asList(PROVIDERS)));
    when(userProfileService.getOrCreate(user)).thenReturn(new UserProfile());
    when(userProfileService.getOrCreate(user)).thenReturn(new UserProfile());
    when(imageCatalog.getImageCatalogUrl()).thenReturn(catalogFile);
    lenient().when(user.getUserCrn()).thenReturn(TestConstants.CRN);
    when(userService.getOrCreate(any())).thenReturn(user);
    when(entitlementService.baseImageEnabled(anyString())).thenReturn(true);
    ReflectionTestUtils.setField(underTest, "imageCatalogServiceProxy", imageCatalogServiceProxy);
    ReflectionTestUtils.setField(imageCatalogServiceProxy, "advertisedImageCatalogService", advertisedImageCatalogService);
    ReflectionTestUtils.setField(imageCatalogServiceProxy, "versionBasedImageCatalogService", versionBasedImageCatalogService);
    ReflectionTestUtils.setField(versionBasedImageCatalogService, "versionBasedImageProvider", versionBasedImageProvider);
}
Also used : UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Before(org.junit.Before)

Example 13 with CloudbreakImageCatalogV3

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

the class ImageCatalogServiceTest method setupImageCatalogProvider.

private void setupImageCatalogProvider(String catalogUrl, String catalogFile) throws IOException, CloudbreakImageCatalogException {
    String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
    CloudbreakImageCatalogV3 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV3.class);
    when(imageCatalog.getImageCatalogUrl()).thenReturn(catalogUrl);
    when(imageCatalogProvider.getImageCatalogV3(catalogUrl)).thenReturn(catalog);
    when(imageCatalogProvider.getImageCatalogV3(catalogUrl, true)).thenReturn(catalog);
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(catalog.getVersions().getCloudbreakVersions());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 14 with CloudbreakImageCatalogV3

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

the class CachedImageCatalogWrapperProviderTest method testImageCatalogWithoutCdhImages.

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

Example 15 with CloudbreakImageCatalogV3

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

the class CachedImageCatalogWrapperProviderTest method testCbImageCatalogFilterToAmazonlinux.

@Test
public void testCbImageCatalogFilterToAmazonlinux() throws CloudbreakImageCatalogException, IOException {
    String path = getPath(CB_IMAGE_CATALOG_V2_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_AMAZONLINUX_FILTER);
    CloudbreakImageCatalogV3 actualCatalog = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_V2_JSON).getImageCatalog();
    List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
    assertEquals(CB_AMAZONLINUX_FILTER, actualOsTypes);
    ObjectMapper objectMapper = new ObjectMapper();
    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(Collections.emptyList()), mapToUuid(actualCatalog.getImages().getCdhImages()));
    assertEquals(1, expectedCatalog.getImages().getCdhImages().size());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) 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