use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeMediumDutySdxEnabled710Runtime.
@Test
void testSdxResizeMediumDutySdxEnabled710Runtime() {
final String invalidRuntime = "7.1.0";
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
sdxCluster.setRuntime(invalidRuntime);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockEnvironmentCall(sdxClusterResizeRequest, CloudPlatform.AWS);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest)));
assertEquals("Provisioning a Medium Duty SDX shape is only valid for CM version greater than or equal to " + MEDIUM_DUTY_REQUIRED_VERSION + " and not " + invalidRuntime, badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeClusterWithoutCloudStorageShouldThrownBadRequestException.
@Test
void testSdxResizeClusterWithoutCloudStorageShouldThrownBadRequestException() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockEnvironmentCall(sdxClusterResizeRequest, CloudPlatform.AWS);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest)));
assertEquals("Cloud storage parameter is required.", badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxResizeAction method action.
/**
* Starts SDX resize operation, and retrieves the detailed SDX response after it's finished.
* @return result of the resize
* @throws Exception if the SdxClusterDetailResponse cannot be converted to JSON
*/
@Override
public SdxInternalTestDto action(TestContext testContext, SdxInternalTestDto testDto, SdxClient client) throws Exception {
SdxClusterResizeRequest clusterResizeRequest = testDto.getSdxResizeRequest();
Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
Log.whenJson(LOGGER, " SDX resize request: ", clusterResizeRequest);
SdxClusterResponse sdxClusterResponse = client.getDefaultClient().sdxEndpoint().resize(testDto.getName(), clusterResizeRequest);
testDto.setFlow("SDX resize", sdxClusterResponse.getFlowIdentifier());
SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
testDto.setResponse(detailedResponse);
Log.whenJson(LOGGER, " SDX resize response: ", detailedResponse);
return testDto;
}
Aggregations