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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations