Search in sources :

Example 1 with CmParcelSyncOperationResult

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult in project cloudbreak by hortonworks.

the class CmSyncerServiceTest method testSyncFromCmToDbWhenCmServerRunningThenSyncIsExecuted.

@Test
void testSyncFromCmToDbWhenCmServerRunningThenSyncIsExecuted() {
    when(cmServerQueryService.isCmServerRunning(stack)).thenReturn(true);
    Set<Image> candidateImages = Set.of(mock(Image.class));
    CmRepoSyncOperationResult cmRepoSyncOperationResult = mock(CmRepoSyncOperationResult.class);
    CmParcelSyncOperationResult cmParcelSyncOperationResult = mock(CmParcelSyncOperationResult.class);
    when(stack.getId()).thenReturn(STACK_ID);
    when(cmInstalledComponentFinderService.findCmRepoComponent(stack, candidateImages)).thenReturn(cmRepoSyncOperationResult);
    when(cmInstalledComponentFinderService.findParcelComponents(stack, candidateImages)).thenReturn(cmParcelSyncOperationResult);
    when(cmSyncOperationSummaryService.evaluate(any())).thenReturn(CmSyncOperationStatus.builder().withSuccess("myMessage").build());
    CmSyncOperationSummary cmSyncOperationSummary = underTest.syncFromCmToDb(stack, candidateImages);
    CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummary.getSyncOperationStatus();
    assertTrue(cmSyncOperationStatus.hasSucceeded());
    assertEquals("myMessage", cmSyncOperationStatus.getMessage());
    verify(cmInstalledComponentFinderService).findCmRepoComponent(stack, candidateImages);
    verify(cmInstalledComponentFinderService).findParcelComponents(stack, candidateImages);
    verify(stack).getId();
    verify(mixedPackageVersionService).validatePackageVersions(eq(STACK_ID), any(), eq(candidateImages));
    verifyEvaluateCmSyncResults(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
    verifyPersistComponentsToDb(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
}
Also used : CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmParcelSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CmRepoSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmRepoSyncOperationResult) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary) Test(org.junit.jupiter.api.Test)

Example 2 with CmParcelSyncOperationResult

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult in project cloudbreak by hortonworks.

the class CmInstalledComponentFinderServiceTest method testFindParcelComponents.

@Test
void testFindParcelComponents() {
    Set<Image> candidateImages = Set.of(mock(Image.class));
    Set<ClouderaManagerProduct> candidateCmProduct = Set.of(new ClouderaManagerProduct());
    Set<ParcelInfo> queriedParcelInfo = Set.of(new ParcelInfo("", ""));
    Set<ClouderaManagerProduct> chosenClouderaManagerProducts = Set.of(new ClouderaManagerProduct());
    when(stack.isDatalake()).thenReturn(true);
    when(imageReaderService.getParcels(candidateImages, true)).thenReturn(candidateCmProduct);
    when(cmInfoRetriever.queryActiveParcels(eq(stack))).thenReturn(queriedParcelInfo);
    when(cmProductChooserService.chooseParcelProduct(queriedParcelInfo, candidateCmProduct)).thenReturn(chosenClouderaManagerProducts);
    CmParcelSyncOperationResult cmParcelSyncOperationResult = underTest.findParcelComponents(stack, candidateImages);
    assertThat(cmParcelSyncOperationResult.getActiveParcels(), hasSize(1));
    verify(imageReaderService).getParcels(candidateImages, true);
    verify(cmInfoRetriever).queryActiveParcels(stack);
    verify(cmProductChooserService).chooseParcelProduct(queriedParcelInfo, candidateCmProduct);
}
Also used : CmParcelSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 3 with CmParcelSyncOperationResult

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult 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)

Example 4 with CmParcelSyncOperationResult

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult 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)

Example 5 with CmParcelSyncOperationResult

use of com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult in project cloudbreak by hortonworks.

the class CmSyncResultMergerServiceTest method testMergeWhenNoResultsAtAll.

@Test
void testMergeWhenNoResultsAtAll() {
    Stack stack = new Stack();
    CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult(null, null);
    CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(Set.of(), Set.of());
    CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
    Set<Component> mergedComponents = underTest.merge(stack, cmSyncOperationResult);
    assertThat(mergedComponents, emptyCollectionOf(Component.class));
    verify(componentConverter, never()).fromClouderaManagerRepo(any(), any());
    verify(componentConverter).fromClouderaManagerProductList(Set.of(), stack);
}
Also used : 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

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