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));
}
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);
}
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));
}
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);
}
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());
}
Aggregations