Search in sources :

Example 11 with ClusterV4Response

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

the class ProvisionerServiceTest method waitCloudbreakClusterDeletionStackRetryFailedTest.

@Test
void waitCloudbreakClusterDeletionStackRetryFailedTest() {
    long clusterId = CLUSTER_ID.incrementAndGet();
    SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
    sdxCluster.setClusterName("sdxcluster1");
    when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    StackV4Response firstStackV4Response = new StackV4Response();
    firstStackV4Response.setStatus(Status.DELETE_FAILED);
    ClusterV4Response firstClusterResponse = new ClusterV4Response();
    firstClusterResponse.setStatus(Status.DELETE_IN_PROGRESS);
    firstStackV4Response.setCluster(firstClusterResponse);
    StackV4Response secondStackV4Response = new StackV4Response();
    secondStackV4Response.setStatus(Status.DELETE_FAILED);
    ClusterV4Response secondClusterResponse = new ClusterV4Response();
    secondClusterResponse.setStatus(Status.DELETE_COMPLETED);
    secondStackV4Response.setCluster(secondClusterResponse);
    when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(firstStackV4Response).thenReturn(secondStackV4Response).thenThrow(new NotFoundException());
    PollingConfig pollingConfig = new PollingConfig(10, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
    underTest.waitCloudbreakClusterDeletion(clusterId, pollingConfig);
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_DELETED, "Datalake stack deleted", sdxCluster);
    verify(stackV4Endpoint, times(3)).get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 12 with ClusterV4Response

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

the class ProvisionerServiceTest method waitCloudbreakClusterDeletionClusterRetryFailedTest.

@Test
void waitCloudbreakClusterDeletionClusterRetryFailedTest() {
    long clusterId = CLUSTER_ID.incrementAndGet();
    SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
    sdxCluster.setClusterName("sdxcluster1");
    when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
    StackV4Response firstStackV4Response = new StackV4Response();
    firstStackV4Response.setStatus(Status.DELETE_IN_PROGRESS);
    ClusterV4Response firstClusterResponse = new ClusterV4Response();
    firstClusterResponse.setStatus(Status.DELETE_IN_PROGRESS);
    firstClusterResponse.setStatusReason("delete failed");
    firstStackV4Response.setCluster(firstClusterResponse);
    StackV4Response secondStackV4Response = new StackV4Response();
    secondStackV4Response.setStatus(Status.DELETE_FAILED);
    ClusterV4Response secondClusterResponse = new ClusterV4Response();
    secondClusterResponse.setStatus(Status.DELETE_IN_PROGRESS);
    secondClusterResponse.setStatusReason("delete failed");
    secondStackV4Response.setCluster(secondClusterResponse);
    StackV4Response thirdStackV4Response = new StackV4Response();
    thirdStackV4Response.setStatus(Status.DELETE_FAILED);
    ClusterV4Response thirdClusterResponse = new ClusterV4Response();
    thirdClusterResponse.setStatus(Status.DELETE_FAILED);
    thirdClusterResponse.setStatusReason("delete failed");
    thirdStackV4Response.setCluster(thirdClusterResponse);
    when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(firstStackV4Response).thenReturn(secondStackV4Response).thenReturn(thirdStackV4Response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    PollingConfig pollingConfig = new PollingConfig(10, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS);
    Assertions.assertThrows(UserBreakException.class, () -> underTest.waitCloudbreakClusterDeletion(clusterId, pollingConfig), "Data lake deletion failed 'sdxcluster1', delete failed");
    verify(stackV4Endpoint, times(5)).get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Example 13 with ClusterV4Response

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

the class SdxRecoveryService method getStackResponseAttemptResult.

private AttemptResult<StackV4Response> getStackResponseAttemptResult(SdxCluster sdxCluster, String pollingMessage, FlowState flowState) throws JsonProcessingException {
    StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
    LOGGER.info("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
    ClusterV4Response cluster = stackV4Response.getCluster();
    if (availabilityChecker.stackAndClusterAvailable(stackV4Response, cluster)) {
        return AttemptResults.finishWith(stackV4Response);
    } else {
        return getResponseAttemptResultUnavailableCase(sdxCluster, pollingMessage, flowState, stackV4Response);
    }
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)

Example 14 with ClusterV4Response

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

the class SdxBackupRestoreService method getStackResponseAttemptResult.

private AttemptResult<StackV4Response> getStackResponseAttemptResult(SdxCluster sdxCluster, String pollingMessage, FlowState flowState) throws JsonProcessingException {
    StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
    LOGGER.info("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
    ClusterV4Response cluster = stackV4Response.getCluster();
    if (isStackOrClusterDrStatusComplete(stackV4Response.getStatus()) && isStackOrClusterDrStatusComplete(cluster.getStatus())) {
        return sdxDrSucceeded(stackV4Response);
    } else if (isStackOrClusterStatusFailed(stackV4Response.getStatus())) {
        LOGGER.info("{} failed for Stack {} with status {}", pollingMessage, stackV4Response.getName(), stackV4Response.getStatus());
        return sdxDrFailed(sdxCluster, stackV4Response.getStatusReason(), pollingMessage);
    } else if (isStackOrClusterStatusFailed(stackV4Response.getCluster().getStatus())) {
        LOGGER.info("{} failed for Cluster {} status {}", pollingMessage, stackV4Response.getCluster().getName(), stackV4Response.getCluster().getStatus());
        return sdxDrFailed(sdxCluster, stackV4Response.getCluster().getStatusReason(), pollingMessage);
    } else if (FINISHED.equals(flowState)) {
        LOGGER.info("Flow finished, but Backup/Restore is not complete: {}", sdxCluster.getClusterName());
        return sdxDrFailed(sdxCluster, "stack is in improper state", pollingMessage);
    } else {
        LOGGER.info("Flow is unknown state");
        return sdxDrFailed(sdxCluster, "Flow is unknown state", pollingMessage);
    }
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)

Example 15 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response 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)

Aggregations

ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)19 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)14 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)6 Json (com.sequenceiq.cloudbreak.common.json.Json)4 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ClouderaManagerProductV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response)3 ClouderaManagerV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)3 Test (org.junit.jupiter.api.Test)3 BlueprintV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)2 CustomContainerV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.customcontainer.CustomContainerV4Response)2 GatewayV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.GatewayV4Response)2 ClusterExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 AuthorizationResourceType (com.sequenceiq.authorization.resource.AuthorizationResourceType)1