Search in sources :

Example 21 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmProductChooserServiceTest method testChooseParcelProductWhenMatchingNameButDifferentVersionThenEmptyResult.

@Test
void testChooseParcelProductWhenMatchingNameButDifferentVersionThenEmptyResult() {
    Set<ParcelInfo> activeParcels = Set.of(new ParcelInfo(PARCEL_NAME_1, PARCEL_VERSION_2));
    Set<ClouderaManagerProduct> candidateProducts = Set.of(new ClouderaManagerProduct().withName(PARCEL_NAME_1).withVersion(PARCEL_VERSION_1));
    Set<ClouderaManagerProduct> foundProducts = underTest.chooseParcelProduct(activeParcels, candidateProducts);
    assertThat(foundProducts, hasSize(0));
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test)

Example 22 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ImageReaderServiceTest method testGetPreWarmParcelNamesFromImageShouldReturnTheParcelNames.

@Test
public void testGetPreWarmParcelNamesFromImageShouldReturnTheParcelNames() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    Image currentImage = Mockito.mock(Image.class);
    Set<ClouderaManagerProduct> products = Set.of(new ClouderaManagerProduct().withName(PARCEL_NAME));
    when(imageService.getCurrentImage(STACK_ID)).thenReturn(StatedImage.statedImage(currentImage, null, null));
    when(clouderaManagerProductTransformer.transform(currentImage, true, true)).thenReturn(products);
    Set<String> actual = underTest.getParcelNames(STACK_ID);
    assertTrue(actual.contains(PARCEL_NAME));
    verify(imageService).getCurrentImage(STACK_ID);
    verify(clouderaManagerProductTransformer).transform(currentImage, true, true);
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 23 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ImageReaderServiceTest method testGetCandidateParcelsWhenMultipleImagesThenProductTransformerIsCalledEachTime.

@Test
void testGetCandidateParcelsWhenMultipleImagesThenProductTransformerIsCalledEachTime() {
    Set<Image> candidateImages = Set.of(mock(Image.class), mock(Image.class));
    when(clouderaManagerProductTransformer.transform(any(), eq(true), eq(false))).thenReturn(Set.of(new ClouderaManagerProduct())).thenReturn(Set.of(new ClouderaManagerProduct()));
    Set<ClouderaManagerProduct> candidateProducts = underTest.getParcels(candidateImages, true);
    assertThat(candidateProducts, hasSize(2));
    verify(clouderaManagerProductTransformer, times(2)).transform(any(Image.class), eq(true), eq(false));
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 24 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct 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 25 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmSyncOperationResultEvaluatorServiceTest method testEvaluateParcelSyncWhenMoreVersionsPresentThanMatchingProductsFoundThenFailure.

@Test
void testEvaluateParcelSyncWhenMoreVersionsPresentThanMatchingProductsFoundThenFailure() {
    Set<ParcelInfo> activeParcels = Set.of(new ParcelInfo(PARCEL_1_NAME, PARCEL_1_VERSION), new ParcelInfo(PARCEL_2_NAME, PARCEL_2_VERSION));
    Set<ClouderaManagerProduct> foundCmProducts = Set.of(new ClouderaManagerProduct().withName(PARCEL_1_NAME));
    CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(activeParcels, foundCmProducts);
    CmSyncOperationStatus.Builder cmSyncOperationStatusBuilder = underTest.evaluateParcelSync(cmParcelSyncOperationResult);
    CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationStatusBuilder.build();
    assertFalse(cmSyncOperationStatus.hasSucceeded());
    assertEquals(String.format("Reading versions of active parcels failed, the version of some active parcels could not be retrieved from CM server: %s. " + "Parcel versions successfully read: %s.", Set.of(PARCEL_2_NAME), Set.of(PARCEL_1_NAME)), cmSyncOperationStatus.getMessage());
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test)

Aggregations

ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)91 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)20 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)14 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)9 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)9 HashSet (java.util.HashSet)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)7 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)6 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)6 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)6 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5