Search in sources :

Example 1 with ImageFilterResult

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

the class CloudPlatformBasedUpgradeImageFilterTest method testFilterShouldReturnErrorMessageWithoutImages.

@Test
public void testFilterShouldReturnErrorMessageWithoutImages() {
    List<Image> images = List.of(createImage(IMAGE_ID_1, AZURE.name()), createImage(IMAGE_ID_2, AZURE.name()));
    ImageFilterResult actual = underTest.filter(createImageFilterResult(images), imageFilterParams);
    assertTrue(actual.getImages().isEmpty());
    assertEquals("There are no eligible images to upgrade for AWS cloud platform.", actual.getReason());
}
Also used : ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 2 with ImageFilterResult

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

the class CloudPlatformBasedUpgradeImageFilterTest method testFilterShouldReturnOnlyOneImage.

@Test
public void testFilterShouldReturnOnlyOneImage() {
    Image image1 = createImage(IMAGE_ID_1, AWS.name());
    Image image2 = createImage(IMAGE_ID_2, AZURE.name());
    List<Image> images = List.of(image1, image2);
    ImageFilterResult actual = underTest.filter(createImageFilterResult(images), imageFilterParams);
    assertTrue(actual.getImages().contains(image1));
    assertFalse(actual.getImages().contains(image2));
    assertTrue(actual.getReason().isEmpty());
}
Also used : ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 3 with ImageFilterResult

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

Example 4 with ImageFilterResult

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

the class CmAndStackVersionUpgradeImageFilterTest method testFilterShouldReturnErrorMessageWhenNotLockedAndCMPermitcheckIsFalse.

@Test
public void testFilterShouldReturnErrorMessageWhenNotLockedAndCMPermitcheckIsFalse() {
    ImageFilterParams imageFilterParams = createImageFilterParams(false);
    lenient().when(upgradePermissionProvider.permitStackUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.TRUE);
    when(upgradePermissionProvider.permitCmUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.FALSE);
    ImageFilterResult actual = underTest.filter(new ImageFilterResult(List.of(candidateImage)), imageFilterParams);
    assertNotLockedCommon(actual);
}
Also used : ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Test(org.junit.jupiter.api.Test)

Example 5 with ImageFilterResult

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

the class CmAndStackVersionUpgradeImageFilterTest method testFilterShouldReturnFalseWhenNotLockedAndCMAndStackPermitcheckIsFalse.

@Test
public void testFilterShouldReturnFalseWhenNotLockedAndCMAndStackPermitcheckIsFalse() {
    ImageFilterParams imageFilterParams = createImageFilterParams(false);
    lenient().when(upgradePermissionProvider.permitStackUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.FALSE);
    when(upgradePermissionProvider.permitCmUpgrade(imageFilterParams, candidateImage)).thenReturn(Boolean.FALSE);
    ImageFilterResult actual = underTest.filter(new ImageFilterResult(List.of(candidateImage)), imageFilterParams);
    assertNotLockedCommon(actual);
}
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

ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)59 Test (org.junit.jupiter.api.Test)47 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)44 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)15 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)10 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)9 Test (org.junit.Test)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 PackageLocationFilter (com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter)4 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 Result (com.sequenceiq.cloudbreak.service.cluster.model.Result)2 ImageComponentVersions (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions)1 Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)1 ImageFilter (com.sequenceiq.cloudbreak.service.image.ImageFilter)1