Search in sources :

Example 16 with Component

use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake.

@Test
public void testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake() throws IOException, CloudbreakImageCatalogException {
    Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
    Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
    List<Component> productComponentList = List.of(productComponent);
    ClouderaManagerProduct cdhProduct = clouderaManagerProduct("CDH", "1.5.0");
    stack.setType(StackType.DATALAKE);
    when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
    when(clouderaManagerProductsProvider.getCdhProducts(anySet())).thenReturn(cdhProduct);
    List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
    assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
    verify(clouderaManagerProductsProvider).getCdhProducts(anySet());
    verifyNoInteractions(parcelFilterService);
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Json(com.sequenceiq.cloudbreak.common.json.Json) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Test(org.junit.Test)

Example 17 with Component

use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponents.

@Test
public void testPrewarmedClouderaManagerClusterComponents() throws IOException, CloudbreakImageCatalogException {
    Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
    Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
    List<Component> productComponentList = List.of(productComponent);
    Set<ClouderaManagerProduct> clouderaManagerProductSet = new HashSet<>();
    clouderaManagerProductSet.add(clouderaManagerProduct("CDH", "1.5.0"));
    when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
    when(parcelFilterService.filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class))).thenReturn(clouderaManagerProductSet);
    List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
    assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
    verify(parcelFilterService, times(1)).filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class));
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Json(com.sequenceiq.cloudbreak.common.json.Json) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with Component

use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.

the class ClusterCreationSetupServiceTest method init.

@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
    MockitoAnnotations.initMocks(this);
    workspace = new Workspace();
    clusterRequest = new ClusterV4Request();
    stack = new Stack();
    stack.setId(1L);
    stack.setWorkspace(workspace);
    stack.setEnvironmentCrn("env");
    stack.setName("name");
    blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    user = new User();
    Map<InstanceGroupType, String> userData = new HashMap<>();
    userData.put(InstanceGroupType.CORE, "userdata");
    Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
    Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    cluster = new Cluster();
    stack.setCluster(cluster);
    when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
    when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
    when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
    when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
    DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
    when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
    when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
    when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
    when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) RepoTestUtil.getDefaultCDHInfo(com.sequenceiq.cloudbreak.RepoTestUtil.getDefaultCDHInfo) Component(com.sequenceiq.cloudbreak.domain.stack.Component) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Example 19 with Component

use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.

the class ComponentConfigProviderServiceTest method replaceImageComponentWithNew.

@Test
public void replaceImageComponentWithNew() {
    Stack stack = new Stack();
    stack.setId(1L);
    Component original = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("asdf"), stack);
    Component modified = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("fdas"), stack);
    when(componentRepository.findComponentByStackIdComponentTypeName(eq(stack.getId()), eq(original.getComponentType()), eq(original.getName()))).thenReturn(Optional.of(original));
    componentConfigProviderService.replaceImageComponentWithNew(modified);
    ArgumentCaptor<Component> argument = ArgumentCaptor.forClass(Component.class);
    verify(componentRepository).save(argument.capture());
    assertEquals(modified.getAttributes(), argument.getValue().getAttributes());
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) Component(com.sequenceiq.cloudbreak.domain.stack.Component) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 20 with Component

use of com.sequenceiq.cloudbreak.domain.stack.Component 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)

Aggregations

Component (com.sequenceiq.cloudbreak.domain.stack.Component)37 Json (com.sequenceiq.cloudbreak.common.json.Json)16 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)14 Image (com.sequenceiq.cloudbreak.cloud.model.Image)12 Test (org.junit.jupiter.api.Test)11 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)6 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)6 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)6 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)5 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)5 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)5 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)4 StackMatrixV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response)4 ImageBasedDefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo)4 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 CmSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationResult)4 DefaultCDHInfo (com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo)3 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)3 CmParcelSyncOperationResult (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult)3