Search in sources :

Example 21 with Component

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

the class CmSyncResultMergerServiceTest method componentWithName.

private Component componentWithName(String name) {
    Component component = new Component();
    component.setName(name);
    return component;
}
Also used : Component(com.sequenceiq.cloudbreak.domain.stack.Component)

Example 22 with Component

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

the class StackImageServiceTest method testRemoveTargetImageShouldRemoveImageWhenTheImagePresent.

@Test
void testRemoveTargetImageShouldRemoveImageWhenTheImagePresent() {
    Component targetImageComponent = createImageComponent();
    when(componentConfigProviderService.getComponent(stack.getId(), ComponentType.IMAGE, TARGET_IMAGE)).thenReturn(targetImageComponent);
    victim.removeImageByComponentName(stack.getId(), TARGET_IMAGE);
    verify(componentConfigProviderService).getComponent(stack.getId(), ComponentType.IMAGE, TARGET_IMAGE);
    verify(componentConfigProviderService).deleteComponents(Collections.singleton(targetImageComponent));
}
Also used : Component(com.sequenceiq.cloudbreak.domain.stack.Component) Test(org.junit.jupiter.api.Test)

Example 23 with Component

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

the class ClusterUpgradeTargetImageServiceTest method testSaveImageShouldSaveTheTargetImageWhenIsNotPresent.

@Test
void testSaveImageShouldSaveTheTargetImageWhenIsNotPresent() throws IOException, CloudbreakImageNotFoundException {
    Image targetModelImage = createTargetModelImage(IMAGE_ID, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
    when(stackImageService.findImageComponentByName(STACK_ID, TARGET_IMAGE)).thenReturn(Optional.empty());
    when(stackService.getById(STACK_ID)).thenReturn(stack);
    when(stackImageService.getCurrentImage(stack)).thenReturn(currentImage);
    when(stackImageService.getImageModelFromStatedImage(stack, currentImage, targetStatedImage)).thenReturn(targetModelImage);
    underTest.saveImage(STACK_ID, targetStatedImage);
    verify(stackImageService).findImageComponentByName(STACK_ID, TARGET_IMAGE);
    verify(stackService).getById(STACK_ID);
    ArgumentCaptor<Component> targetComponentCaptor = ArgumentCaptor.forClass(Component.class);
    verify(componentConfigProviderService).store(targetComponentCaptor.capture());
    Component targetComponent = targetComponentCaptor.getValue();
    assertEquals(ComponentType.IMAGE, targetComponent.getComponentType());
    assertEquals(TARGET_IMAGE, targetComponent.getName());
    assertEquals(stack, targetComponent.getStack());
    assertEquals(targetModelImage.getImageId(), targetComponent.getAttributes().get(Image.class).getImageId());
}
Also used : Image(com.sequenceiq.cloudbreak.cloud.model.Image) Component(com.sequenceiq.cloudbreak.domain.stack.Component) Test(org.junit.jupiter.api.Test)

Example 24 with Component

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

the class ClusterUpgradeTargetImageServiceTest method testSaveImageShouldRemoveTheOldTargetImageAndSaveTheTargetImageWhenAnOldImageIsPresentAndTheImageCatalogNameIsNotTheSame.

@Test
void testSaveImageShouldRemoveTheOldTargetImageAndSaveTheTargetImageWhenAnOldImageIsPresentAndTheImageCatalogNameIsNotTheSame() throws IOException, CloudbreakImageNotFoundException {
    StatedImage targetImage = ImageTestUtil.getImageFromCatalog(true, IMAGE_ID, STACK_VERSION, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
    Image targetModelImage = createTargetModelImage(IMAGE_ID, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
    Image oldTargetImage = createTargetModelImage(IMAGE_ID, "old-image-catalog-url", IMAGE_CATALOG_NAME);
    Optional<Component> existingTargetImageComponent = createExistingTargetImageComponent(oldTargetImage);
    when(imageProvider.convertJsonToImage(existingTargetImageComponent.get().getAttributes())).thenReturn(oldTargetImage);
    when(stackImageService.findImageComponentByName(STACK_ID, TARGET_IMAGE)).thenReturn(existingTargetImageComponent);
    when(stackService.getById(STACK_ID)).thenReturn(stack);
    when(stackImageService.getCurrentImage(stack)).thenReturn(currentImage);
    when(stackImageService.getImageModelFromStatedImage(stack, currentImage, targetImage)).thenReturn(targetModelImage);
    underTest.saveImage(STACK_ID, targetImage);
    verify(stackImageService).getCurrentImage(stack);
    verify(stackImageService).findImageComponentByName(STACK_ID, TARGET_IMAGE);
    verify(stackService).getById(STACK_ID);
    ArgumentCaptor<Component> targetComponentCaptor = ArgumentCaptor.forClass(Component.class);
    verify(componentConfigProviderService).store(targetComponentCaptor.capture());
    Component targetComponent = targetComponentCaptor.getValue();
    assertEquals(ComponentType.IMAGE, targetComponent.getComponentType());
    assertEquals(TARGET_IMAGE, targetComponent.getName());
    assertEquals(stack, targetComponent.getStack());
    assertEquals(targetModelImage.getImageId(), targetComponent.getAttributes().get(Image.class).getImageId());
}
Also used : Image(com.sequenceiq.cloudbreak.cloud.model.Image) Component(com.sequenceiq.cloudbreak.domain.stack.Component) Test(org.junit.jupiter.api.Test)

Example 25 with Component

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

the class ImageService method addStackRepo.

private void addStackRepo(Stack stack, Set<Component> components, com.sequenceiq.cloudbreak.cloud.model.catalog.Image catalogBasedImage) throws CloudbreakImageCatalogException {
    if (catalogBasedImage.getStackDetails() != null) {
        ImageStackDetails stackDetails = catalogBasedImage.getStackDetails();
        StackType stackType = determineStackType(stackDetails);
        Component stackRepoComponent = getStackComponent(stack, stackDetails, stackType, catalogBasedImage.getOsType());
        components.add(stackRepoComponent);
    }
}
Also used : StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ImageStackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.ImageStackDetails) Component(com.sequenceiq.cloudbreak.domain.stack.Component)

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