use of com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo in project cloudbreak by hortonworks.
the class MixedPackageVersionServiceTest method testValidatePackageVersionsShouldNotSendNotificationWhenThePackageVersionsAreValidAndEqualsWithTheCurrentImage.
@Test
void testValidatePackageVersionsShouldNotSendNotificationWhenThePackageVersionsAreValidAndEqualsWithTheCurrentImage() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Map<String, String> parcels = Map.of(CDH_KEY, CDH_VERSION, "SPARK", "3.1.5");
CmSyncOperationResult cmSyncOperationResult = createCmSyncResult(CM_VERSION, parcels);
com.sequenceiq.cloudbreak.cloud.model.catalog.Image currentImage = createCatalogImage(CM_VERSION);
when(imageService.getImage(STACK_ID)).thenReturn(createModelImage(CURRENT_IMAGE_ID));
when(imageCatalogService.getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID)).thenReturn(createStatedImage(currentImage));
when(clouderaManagerProductTransformer.transformToMap(currentImage, true, true)).thenReturn(parcels);
Set<ParcelInfo> activeParcels = cmSyncOperationResult.getCmParcelSyncOperationResult().getActiveParcels();
when(mixedPackageVersionComparator.areAllComponentVersionsMatchingWithImage(CM_VERSION, parcels, CM_VERSION, activeParcels)).thenReturn(true);
underTest.validatePackageVersions(STACK_ID, cmSyncOperationResult, Collections.emptySet());
verify(imageService).getImage(STACK_ID);
verify(imageCatalogService).getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID);
verify(clouderaManagerProductTransformer).transformToMap(currentImage, true, true);
verify(mixedPackageVersionComparator).areAllComponentVersionsMatchingWithImage(CM_VERSION, parcels, CM_VERSION, activeParcels);
verifyNoInteractions(clusterUpgradeTargetImageService);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo in project cloudbreak by hortonworks.
the class MixedPackageVersionServiceTest method testValidatePackageVersionsShouldExamineCandidateImagesWhenTheCurrentImageIsNotFound.
@Test
void testValidatePackageVersionsShouldExamineCandidateImagesWhenTheCurrentImageIsNotFound() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Map<String, String> parcels = Map.of(CDH_KEY, CDH_VERSION, "SPARK", "3.1.5");
CmSyncOperationResult cmSyncOperationResult = createCmSyncResult(CM_VERSION, parcels);
Set<ParcelInfo> activeParcels = cmSyncOperationResult.getCmParcelSyncOperationResult().getActiveParcels();
Set<com.sequenceiq.cloudbreak.cloud.model.catalog.Image> candidateImages = Set.of(createCatalogImage("image1", CM_VERSION));
when(imageService.getImage(STACK_ID)).thenReturn(createModelImage(CURRENT_IMAGE_ID));
when(imageCatalogService.getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID)).thenReturn(null);
when(imageCatalogService.getCloudbreakDefaultImageCatalog()).thenReturn(createImageCatalog());
underTest.validatePackageVersions(STACK_ID, cmSyncOperationResult, candidateImages);
verify(imageService).getImage(STACK_ID);
verify(imageCatalogService).getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID);
verify(imageCatalogService).getCloudbreakDefaultImageCatalog();
verify(candidateImageAwareMixedPackageVersionService).examinePackageVersionsWithAllCandidateImages(STACK_ID, candidateImages, CM_VERSION, activeParcels, IMAGE_CATALOG_URL);
verifyNoInteractions(clusterUpgradeTargetImageService);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo in project cloudbreak by hortonworks.
the class MixedPackageVersionServiceTest method testValidatePackageVersionsShouldExamineCandidateImagesWhenTheTargetImageIsNotPresent.
@Test
void testValidatePackageVersionsShouldExamineCandidateImagesWhenTheTargetImageIsNotPresent() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Map<String, String> parcels = Map.of(CDH_KEY, CDH_VERSION, "SPARK", "3.1.5");
CmSyncOperationResult cmSyncOperationResult = createCmSyncResult(CM_VERSION, parcels);
Set<ParcelInfo> activeParcels = cmSyncOperationResult.getCmParcelSyncOperationResult().getActiveParcels();
com.sequenceiq.cloudbreak.cloud.model.catalog.Image currentImage = createCatalogImage(CM_VERSION);
Set<com.sequenceiq.cloudbreak.cloud.model.catalog.Image> candidateImages = Set.of(createCatalogImage("image1", CM_VERSION));
when(imageService.getImage(STACK_ID)).thenReturn(createModelImage(CURRENT_IMAGE_ID));
when(imageCatalogService.getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID)).thenReturn(createStatedImage(currentImage));
when(clouderaManagerProductTransformer.transformToMap(currentImage, true, true)).thenReturn(parcels);
when(mixedPackageVersionComparator.areAllComponentVersionsMatchingWithImage(CM_VERSION, parcels, CM_VERSION, activeParcels)).thenReturn(false);
when(clusterUpgradeTargetImageService.findTargetImage(STACK_ID)).thenReturn(Optional.empty());
underTest.validatePackageVersions(STACK_ID, cmSyncOperationResult, candidateImages);
verify(imageService).getImage(STACK_ID);
verify(imageCatalogService).getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, CURRENT_IMAGE_ID);
verify(clouderaManagerProductTransformer).transformToMap(currentImage, true, true);
verify(mixedPackageVersionComparator).areAllComponentVersionsMatchingWithImage(CM_VERSION, parcels, CM_VERSION, activeParcels);
verify(clusterUpgradeTargetImageService).findTargetImage(STACK_ID);
verify(candidateImageAwareMixedPackageVersionService).examinePackageVersionsWithAllCandidateImages(STACK_ID, candidateImages, CM_VERSION, activeParcels, IMAGE_CATALOG_URL);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo in project cloudbreak by hortonworks.
the class TargetImageAwareMixedPackageVersionServiceTest method testExaminePackageVersionsWithTargetImageShouldSendNotificationWhenTheClouderaManagerVersionIsHigherThanTheTarget.
@Test
void testExaminePackageVersionsWithTargetImageShouldSendNotificationWhenTheClouderaManagerVersionIsHigherThanTheTarget() {
Map<String, String> activeProducts = Map.of(CDH_KEY, V_7_2_2);
Set<ParcelInfo> activeParcels = createParcelInfo(activeProducts);
Image targetImage = createTargetImage();
Map<String, String> targetProducts = Map.of(CDH_KEY, V_7_2_2);
String activeCmVersion = "7.4.0";
Map<String, String> newerComponents = Map.of(CM.getDisplayName(), activeCmVersion);
when(clouderaManagerProductTransformer.transformToMap(targetImage, true, true)).thenReturn(targetProducts);
when(mixedPackageVersionComparator.areAllComponentVersionsMatchingWithImage(CM_VERSION, targetProducts, activeCmVersion, activeParcels)).thenReturn(false);
when(mixedPackageVersionComparator.getComponentsWithNewerVersionThanTheTarget(targetProducts, CM_VERSION, activeParcels, activeCmVersion)).thenReturn(newerComponents);
when(mixedPackageMessageProvider.createActiveParcelsMessage(activeParcels)).thenReturn("CDH 7.2.2");
when(mixedPackageMessageProvider.createMessageFromMap(newerComponents)).thenReturn("Cloudera Manager 7.4.0");
when(mixedPackageMessageProvider.createMessageFromMap(targetProducts)).thenReturn("Cloudera Manager 7.2.2");
when(mixedPackageVersionComparator.filterTargetPackageVersionsByNewerPackageVersions(targetProducts, CM_VERSION, newerComponents)).thenReturn(targetProducts);
underTest.examinePackageVersionsWithTargetImage(STACK_ID, targetImage, activeCmVersion, activeParcels);
verify(clouderaManagerProductTransformer).transformToMap(targetImage, true, true);
verify(mixedPackageVersionComparator).areAllComponentVersionsMatchingWithImage(CM_VERSION, targetProducts, activeCmVersion, activeParcels);
verify(mixedPackageVersionComparator).getComponentsWithNewerVersionThanTheTarget(targetProducts, CM_VERSION, activeParcels, activeCmVersion);
verify(mixedPackageMessageProvider).createActiveParcelsMessage(activeParcels);
verify(mixedPackageMessageProvider).createMessageFromMap(activeProducts);
verify(mixedPackageMessageProvider).createMessageFromMap(targetProducts);
verify(mixedPackageVersionComparator).filterTargetPackageVersionsByNewerPackageVersions(targetProducts, CM_VERSION, newerComponents);
verify(eventService).fireCloudbreakEvent(STACK_ID, UPDATE_IN_PROGRESS.name(), STACK_CM_MIXED_PACKAGE_VERSIONS_NEWER_FAILED, List.of(activeCmVersion, "CDH 7.2.2", "Cloudera Manager 7.4.0", "Cloudera Manager 7.2.2"));
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo in project cloudbreak by hortonworks.
the class TargetImageAwareMixedPackageVersionServiceTest method testExaminePackageVersionsWithTargetImageShouldNotSendNotificationWhenThePackageVersionsAreValidAndEqualsWithTheTargetImage.
@Test
void testExaminePackageVersionsWithTargetImageShouldNotSendNotificationWhenThePackageVersionsAreValidAndEqualsWithTheTargetImage() {
Set<ParcelInfo> activeParcels = createParcelInfo(Map.of(CDH_KEY, V_7_2_2));
Image targetImage = createTargetImage();
Map<String, String> targetProducts = Map.of(CDH_KEY, V_7_2_2);
when(clouderaManagerProductTransformer.transformToMap(targetImage, true, true)).thenReturn(targetProducts);
when(mixedPackageVersionComparator.areAllComponentVersionsMatchingWithImage(CM_VERSION, targetProducts, CM_VERSION, activeParcels)).thenReturn(true);
underTest.examinePackageVersionsWithTargetImage(STACK_ID, targetImage, CM_VERSION, activeParcels);
verify(clouderaManagerProductTransformer).transformToMap(targetImage, true, true);
verify(mixedPackageVersionComparator).areAllComponentVersionsMatchingWithImage(CM_VERSION, targetProducts, CM_VERSION, activeParcels);
verifyNoInteractions(mixedPackageMessageProvider);
verifyNoInteractions(eventService);
}
Aggregations