Search in sources :

Example 46 with UpgradeV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsDefaultCase.

@Test
public void testFilterUpgradeOptionsDefaultCase() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setDryRun(true);
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response imageInfo = new ImageInfoV4Response();
    imageInfo.setImageId(IMAGE_ID);
    imageInfo.setCreated(1);
    imageInfo.setComponentVersions(createExpectedPackageVersions());
    ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
    lastImageInfo.setImageId(IMAGE_ID_LAST);
    lastImageInfo.setCreated(2);
    lastImageInfo.setComponentVersions(createExpectedPackageVersions());
    response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
    underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
    assertEquals(2, response.getUpgradeCandidates().size());
    assertEquals(2, response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).collect(Collectors.toSet()).size());
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) Test(org.junit.Test)

Example 47 with UpgradeV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsLockComponents.

@Test
public void testFilterUpgradeOptionsLockComponents() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setLockComponents(true);
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response imageInfo = new ImageInfoV4Response();
    imageInfo.setImageId(IMAGE_ID);
    imageInfo.setCreated(1);
    imageInfo.setComponentVersions(createExpectedPackageVersions());
    ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
    lastImageInfo.setImageId(IMAGE_ID_LAST);
    lastImageInfo.setCreated(2);
    lastImageInfo.setComponentVersions(createExpectedPackageVersions());
    response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
    underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
    assertEquals(2, response.getUpgradeCandidates().size());
    assertTrue(response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).anyMatch(id -> id.equals(IMAGE_ID_LAST)));
    assertTrue(response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).anyMatch(id -> id.equals(IMAGE_ID)));
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) ImageComponentVersions(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) HostGroupName(com.sequenceiq.cloudbreak.service.cluster.model.HostGroupName) Map(java.util.Map) UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) ImageProvider(com.sequenceiq.cloudbreak.service.image.ImageProvider) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) ImageCatalogProvider(com.sequenceiq.cloudbreak.service.image.ImageCatalogProvider) Set(java.util.Set) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) Collectors(java.util.stream.Collectors) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) List(java.util.List) ClusterUpgradeImageFilter(com.sequenceiq.cloudbreak.service.upgrade.image.ClusterUpgradeImageFilter) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ClusterRepairService(com.sequenceiq.cloudbreak.service.cluster.ClusterRepairService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Result(com.sequenceiq.cloudbreak.service.cluster.model.Result) InjectMocks(org.mockito.InjectMocks) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Mockito.verify(org.mockito.Mockito.verify) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Mockito(org.mockito.Mockito) User(com.sequenceiq.cloudbreak.workspace.model.User) Assert.assertNull(org.junit.Assert.assertNull) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Assertions(org.junit.jupiter.api.Assertions) ImageCatalogService(com.sequenceiq.cloudbreak.service.image.ImageCatalogService) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) Test(org.junit.Test)

Example 48 with UpgradeV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsImageIdInvalid.

@Test
public void testFilterUpgradeOptionsImageIdInvalid() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setImageId(ANOTHER_IMAGE_ID);
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response imageInfo = new ImageInfoV4Response();
    imageInfo.setImageId(IMAGE_ID);
    imageInfo.setCreated(1);
    imageInfo.setComponentVersions(createExpectedPackageVersions());
    ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
    lastImageInfo.setImageId(IMAGE_ID_LAST);
    lastImageInfo.setCreated(2);
    lastImageInfo.setComponentVersions(createExpectedPackageVersions());
    response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
    Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true));
    Assert.assertEquals("The given image (another-image-id) is not eligible for the cluster upgrade. " + "Please choose an id from the following image(s): image-id-first,image-id-last", e.getMessage());
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.Test)

Example 49 with UpgradeV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsRuntimeInvalid.

@Test
public void testFilterUpgradeOptionsRuntimeInvalid() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setRuntime(ANOTHER_TARGET_RUNTIME);
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response imageInfo = new ImageInfoV4Response();
    imageInfo.setImageId(IMAGE_ID);
    imageInfo.setCreated(1);
    imageInfo.setComponentVersions(createExpectedPackageVersions());
    ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
    lastImageInfo.setImageId(IMAGE_ID_LAST);
    lastImageInfo.setCreated(2);
    lastImageInfo.setComponentVersions(createExpectedPackageVersions());
    response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
    Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true));
    Assert.assertEquals("There is no image eligible for the cluster upgrade with runtime: 7.2.0. " + "Please choose a runtime from the following: 7.0.2", e.getMessage());
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.Test)

Example 50 with UpgradeV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.

the class DistroXUpgradeImageSelectorTest method testSelectedImageByIdNotInCandidates.

@Test
public void testSelectedImageByIdNotInCandidates() {
    List<ImageInfoV4Response> candidates = List.of(createImageResponse("A", 1L, "5"), createImageResponse("B", 6L, "3"), createImageResponse("C", 3L, "1"));
    UpgradeV4Request request = new UpgradeV4Request();
    request.setImageId("D");
    assertThrows(BadRequestException.class, () -> underTest.determineImageId(request, candidates));
}
Also used : UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) Test(org.junit.jupiter.api.Test)

Aggregations

UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)54 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)44 Test (org.junit.jupiter.api.Test)42 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)35 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)14 InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)10 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)9 DisplayName (org.junit.jupiter.api.DisplayName)9 ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)7 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)7 ImageChangeDto (com.sequenceiq.cloudbreak.service.image.ImageChangeDto)7 DistroXUpgradeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)7 Test (org.junit.Test)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)6 ImageComponentVersions (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions)6 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)6 BlueprintUpgradeOption (com.sequenceiq.cloudbreak.domain.BlueprintUpgradeOption)6 List (java.util.List)6