Search in sources :

Example 56 with StackV4Response

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

the class StackCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StackCreationWaitRequest> handlerEvent) {
    StackCreationWaitRequest stackCreationWaitRequest = handlerEvent.getData();
    Long sdxId = stackCreationWaitRequest.getResourceId();
    String userId = stackCreationWaitRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("start polling stack creation process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        StackV4Response stackV4Response = provisionerService.waitCloudbreakClusterCreation(sdxId, pollingConfig);
        SdxCluster sdxCluster = sdxService.getById(sdxId);
        sdxService.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
        setStackCreatedStatus(sdxId);
        response = new StackCreationSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout for SDX: {}. Cause: ", sdxId, userBreakException);
        response = new SdxCreateFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for SDX: {}", sdxId, pollerStoppedException);
        response = new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack creation timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack: {}", sdxId, exception);
        response = new SdxCreateFailedEvent(sdxId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in stack creation wait phase", anotherException);
        response = new SdxCreateFailedEvent(sdxId, userId, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackCreationWaitRequest(com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) StackCreationSuccessEvent(com.sequenceiq.datalake.flow.create.event.StackCreationSuccessEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 57 with StackV4Response

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

the class SdxServiceTest method testSdxResizeClusterSuccess.

@Test
void testSdxResizeClusterSuccess() throws Exception {
    final String runtime = "7.2.10";
    SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
    sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
    sdxClusterResizeRequest.setEnvironment("environment");
    SdxCluster sdxCluster = getSdxCluster();
    sdxCluster.setId(1L);
    sdxCluster.setClusterShape(LIGHT_DUTY);
    sdxCluster.setDatabaseCrn(null);
    sdxCluster.setRuntime(runtime);
    sdxCluster.setCloudStorageBaseLocation("s3a://some/dir/");
    when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
    when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
    when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
    mockEnvironmentCall(sdxClusterResizeRequest, CloudPlatform.AWS);
    when(sdxReactorFlowManager.triggerSdxResize(anyLong(), any(SdxCluster.class))).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
    String mediumDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.10/aws/medium_duty_ha.json");
    when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(mediumDutyJson, StackV4Request.class));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setStatus(Status.STOPPED);
    when(stackV4Endpoint.get(anyLong(), anyString(), anySet(), anyString())).thenReturn(stackV4Response);
    Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.resizeSdx(USER_CRN, sdxCluster.getClusterName(), sdxClusterResizeRequest));
    SdxCluster createdSdxCluster = result.getLeft();
    assertEquals(sdxCluster.getClusterName(), createdSdxCluster.getClusterName());
    assertEquals(runtime, createdSdxCluster.getRuntime());
    assertEquals("s3a://some/dir/", createdSdxCluster.getCloudStorageBaseLocation());
    assertEquals("envir", createdSdxCluster.getEnvName());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 58 with StackV4Response

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

the class SdxServiceTest method testUpdateRuntimeVersionFromStackResponse.

@Test
public void testUpdateRuntimeVersionFromStackResponse() {
    SdxCluster sdxCluster = getSdxCluster();
    StackV4Response stackV4Response = new StackV4Response();
    ClusterV4Response clusterV4Response = new ClusterV4Response();
    ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
    ClouderaManagerProductV4Response cdpResponse = new ClouderaManagerProductV4Response();
    cdpResponse.setName("CDH");
    cdpResponse.setVersion("7.2.1-1.32.123-123");
    cm.setProducts(Collections.singletonList(cdpResponse));
    clusterV4Response.setCm(cm);
    stackV4Response.setCluster(clusterV4Response);
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    ArgumentCaptor<SdxCluster> sdxClusterArgumentCaptor = ArgumentCaptor.forClass(SdxCluster.class);
    verify(sdxClusterRepository, times(1)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.2.1", sdxClusterArgumentCaptor.getValue().getRuntime());
    cdpResponse.setVersion("7.1.0");
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    verify(sdxClusterRepository, times(2)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.1.0", sdxClusterArgumentCaptor.getValue().getRuntime());
    cdpResponse.setVersion("7.0.2-valami");
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    verify(sdxClusterRepository, times(3)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.0.2", sdxClusterArgumentCaptor.getValue().getRuntime());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 59 with StackV4Response

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

the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCM.

@Test
@DisplayName("Test if the runtime cannot be updated when there is no CM installed")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCM() {
    when(sdxService.getById(1L)).thenReturn(sdxCluster);
    StackV4Response stackV4Response = getStackV4Response();
    stackV4Response.getCluster().setCm(null);
    when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.updateRuntimeVersionFromCloudbreak(1L);
    verify(sdxService, times(0)).save(any());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 60 with StackV4Response

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

the class SdxUpgradeServiceTest method getStackV4Response.

private StackV4Response getStackV4Response() {
    ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
    cdp.setName("CDH");
    cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
    ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
    cfm.setName("CFM");
    cfm.setVersion("2.0.0.0");
    ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
    spark3.setName("SPARK3");
    spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
    ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
    cm.setProducts(List.of(cdp, cfm, spark3));
    ClusterV4Response clusterV4Response = new ClusterV4Response();
    clusterV4Response.setCm(cm);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setName("test-sdx-cluster");
    stackV4Response.setCluster(clusterV4Response);
    return stackV4Response;
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)101 Test (org.junit.jupiter.api.Test)26 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)19 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)14 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)7 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)7 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)6 TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)6 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)6 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)6