use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class CmInstalledComponentFinderServiceTest method testFindCmRepoComponent.
@Test
void testFindCmRepoComponent() {
Set<Image> candidateImages = Set.of(mock(Image.class));
Set<ClouderaManagerRepo> candidateCmRepos = Set.of();
ClouderaManagerRepo chosenClouderaManagerRepo = new ClouderaManagerRepo().withVersion(CM_VERSION);
when(imageReaderService.getCmRepos(eq(candidateImages))).thenReturn(candidateCmRepos);
when(cmInfoRetriever.queryCmVersion(eq(stack))).thenReturn(Optional.of(CM_VERSION));
when(cmProductChooserService.chooseCmRepo(eq(Optional.of(CM_VERSION)), eq(candidateCmRepos))).thenReturn(Optional.of(chosenClouderaManagerRepo));
CmRepoSyncOperationResult cmRepoSyncOperationResult = underTest.findCmRepoComponent(stack, candidateImages);
assertTrue(cmRepoSyncOperationResult.getFoundClouderaManagerRepo().isPresent());
verify(imageReaderService).getCmRepos(eq(candidateImages));
verify(cmInfoRetriever).queryCmVersion(eq(stack));
verify(cmProductChooserService).chooseCmRepo(eq(Optional.of(CM_VERSION)), eq(candidateCmRepos));
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class ImageReaderServiceTest method testGetCandidateCmReposWhenMultipleImagesThenGetCmRepoIsCalledEachTime.
@Test
void testGetCandidateCmReposWhenMultipleImagesThenGetCmRepoIsCalledEachTime() throws CloudbreakImageCatalogException {
Set<Image> candidateImages = Set.of(mock(Image.class), mock(Image.class));
when(imageService.getClouderaManagerRepo(any(Image.class))).thenReturn(Optional.of(new ClouderaManagerRepo())).thenReturn(Optional.of(new ClouderaManagerRepo()));
Set<ClouderaManagerRepo> candidateRepos = underTest.getCmRepos(candidateImages);
assertThat(candidateRepos, hasSize(2));
verify(imageService, times(2)).getClouderaManagerRepo(any(Image.class));
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo 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);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method testMerge.
@Test
void testMerge() {
Stack stack = new Stack();
ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult("", clouderaManagerRepo);
when(componentConverter.fromClouderaManagerRepo(clouderaManagerRepo, stack)).thenReturn(componentWithName(CM_REPO_COMPONENT_NAME));
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(2));
assertThat(mergedComponents, containsInAnyOrder(hasProperty("name", is(CM_REPO_COMPONENT_NAME)), hasProperty("name", is(CM_PARCEL_COMPONENT_NAME))));
verify(componentConverter).fromClouderaManagerRepo(clouderaManagerRepo, stack);
verify(componentConverter).fromClouderaManagerProductList(clouderaManagerProducts, stack);
}
use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method decorateBuilderWithProductDetails.
private void decorateBuilderWithProductDetails(StackV4Request source, TemplatePreparationObject.Builder builder) {
// base image
if (source.getCluster() != null && source.getCluster().getCm() != null && source.getCluster().getCm().getRepository() != null) {
ClouderaManagerV4Request cm = source.getCluster().getCm();
ClouderaManagerRepositoryV4Request repository = cm.getRepository();
ClouderaManagerRepo cmRepo = new ClouderaManagerRepo().withBaseUrl(repository.getBaseUrl()).withGpgKeyUrl(repository.getGpgKeyUrl()).withVersion(repository.getVersion());
List<ClouderaManagerProduct> products = null != cm.getProducts() ? cm.getProducts().stream().map(StackV4RequestToTemplatePreparationObjectConverter::convertProduct).collect(toList()) : new ArrayList<>();
builder.withProductDetails(cmRepo, products);
// prewarm image
}
// TODO: implement else {} branch for prewarm images
}
Aggregations