Search in sources :

Example 11 with SdxClusterResizeRequest

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());
}
Also used : SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 12 with SdxClusterResizeRequest

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());
}
Also used : SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 13 with SdxClusterResizeRequest

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;
}
Also used : SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse)

Aggregations

SdxClusterResizeRequest (com.sequenceiq.sdx.api.model.SdxClusterResizeRequest)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Test (org.junit.jupiter.api.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)1 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)1