use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class CmSyncerServiceTest method verifyPersistComponentsToDb.
private void verifyPersistComponentsToDb(CmRepoSyncOperationResult cmRepoSyncOperationResult, CmParcelSyncOperationResult cmParcelSyncOperationResult) {
ArgumentCaptor<CmSyncOperationResult> cmSyncOperationResultArgumentCaptor = ArgumentCaptor.forClass(CmSyncOperationResult.class);
verify(componentPersistingService).persistComponentsToDb(eq(stack), cmSyncOperationResultArgumentCaptor.capture());
CmSyncOperationResult cmSyncOperationResult = cmSyncOperationResultArgumentCaptor.getValue();
assertEquals(cmRepoSyncOperationResult, cmSyncOperationResult.getCmRepoSyncOperationResult());
assertEquals(cmParcelSyncOperationResult, cmSyncOperationResult.getCmParcelSyncOperationResult());
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult 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.operationresult.CmSyncOperationResult 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.operationresult.CmSyncOperationResult 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.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method testMergeNoClouderaManagerRepo.
@Test
void testMergeNoClouderaManagerRepo() {
Stack stack = new Stack();
CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult(null, null);
Set<ClouderaManagerProduct> clouderaManagerProducts = Set.of(new ClouderaManagerProduct());
CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(Set.of(), clouderaManagerProducts);
when(componentConverter.fromClouderaManagerProductList(clouderaManagerProducts, stack)).thenReturn(Set.of(componentWithName(CM_PARCEL_COMPONENT_NAME)));
CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
Set<Component> mergedComponents = underTest.merge(stack, cmSyncOperationResult);
assertThat(mergedComponents, hasSize(1));
assertThat(mergedComponents, contains(hasProperty("name", is(CM_PARCEL_COMPONENT_NAME))));
verify(componentConverter, never()).fromClouderaManagerRepo(any(), any());
verify(componentConverter).fromClouderaManagerProductList(clouderaManagerProducts, stack);
}
Aggregations