use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class CmSyncerService method syncInternal.
private CmSyncOperationSummary syncInternal(Stack stack, Set<Image> candidateImages) {
CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmInstalledComponentFinderService.findCmRepoComponent(stack, candidateImages), cmInstalledComponentFinderService.findParcelComponents(stack, candidateImages));
LOGGER.debug("Synced CM versions and found components: {}", cmSyncOperationResult);
componentPersistingService.persistComponentsToDb(stack, cmSyncOperationResult);
CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummaryService.evaluate(cmSyncOperationResult);
mixedPackageVersionService.validatePackageVersions(stack.getId(), cmSyncOperationResult, candidateImages);
LOGGER.info("CM sync was executed, summary: {}", cmSyncOperationStatus);
return new CmSyncOperationSummary(cmSyncOperationStatus, cmSyncOperationResult);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class CmSyncerServiceTest method verifyEvaluateCmSyncResults.
private void verifyEvaluateCmSyncResults(CmRepoSyncOperationResult cmRepoSyncOperationResult, CmParcelSyncOperationResult cmParcelSyncOperationResult) {
ArgumentCaptor<CmSyncOperationResult> argumentCaptor = ArgumentCaptor.forClass(CmSyncOperationResult.class);
verify(cmSyncOperationSummaryService).evaluate(argumentCaptor.capture());
CmSyncOperationResult cmSyncOperationResult = argumentCaptor.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 testValidatePackageVersionsShouldExamineTargetImageWhenTheTargetImageIsPresent.
@Test
void testValidatePackageVersionsShouldExamineTargetImageWhenTheTargetImageIsPresent() 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);
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);
com.sequenceiq.cloudbreak.cloud.model.catalog.Image targetImage = createCatalogImage(CM_VERSION);
when(clusterUpgradeTargetImageService.findTargetImage(STACK_ID)).thenReturn(Optional.of(createModelImage(TARGET_IMAGE_ID)));
when(imageCatalogService.getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, TARGET_IMAGE_ID)).thenReturn(createStatedImage(targetImage));
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);
verify(clusterUpgradeTargetImageService).findTargetImage(STACK_ID);
verify(imageCatalogService).getImage(IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME, TARGET_IMAGE_ID);
verify(targetImageAwareMixedPackageVersionService).examinePackageVersionsWithTargetImage(STACK_ID, targetImage, CM_VERSION, activeParcels);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class MixedPackageVersionServiceTest method testValidatePackageVersionsShouldNotCallAnyExaminationWhenTheActiveCmVersionIsNotAvailable.
@Test
void testValidatePackageVersionsShouldNotCallAnyExaminationWhenTheActiveCmVersionIsNotAvailable() {
CmSyncOperationResult cmSyncOperationResult = createCmSyncResult(null, Collections.emptyMap());
Set<com.sequenceiq.cloudbreak.cloud.model.catalog.Image> candidateImages = Set.of(createCatalogImage("image1", CM_VERSION));
underTest.validatePackageVersions(STACK_ID, cmSyncOperationResult, candidateImages);
verifyNoInteractions(clusterUpgradeTargetImageService);
verifyNoInteractions(clouderaManagerProductTransformer);
verifyNoInteractions(imageService);
verifyNoInteractions(imageCatalogService);
verifyNoInteractions(mixedPackageVersionComparator);
verifyNoInteractions(targetImageAwareMixedPackageVersionService);
verifyNoInteractions(candidateImageAwareMixedPackageVersionService);
}
use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method testMergeWhenNoClouderaManagerProductFound.
@Test
void testMergeWhenNoClouderaManagerProductFound() {
Stack stack = new Stack();
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult("", clouderaManagerRepo);
when(componentConverter.fromClouderaManagerRepo(clouderaManagerRepo, stack)).thenReturn(componentWithName(CM_REPO_COMPONENT_NAME));
CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(Set.of(), Set.of());
CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
Set<Component> mergedComponents = underTest.merge(stack, cmSyncOperationResult);
assertThat(mergedComponents, hasSize(1));
assertThat(mergedComponents, contains(hasProperty("name", is(CM_REPO_COMPONENT_NAME))));
verify(componentConverter).fromClouderaManagerRepo(clouderaManagerRepo, stack);
verify(componentConverter).fromClouderaManagerProductList(Set.of(), stack);
}
Aggregations