use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesNoNewerImage.
@Test
public void testFindTargetImagesNoNewerImage() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-07-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesImageWithSameId.
@Test
public void testFindTargetImagesImageWithSameId() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("1234-456");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDate.
@Test
public void testFindTargetImagesCurrentImageMissingDate() {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("reg");
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
Image currentImageFromCatalog = createImage("2021-08-01");
ImageWrapper currentImageWrapperFromCatalog = new ImageWrapper(currentImageFromCatalog, "asdf", "Asdf");
when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenReturn(currentImageWrapperFromCatalog);
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setId("222-333");
currentImage.setCatalog("cat");
currentImage.setCatalogName("catName");
currentImage.setOs("zOs");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertEquals(1, targetImages.size());
ImageInfoResponse imageInfoResponse = targetImages.get(0);
assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
assertEquals(image.getDate(), imageInfoResponse.getDate());
assertEquals(image.getUuid(), imageInfoResponse.getId());
assertEquals(image.getOs(), imageInfoResponse.getOs());
ImageSettingsRequest settingsRequest = captor.getValue();
assertEquals(currentImage.getCatalog(), settingsRequest.getCatalog());
assertEquals(currentImage.getId(), settingsRequest.getId());
assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeServiceTest method testUpgradeOptionsCatalogNameFromCurrentImage.
@Test
public void testUpgradeOptionsCatalogNameFromCurrentImage() {
Stack stack = new Stack();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setCatalogName("catName");
when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
ImageInfoResponse targetImage = new ImageInfoResponse();
when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, null);
assertEquals(currentImage, result.getCurrentImage());
assertEquals(1, result.getImages().size());
assertEquals(targetImage, result.getImages().get(0));
ImageSettingsRequest imageSettingsRequest = captor.getValue();
assertEquals("catName", imageSettingsRequest.getCatalog());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeServiceTest method testUpgradeOptionsCatalogFromCurrentImage.
@Test
public void testUpgradeOptionsCatalogFromCurrentImage() {
Stack stack = new Stack();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setCatalog("cat2");
currentImage.setCatalogName("catName");
when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
ImageInfoResponse targetImage = new ImageInfoResponse();
when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, null);
assertEquals(currentImage, result.getCurrentImage());
assertEquals(1, result.getImages().size());
assertEquals(targetImage, result.getImages().get(0));
ImageSettingsRequest imageSettingsRequest = captor.getValue();
assertEquals("cat2", imageSettingsRequest.getCatalog());
}
Aggregations