use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions 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.upgrade.model.FreeIpaUpgradeOptions 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());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.
the class UpgradeService method createFreeIpaUpgradeOptions.
private FreeIpaUpgradeOptions createFreeIpaUpgradeOptions(List<ImageInfoResponse> targetImages, ImageInfoResponse currentImage) {
FreeIpaUpgradeOptions freeIpaUpgradeOptions = new FreeIpaUpgradeOptions();
freeIpaUpgradeOptions.setImages(targetImages);
freeIpaUpgradeOptions.setCurrentImage(currentImage);
return freeIpaUpgradeOptions;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.
the class UpgradeCcmService method checkPrerequsities.
public void checkPrerequsities(Long stackId) {
Stack stack = stackService.getStackById(stackId);
ImageEntity stackImage = imageService.getByStackId(stackId);
FreeIpaUpgradeOptions freeIpaUpgradeOptions = upgradeService.collectUpgradeOptions(stack.getAccountId(), stack.getEnvironmentCrn(), Objects.requireNonNullElse(stackImage.getImageCatalogName(), stackImage.getImageCatalogUrl()));
if (!freeIpaUpgradeOptions.getImages().isEmpty()) {
throw new CloudbreakServiceException("FreeIPA is not on the latest available image. Please upgrade that first. CCM upgrade is not possible yet.");
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions in project cloudbreak by hortonworks.
the class UpgradeServiceTest method testUpgradeOptionsWithCatalogSet.
@Test
public void testUpgradeOptionsWithCatalogSet() {
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, "cat");
assertEquals(currentImage, result.getCurrentImage());
assertEquals(1, result.getImages().size());
assertEquals(targetImage, result.getImages().get(0));
ImageSettingsRequest imageSettingsRequest = captor.getValue();
assertEquals("cat", imageSettingsRequest.getCatalog());
}
Aggregations