use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class CmSyncImageCollectorServiceTest method testCollectImagesWhenNoImageUuidThenAllImagesCollected.
@Test
void testCollectImagesWhenNoImageUuidThenAllImagesCollected() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
ImageCatalogPlatform imageCatalogPlatform = imageCatalogPlatform(CURRENT_CLOUD_PLATFORM);
setupStack(true, true);
Set<String> candidateImageUuids = Set.of();
List<Image> allCdhImages = List.of(getImage(IMAGE_UUID_1));
when(imageService.getCurrentImageCatalogName(STACK_ID)).thenReturn(CURRENT_IMAGE_CATALOG_NAME);
when(imageCatalogService.getAllCdhImages(anyString(), anyLong(), anyString(), anySet())).thenReturn(allCdhImages);
when(platformStringTransformer.getPlatformStringForImageCatalogSet(anyObject(), anyString())).thenReturn(Set.of(imageCatalogPlatform));
Set<Image> collectedImages = underTest.collectImages(USER_CRN, stack, candidateImageUuids);
assertThat(collectedImages, hasSize(1));
assertThat(collectedImages, containsInAnyOrder(hasProperty("uuid", is(IMAGE_UUID_1))));
verify(imageService).getCurrentImageCatalogName(STACK_ID);
verify(imageCatalogService).getAllCdhImages(USER_CRN, WORKSPCE_ID, CURRENT_IMAGE_CATALOG_NAME, Set.of(imageCatalogPlatform));
verify(imageService, never()).getCurrentImage(anyLong());
verify(imageCatalogService, never()).getImageByCatalogName(anyLong(), anyString(), anyString());
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class UpgradeOptionsResponseFactoryTest method testCreateV4ResponseShouldReturnTheUpgradeOptionsFromTheGivenParameters.
@Test
public void testCreateV4ResponseShouldReturnTheUpgradeOptionsFromTheGivenParameters() throws CloudbreakImageNotFoundException {
ImageCatalogPlatform imageCatalogPlatform = imageCatalogPlatform(CLOUD_PLATFORM);
Map<String, String> packageVersions = createPackageVersions();
ImageComponentVersions expectedPackageVersions = creatExpectedPackageVersions();
Image currentImage = createImage(packageVersions);
ImageFilterResult availableImages = createAvailableImages(packageVersions);
when(platformStringTransformer.getPlatformStringForImageCatalogByRegion(anyString(), anyString())).thenReturn(imageCatalogPlatform);
when(imageService.determineImageName(CLOUD_PLATFORM, imageCatalogPlatform, REGION, currentImage)).thenReturn(IMAGE_NAME);
when(imageService.determineImageName(CLOUD_PLATFORM, imageCatalogPlatform, REGION, availableImages.getImages().get(0))).thenReturn(IMAGE_NAME);
when(componentVersionProvider.getComponentVersions(eq(packageVersions), any(), any())).thenReturn(expectedPackageVersions);
UpgradeV4Response actual = underTest.createV4Response(currentImage, availableImages, CLOUD_PLATFORM, REGION, IMAGE_CATALOG_NAME);
assertEquals(IMAGE_ID, actual.getCurrent().getImageId());
assertEquals(IMAGE_CATALOG_NAME, actual.getCurrent().getImageCatalogName());
assertEquals(IMAGE_NAME, actual.getCurrent().getImageName());
assertEquals(expectedPackageVersions, actual.getCurrent().getComponentVersions());
assertEquals(CREATION_DATE, actual.getCurrent().getCreated());
assertEquals(IMAGE_ID, actual.getUpgradeCandidates().get(0).getImageId());
assertEquals(IMAGE_CATALOG_NAME, actual.getUpgradeCandidates().get(0).getImageCatalogName());
assertEquals(IMAGE_NAME, actual.getUpgradeCandidates().get(0).getImageName());
assertEquals(expectedPackageVersions, actual.getUpgradeCandidates().get(0).getComponentVersions());
assertEquals(CREATION_DATE, actual.getUpgradeCandidates().get(0).getCreated());
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class StackImageService method getImageModelFromStatedImage.
public Image getImageModelFromStatedImage(Stack stack, Image currentImage, StatedImage targetImage) {
try {
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(stack.getCloudPlatform(), stack.getPlatformVariant());
String cloudPlatform = platform(stack.cloudPlatform()).value().toLowerCase();
String newImageName = imageService.determineImageName(cloudPlatform, platformString, stack.getRegion(), targetImage.getImage());
return new Image(newImageName, currentImage.getUserdata(), targetImage.getImage().getOs(), targetImage.getImage().getOsType(), targetImage.getImageCatalogUrl(), targetImage.getImageCatalogName(), targetImage.getImage().getUuid(), targetImage.getImage().getPackageVersions());
} catch (CloudbreakImageNotFoundException e) {
LOGGER.info("Could not find image", e);
throw new CloudbreakServiceException("Could not find image", e);
}
}
use of com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method testGetImagesWithPlatform.
@Test
public void testGetImagesWithPlatform() throws CloudbreakImageCatalogException, IOException {
setupUserProfileService();
setupImageCatalogProvider(DEFAULT_CATALOG_URL, V2_CB_CATALOG_FILE);
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setImageCatalogUrl(DEFAULT_CATALOG_URL);
ImageCatalogPlatform imageCatalogPlatform = imageCatalogPlatform("AWS");
when(platformStringTransformer.getPlatformStringForImageCatalog(any(String.class), anyBoolean())).thenReturn(imageCatalogPlatform);
when(imageCatalogRepository.findByNameAndWorkspaceId(anyString(), anyLong())).thenReturn(Optional.of(imageCatalog));
underTest.getImagesByCatalogName(ORG_ID, "catalog", null, imageCatalogPlatform, false);
verify(entitlementService, times(1)).baseImageEnabled(Objects.requireNonNull(Crn.fromString(user.getUserCrn())).getAccountId());
verify(entitlementService, never()).baseImageEnabled(user.getUserCrn());
verify(stackImageFilterService, never()).getApplicableImages(anyLong(), anyString(), anyString());
verify(stackImageFilterService, never()).getApplicableImages(anyLong(), anyString());
}
Aggregations