Search in sources :

Example 16 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsRuntimeValid.

@Test
public void testFilterUpgradeOptionsRuntimeValid() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setRuntime(MATCHING_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));
    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 17 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class UpgradeConverterTest method testConvertResult.

@Test
public void testConvertResult() {
    UpgradeV4Response source = new UpgradeV4Response();
    source.setUpgradeCandidates(List.of());
    source.setCurrent(new ImageInfoV4Response());
    source.setFlowIdentifier(new FlowIdentifier(FlowType.FLOW, "asdg"));
    source.setReason("fdas");
    DistroXUpgradeV1Response result = underTest.convert(source);
    assertEquals(source.getCurrent(), result.getCurrent());
    assertEquals(source.getFlowIdentifier(), result.getFlowIdentifier());
    assertEquals(source.getReason(), result.getReason());
    assertEquals(source.getUpgradeCandidates(), result.getUpgradeCandidates());
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnNoMaintenanceUpgradeCandidatesAreAvaiable.

@Test
@DisplayName("this test simulates that a Data Hub runtime upgrade entitlement is disabled" + " and all the image candidates are filtered for maintenance upgrade so empty response should be returned")
public void testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnNoMaintenanceUpgradeCandidatesAreAvaiable() {
    Cluster datalakeCluster = TestUtil.cluster();
    datalakeCluster.setRangerRazEnabled(false);
    UpgradeV4Request request = new UpgradeV4Request();
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response current = createImageResponse(1L, "7.1.0");
    ImageInfoV4Response image1 = createImageResponse(2L, "7.2.0");
    ImageInfoV4Response image2 = createImageResponse(8L, "7.3.0");
    ImageInfoV4Response image3 = createImageResponse(6L, "7.4.0");
    response.setUpgradeCandidates(List.of(image1, image2, image3));
    response.setCurrent(current);
    when(clusterService.getClusterByStackResourceCrn(any())).thenReturn(datalakeCluster);
    when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
    when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
    when(entitlementService.datahubRuntimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(false);
    UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
    String expectedMessage = "No image is available for maintenance upgrade, CDP version: 7.1.0";
    assertEquals(0, result.getUpgradeCandidates().size());
    assertEquals(expectedMessage, result.getReason());
}
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) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 19 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class DistroXUpgradeAvailabilityServiceTest method testReturnLatestOnlyForDryRun.

@Test
public void testReturnLatestOnlyForDryRun() {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setDryRun(Boolean.TRUE);
    UpgradeV4Response response = new UpgradeV4Response();
    ImageInfoV4Response image1 = new ImageInfoV4Response();
    image1.setCreated(1L);
    ImageInfoV4Response image2 = new ImageInfoV4Response();
    image2.setCreated(8L);
    ImageInfoV4Response image3 = new ImageInfoV4Response();
    image3.setCreated(5L);
    response.setUpgradeCandidates(List.of(image1, image2, image3));
    when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
    when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
    UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
    assertEquals(1, result.getUpgradeCandidates().size());
    assertEquals(8L, result.getUpgradeCandidates().get(0).getCreated());
}
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.jupiter.api.Test)

Example 20 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class DistroXUpgradeAvailabilityServiceTest method testReturnAllCandidates.

@Test
public void testReturnAllCandidates() {
    UpgradeV4Request request = new UpgradeV4Request();
    UpgradeV4Response response = new UpgradeV4Response();
    response.setUpgradeCandidates(List.of(mock(ImageInfoV4Response.class), mock(ImageInfoV4Response.class)));
    when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
    when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
    UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
    assertEquals(response.getUpgradeCandidates(), result.getUpgradeCandidates());
}
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) Test(org.junit.jupiter.api.Test)

Aggregations

UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)69 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)43 Test (org.junit.jupiter.api.Test)41 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)40 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)21 Test (org.junit.Test)16 DisplayName (org.junit.jupiter.api.DisplayName)16 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)13 ImageComponentVersions (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)10 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)9 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)9 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)9 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)9 List (java.util.List)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 InjectMocks (org.mockito.InjectMocks)8 Mock (org.mockito.Mock)8