Search in sources :

Example 21 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class ImageFilterParamsFactoryTest method testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataLake.

@Test
public void testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataLake() {
    Image image = mock(Image.class);
    Stack stack = createStack(StackType.DATALAKE);
    Set<ClusterComponent> clusterComponents = createCdhClusterComponent();
    String cdhName = com.sequenceiq.cloudbreak.cloud.model.component.StackType.CDH.name();
    String cdhVersion = "7.2.0";
    when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform(CLOUD_PLATFORM));
    when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(clusterComponents);
    when(clouderaManagerProductsProvider.findCdhProduct(clusterComponents)).thenReturn(Optional.of(createCMProduct(cdhName, cdhVersion)));
    ImageFilterParams actual = underTest.create(image, true, stack, new InternalUpgradeSettings(false, true, true));
    assertEquals(image, actual.getCurrentImage());
    assertTrue(actual.isLockComponents());
    assertEquals(cdhVersion, actual.getStackRelatedParcels().get(cdhName));
    assertEquals(StackType.DATALAKE, actual.getStackType());
    assertEquals(blueprint, actual.getBlueprint());
    assertEquals(STACK_ID, actual.getStackId());
    assertEquals(CLOUD_PLATFORM, actual.getCloudPlatform().nameToUpperCase());
    verify(parcelService).getParcelComponentsByBlueprint(stack);
    verify(clouderaManagerProductsProvider).findCdhProduct(clusterComponents);
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 22 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class ImageFilterParamsFactoryTest method testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataHub.

@Test
public void testCreateShouldReturnsANewImageFilterParamsInstanceWhenTheStackTypeIsDataHub() {
    Image image = mock(Image.class);
    Stack stack = createStack(StackType.WORKLOAD);
    Set<ClusterComponent> cdhClusterComponent = createCdhClusterComponent();
    String sparkName = "Spark";
    String sparkVersion = "123";
    ClouderaManagerProduct spark = createCMProduct(sparkName, sparkVersion);
    String nifiName = "Nifi";
    String nifiVersion = "456";
    ClouderaManagerProduct nifi = createCMProduct(nifiName, nifiVersion);
    when(platformStringTransformer.getPlatformStringForImageCatalog(anyString(), anyString())).thenReturn(imageCatalogPlatform(CLOUD_PLATFORM));
    when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(cdhClusterComponent);
    when(clouderaManagerProductsProvider.getProducts(cdhClusterComponent)).thenReturn(Set.of(spark, nifi));
    ImageFilterParams actual = underTest.create(image, true, stack, new InternalUpgradeSettings(true, true, true));
    assertEquals(image, actual.getCurrentImage());
    assertTrue(actual.isLockComponents());
    assertTrue(actual.isSkipValidations());
    assertEquals(sparkVersion, actual.getStackRelatedParcels().get(sparkName));
    assertEquals(nifiVersion, actual.getStackRelatedParcels().get(nifiName));
    assertEquals(StackType.WORKLOAD, actual.getStackType());
    assertEquals(blueprint, actual.getBlueprint());
    assertEquals(STACK_ID, actual.getStackId());
    assertEquals(CLOUD_PLATFORM, actual.getCloudPlatform().nameToUpperCase());
    verify(parcelService).getParcelComponentsByBlueprint(stack);
    verify(clouderaManagerProductsProvider).getProducts(cdhClusterComponent);
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 23 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class ImageFilterParamsFactoryTest method testCreateShouldThrowExceptionThenThereIsNoCdhComponentAvailable.

@Test(expected = NotFoundException.class)
public void testCreateShouldThrowExceptionThenThereIsNoCdhComponentAvailable() {
    Image image = mock(Image.class);
    Stack stack = createStack(StackType.DATALAKE);
    ClusterComponent clusterComponent = new ClusterComponent();
    clusterComponent.setName("CM");
    when(parcelService.getParcelComponentsByBlueprint(stack)).thenReturn(Collections.singleton(clusterComponent));
    underTest.create(image, true, stack, new InternalUpgradeSettings(false, true, true));
    verify(parcelService).getParcelComponentsByBlueprint(stack);
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 24 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheUpgradeNotPermittedByTheUpgradeMatrix.

@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheUpgradeNotPermittedByTheUpgradeMatrix() {
    String currentVersion = "7.2.1";
    String targetVersion = "7.2.2";
    Image currentImage = createImage(currentVersion, "2002");
    Image candidateImage = createImage(targetVersion, "2001");
    ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
    when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
    when(upgradeMatrixService.permitByUpgradeMatrix(currentVersion, targetVersion)).thenReturn(false);
    when(supportedRuntimes.isSupported("7.2.2")).thenReturn(true);
    boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
    assertFalse(actual);
    verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
    verify(upgradeMatrixService).permitByUpgradeMatrix(currentVersion, targetVersion);
    verifyNoInteractions(componentBuildNumberComparator);
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.Test)

Example 25 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnTrueWhenTheCandidateCmVersionIsGreater.

@Test
public void testPermitStackUpgradeShouldReturnTrueWhenTheCandidateCmVersionIsGreater() {
    String currentVersion = "7.2.1";
    String targetVersion = "7.2.2";
    Image currentImage = createImage(currentVersion, "2002");
    Image candidateImage = createImage(targetVersion, "2001");
    ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
    when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
    when(upgradeMatrixService.permitByUpgradeMatrix(currentVersion, targetVersion)).thenReturn(true);
    when(supportedRuntimes.isSupported("7.2.2")).thenReturn(true);
    boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
    assertTrue(actual);
    verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
    verify(upgradeMatrixService).permitByUpgradeMatrix(currentVersion, targetVersion);
    verifyNoInteractions(componentBuildNumberComparator);
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.Test)

Aggregations

InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)25 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)13 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)12 Test (org.junit.Test)12 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)11 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 DistroXUpgradeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)7 Test (org.junit.jupiter.api.Test)7 DistroXUpgradeV1Response (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)2 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1