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));
}
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));
}
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);
}
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());
}
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));
}
Aggregations