Search in sources :

Example 61 with ClouderaManagerRepo

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));
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CmRepoSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmRepoSyncOperationResult) Test(org.junit.jupiter.api.Test)

Example 62 with ClouderaManagerRepo

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));
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 63 with ClouderaManagerRepo

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);
}
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 64 with ClouderaManagerRepo

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);
}
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) 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 65 with ClouderaManagerRepo

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
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)

Aggregations

ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)96 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)40 Test (org.junit.jupiter.api.Test)38 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)17 ApiClient (com.cloudera.api.swagger.client.ApiClient)15 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)15 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)15 Test (org.junit.Test)15 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)14 DisplayName (org.junit.jupiter.api.DisplayName)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 BigDecimal (java.math.BigDecimal)9 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8