Search in sources :

Example 41 with StackV4Response

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

the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreak.

@Test
@DisplayName("Test if the runtime is properly updated")
public void testUpdateRuntimeVersionFromCloudbreak() {
    when(sdxService.getById(1L)).thenReturn(sdxCluster);
    StackV4Response stackV4Response = getStackV4Response();
    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(1)).updateRuntimeVersionFromStackResponse(eq(sdxCluster), eq(stackV4Response));
    when(sdxService.getById(1L)).thenReturn(detachedSdxCluster);
    stackV4Response = getStackV4Response();
    when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
    underTest.updateRuntimeVersionFromCloudbreak(1L);
    verify(sdxService, times(1)).updateRuntimeVersionFromStackResponse(eq(detachedSdxCluster), eq(stackV4Response));
}
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 42 with StackV4Response

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

the class ProvisionerServiceTest method startForcedStackDeletionStackFound.

@Test
void startForcedStackDeletionStackFound() {
    long clusterId = CLUSTER_ID.incrementAndGet();
    SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
    when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setStatus(Status.CREATE_FAILED);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.startStackDeletion(clusterId, true);
    verify(stackV4Endpoint).deleteInternal(eq(0L), eq(null), eq(true), nullable(String.class));
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 43 with StackV4Response

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

the class ProvisionerServiceTest method waitCloudbreakClusterCreationSuccess.

@Test
void waitCloudbreakClusterCreationSuccess() {
    long clusterId = CLUSTER_ID.incrementAndGet();
    SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setStatus(Status.AVAILABLE);
    ClusterV4Response cluster = new ClusterV4Response();
    cluster.setStatus(Status.AVAILABLE);
    stackV4Response.setCluster(cluster);
    when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(stackV4Response);
    when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
    PollingConfig pollingConfig = new PollingConfig(10, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.waitCloudbreakClusterCreation(clusterId, pollingConfig);
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_CREATION_IN_PROGRESS, "Datalake stack creation in progress", sdxCluster);
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_CREATION_FINISHED, "Stack created for Datalake", sdxCluster);
}
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 44 with StackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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 45 with StackV4Response

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

the class ProvisionerServiceTest method startStackDeletionStackNotFound.

@Test
void startStackDeletionStackNotFound() {
    long clusterId = CLUSTER_ID.incrementAndGet();
    SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
    when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setStatus(Status.CREATE_FAILED);
    doThrow(new NotFoundException()).when(stackV4Endpoint).deleteInternal(anyLong(), eq(sdxCluster.getClusterName()), eq(Boolean.FALSE), nullable(String.class));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.startStackDeletion(clusterId, false);
    verify(stackV4Endpoint).deleteInternal(eq(0L), eq(null), eq(false), nullable(String.class));
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(javax.ws.rs.NotFoundException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

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