Search in sources :

Example 21 with ImageFilterParams

use of com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams 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 22 with ImageFilterParams

use of com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams 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 23 with ImageFilterParams

use of com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams 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)

Example 24 with ImageFilterParams

use of com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams in project cloudbreak by hortonworks.

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheVersionsAreEqualAndTheBuildNumberIsLower.

@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheVersionsAreEqualAndTheBuildNumberIsLower() {
    String componentVersion = "7.2.1";
    Image currentImage = createImage(componentVersion, "2002");
    Image candidateImage = createImage(componentVersion, "2001");
    ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
    when(componentBuildNumberComparator.compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey())).thenReturn(false);
    when(supportedRuntimes.isSupported("7.2.1")).thenReturn(true);
    boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
    assertFalse(actual);
    verify(componentBuildNumberComparator).compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey());
    verifyNoInteractions(upgradeMatrixService, componentVersionComparator);
}
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 ImageFilterParams

use of com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams in project cloudbreak by hortonworks.

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnTrueWhenTheVersionsAreEqualAndTheBuildNumberIsGreater.

@Test
public void testPermitStackUpgradeShouldReturnTrueWhenTheVersionsAreEqualAndTheBuildNumberIsGreater() {
    String componentVersion = "7.2.1";
    Image currentImage = createImage(componentVersion, "2000");
    Image candidateImage = createImage(componentVersion, "2001");
    ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
    when(componentBuildNumberComparator.compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey())).thenReturn(true);
    when(supportedRuntimes.isSupported("7.2.1")).thenReturn(true);
    boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
    assertTrue(actual);
    verify(componentBuildNumberComparator).compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey());
    verifyNoInteractions(upgradeMatrixService, componentVersionComparator);
}
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

ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)26 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)20 Test (org.junit.Test)18 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)15 InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)11 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)8 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)8 Test (org.junit.jupiter.api.Test)7 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)2 Result (com.sequenceiq.cloudbreak.service.cluster.model.Result)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)1