Search in sources :

Example 1 with ParcelInfo

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);
}
Also used : CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Test(org.junit.jupiter.api.Test)

Example 2 with ParcelInfo

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);
}
Also used : CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.jupiter.api.Test)

Example 3 with ParcelInfo

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);
}
Also used : CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.jupiter.api.Test)

Example 4 with ParcelInfo

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"));
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 5 with ParcelInfo

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);
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Aggregations

ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)23 Test (org.junit.jupiter.api.Test)22 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)9 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 CmSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult)4 LinkedHashSet (java.util.LinkedHashSet)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)2 CM (com.sequenceiq.cloudbreak.cloud.model.catalog.ImagePackageVersion.CM)1 CmParcelSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult)1 VersionComparator (com.sequenceiq.cloudbreak.util.VersionComparator)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Service (org.springframework.stereotype.Service)1 CollectionUtils (org.springframework.util.CollectionUtils)1