use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class SdxRuntimeUpgradeServiceTest method testShowLatestOnlyShouldReturnLatestUpgradeCandidatesPerRuntime.
@Test
public void testShowLatestOnlyShouldReturnLatestUpgradeCandidatesPerRuntime() {
when(entitlementService.runtimeUpgradeEnabled(any())).thenReturn(true);
ImageComponentVersions imageComponentVersionsFor702 = new ImageComponentVersions();
imageComponentVersionsFor702.setCm(V_7_0_2);
imageComponentVersionsFor702.setCdp(V_7_0_2);
ImageComponentVersions imageComponentVersionsFor703 = new ImageComponentVersions();
imageComponentVersionsFor703.setCm(V_7_0_3);
imageComponentVersionsFor703.setCdp(V_7_0_3);
ImageInfoV4Response imageInfo1 = new ImageInfoV4Response();
imageInfo1.setImageId(IMAGE_ID + 1);
imageInfo1.setCreated(1);
imageInfo1.setComponentVersions(imageComponentVersionsFor702);
ImageInfoV4Response imageInfo2 = new ImageInfoV4Response();
imageInfo2.setImageId(IMAGE_ID + 2);
imageInfo2.setCreated(2);
imageInfo2.setComponentVersions(imageComponentVersionsFor702);
ImageInfoV4Response imageInfo3 = new ImageInfoV4Response();
imageInfo3.setImageId(IMAGE_ID + 3);
imageInfo3.setCreated(3);
imageInfo3.setComponentVersions(imageComponentVersionsFor703);
UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
upgradeV4Response.setUpgradeCandidates(List.of(imageInfo1, imageInfo2, imageInfo3));
sdxUpgradeRequest.setShowAvailableImages(SdxUpgradeShowAvailableImages.LATEST_ONLY);
UpgradeV4Response actualResponse = underTest.filterSdxUpgradeResponse(ACCOUNT_ID, sdxCluster.getClusterName(), sdxUpgradeRequest, upgradeV4Response);
assertEquals(2, actualResponse.getUpgradeCandidates().size());
assertFalse(actualResponse.getUpgradeCandidates().stream().anyMatch(imageInfoV4Response -> imageInfoV4Response.getImageId().equals(IMAGE_ID + 1)));
assertTrue(actualResponse.getUpgradeCandidates().stream().anyMatch(imageInfoV4Response -> imageInfoV4Response.getImageId().equals(IMAGE_ID + 2)));
assertTrue(actualResponse.getUpgradeCandidates().stream().anyMatch(imageInfoV4Response -> imageInfoV4Response.getImageId().equals(IMAGE_ID + 3)));
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameRuntimeIsSetAndDisabled.
@Test
void testUpgradeClusterByNameRuntimeIsSetAndDisabled() {
SdxUpgradeRequest request = new SdxUpgradeRequest();
request.setRuntime("7.1.0");
doThrow(new BadRequestException("Runtime upgrade feature is not enabled")).when(sdxRuntimeUpgradeService).triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId());
BadRequestException exception = doAs(USER_CRN, () -> Assertions.assertThrows(BadRequestException.class, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request)));
assertEquals("Runtime upgrade feature is not enabled", exception.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsEmptyAndRuntimeIsDisabled.
@Test
void testUpgradeClusterByNameWhenRequestIsEmptyAndRuntimeIsDisabled() {
SdxUpgradeRequest request = new SdxUpgradeRequest();
doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
verify(sdxRuntimeUpgradeService, times(1)).triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId());
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsEnabled.
@Test
void testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsEnabled() {
SdxUpgradeRequest request = new SdxUpgradeRequest();
request.setImageId("imageId");
SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
sdxUpgradeResponse.setReason("No image available to upgrade");
when(sdxRuntimeUpgradeService.triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId())).thenReturn(sdxUpgradeResponse);
SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
verify(sdxRuntimeUpgradeService, times(0)).checkForUpgradeByName(any(), any(), any(), anyString());
verify(sdxRuntimeUpgradeService).triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId());
assertEquals("No image available to upgrade", response.getReason());
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsDryRunAndLockComponents.
@Test
void testUpgradeClusterByNameWhenRequestIsDryRunAndLockComponents() {
SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
sdxUpgradeResponse.setReason("No image available to upgrade");
SdxUpgradeRequest request = new SdxUpgradeRequest();
request.setDryRun(true);
request.setLockComponents(true);
when(sdxRuntimeUpgradeService.checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString())).thenReturn(sdxUpgradeResponse);
SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
verify(sdxRuntimeUpgradeService, times(1)).checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString());
assertEquals("No image available to upgrade", response.getReason());
}
Aggregations