use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityService method checkForUpgrades.
private UpgradeV4Response checkForUpgrades(Stack stack, boolean lockComponents, InternalUpgradeSettings internalUpgradeSettings) {
String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
UpgradeV4Response upgradeOptions = new UpgradeV4Response();
try {
LOGGER.info(String.format("Retrieving images for upgrading stack %s", stack.getName()));
com.sequenceiq.cloudbreak.cloud.model.Image currentImage = getImage(stack);
CloudbreakImageCatalogV3 imageCatalog = getImagesFromCatalog(stack.getWorkspace(), currentImage.getImageCatalogName(), currentImage.getImageCatalogUrl());
Image image = getCurrentImageFromCatalog(currentImage.getImageId(), imageCatalog);
ImageFilterParams imageFilterParams = createImageFilterParams(image, lockComponents, stack, internalUpgradeSettings);
ImageFilterResult imageFilterResult = filterImages(accountId, imageCatalog, imageFilterParams);
LOGGER.info(String.format("%d possible image found for stack upgrade.", imageFilterResult.getImages().size()));
upgradeOptions = createResponse(image, imageFilterResult, stack.getCloudPlatform(), stack.getRegion(), currentImage.getImageCatalogName());
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException | NotFoundException e) {
LOGGER.warn("Failed to get images", e);
upgradeOptions.setReason(String.format("Failed to retrieve image due to %s", e.getMessage()));
}
return upgradeOptions;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnOneMaintenanceUpgradeCandidateIsAvaiable.
@Test
@DisplayName("this test simulates that a Data Hub runtime upgrade entitlement is disabled" + " and there is 1 image candidate for maintenance upgrade")
public void testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnOneMaintenanceUpgradeCandidateIsAvaiable() {
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.1.0");
ImageInfoV4Response image2 = createImageResponse(8L, "7.2.0");
ImageInfoV4Response image3 = createImageResponse(6L, "7.3.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);
assertEquals(1, result.getUpgradeCandidates().size());
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 2L && "7.1.0".equals(img.getComponentVersions().getCdp())));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testLatestByRuntime.
@Test
public void testLatestByRuntime() {
UpgradeV4Request request = new UpgradeV4Request();
request.setShowAvailableImages(UpgradeShowAvailableImages.LATEST_ONLY);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response image1 = createImageResponse(2L, "A");
ImageInfoV4Response image2 = createImageResponse(8L, "A");
ImageInfoV4Response image3 = createImageResponse(6L, "A");
ImageInfoV4Response image4 = createImageResponse(1L, "B");
ImageInfoV4Response image5 = createImageResponse(4L, "B");
ImageInfoV4Response image6 = createImageResponse(3L, "B");
ImageInfoV4Response image7 = createImageResponse(9L, "C");
ImageInfoV4Response image8 = createImageResponse(8L, "C");
ImageInfoV4Response image9 = createImageResponse(6L, "C");
response.setUpgradeCandidates(List.of(image1, image2, image3, image4, image5, image6, image7, image8, image9));
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(3, result.getUpgradeCandidates().size());
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 8L && "A".equals(img.getComponentVersions().getCdp())));
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 4L && "B".equals(img.getComponentVersions().getCdp())));
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 9L && "C".equals(img.getComponentVersions().getCdp())));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataLakeAndDataHubIsOnTheSameVersionAndPatchUpgradeIsAvailable.
@Test
@DisplayName("this test simulates when the Data Lake and Data Hub version is the same (7.1.0)" + "and no upgrade options are available with this version.")
public void testCheckForUpgradeWhenDataLakeAndDataHubIsOnTheSameVersionAndPatchUpgradeIsAvailable() {
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
response.setUpgradeCandidates(List.of());
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(0, result.getUpgradeCandidates().size());
assertNull(result.getReason());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testWhenRangerRazDisabledAndEntitlementGrantedThenUpgradeAllowed.
@Test
public void testWhenRangerRazDisabledAndEntitlementGrantedThenUpgradeAllowed() {
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response currentImage = createImageResponse(2L, "7.2.0");
ImageInfoV4Response candidateImage1 = createImageResponse(3L, "7.2.1");
ImageInfoV4Response candidateImage2 = createImageResponse(4L, "7.2.2");
response.setUpgradeCandidates(List.of(candidateImage1, candidateImage2));
response.setCurrent(currentImage);
when(entitlementService.datahubRuntimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(true);
when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
assertDoesNotThrow(() -> underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN));
verify(clusterService, never()).getClusterByStackResourceCrn(DATALAKE_CRN);
}
Aggregations