Search in sources :

Example 1 with ImageFilterParams

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

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrixButUpgradeMatrixCheckSkippedInImageFilterParams.

@Test
public void testPermitStackUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrixButUpgradeMatrixCheckSkippedInImageFilterParams() {
    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(), StackType.WORKLOAD, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
    when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(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, never()).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 2 with ImageFilterParams

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

the class UpgradePermissionProviderTest method testPermitCmUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrix.

@Test
public void testPermitCmUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrix() {
    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);
    boolean actual = underTest.permitCmUpgrade(imageFilterParams, candidateImage);
    assertTrue(actual);
    verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
    verify(upgradeMatrixService, never()).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 3 with ImageFilterParams

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

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheCandidateCmVersionIsLower.

@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheCandidateCmVersionIsLower() {
    String currentVersion = "7.2.1";
    String targetVersion = "7.1.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(false);
    when(supportedRuntimes.isSupported("7.1.2")).thenReturn(true);
    boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
    assertFalse(actual);
    verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
    verifyNoInteractions(componentBuildNumberComparator, upgradeMatrixService);
}
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 4 with ImageFilterParams

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

the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheCmBuildNumberIsNotAvailable.

@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheCmBuildNumberIsNotAvailable() {
    Image currentImage = createImage("7.2.1", "2002");
    Image candidateImage = createImage("7.2.1", null);
    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 5 with ImageFilterParams

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

the class CmAndStackVersionUpgradeImageFilterTest method testFilterShouldReturnTrueWhenNotLockedAndCMAndStackPermitcheckIsTrue.

@Test
public void testFilterShouldReturnTrueWhenNotLockedAndCMAndStackPermitcheckIsTrue() {
    ImageFilterParams imageFilterParams = createImageFilterParams(false);
    when(upgradePermissionProvider.permitStackUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.TRUE);
    when(upgradePermissionProvider.permitCmUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.TRUE);
    ImageFilterResult actual = underTest.filter(new ImageFilterResult(List.of(candidateImage)), imageFilterParams);
    assertFalse(actual.getImages().isEmpty());
    assertTrue(actual.getReason().isEmpty());
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Test(org.junit.jupiter.api.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