Search in sources :

Example 1 with CmSyncOperationResult

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

Example 2 with CmSyncOperationResult

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

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

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

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