Search in sources :

Example 6 with CmSyncOperationResult

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);
}
Also used : CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary)

Example 7 with 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());
}
Also used : CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult)

Example 8 with CmSyncOperationResult

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);
}
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 9 with CmSyncOperationResult

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

Example 10 with CmSyncOperationResult

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);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) CmParcelSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult) CmSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult) CmRepoSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmRepoSyncOperationResult) Component(com.sequenceiq.cloudbreak.domain.stack.Component) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

CmSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult)13 Test (org.junit.jupiter.api.Test)10 Component (com.sequenceiq.cloudbreak.domain.stack.Component)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)4 CmParcelSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult)4 CmRepoSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmRepoSyncOperationResult)4 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 CmSyncOperationStatus (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus)1 CmSyncOperationSummary (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary)1