use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint 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.StackV4Endpoint 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));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint 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());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class SdxRecoveryServiceTest method triggerCloudbreakRecovery.
@Test
public void triggerCloudbreakRecovery() {
Long clusterId = cluster.getId();
doNothing().when(cloudbreakFlowService).saveLastCloudbreakFlowChainId(any(), any());
FlowIdentifier flowId = new FlowIdentifier(FlowType.FLOW, "FLOW_ID_1");
RecoveryV4Response recoveryV4Response = new RecoveryV4Response(flowId);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(sdxService.getById(clusterId)).thenReturn(cluster);
when(ThreadBasedUserCrnProvider.doAsInternalActor("crn:cdp:iam:us-west-1:cloudera:user:__internal__actor__", () -> stackV4Endpoint.recoverClusterByNameInternal(0L, cluster.getClusterName(), ThreadBasedUserCrnProvider.getUserCrn()))).thenReturn(recoveryV4Response);
ThreadBasedUserCrnProvider.doAsInternalActor("crn:cdp:iam:us-west-1:cloudera:user:__internal__actor__", () -> underTest.recoverCluster(clusterId));
verify(stackV4Endpoint).recoverClusterByNameInternal(eq(0L), eq(CLUSTER_NAME), nullable(String.class));
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RECOVERY_IN_PROGRESS, DATALAKE_RECOVERY_REQUESTED, "Recovering datalake stack", cluster);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method startStackDeletionButClientError.
@Test
void startStackDeletionButClientError() {
long clusterId = CLUSTER_ID.incrementAndGet();
SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setStatus(Status.CREATE_FAILED);
WebApplicationException webApplicationException = new WebApplicationException();
doThrow(webApplicationException).when(stackV4Endpoint).deleteInternal(anyLong(), eq(sdxCluster.getClusterName()), eq(Boolean.FALSE), nullable(String.class));
when(webApplicationExceptionMessageExtractor.getErrorMessage(webApplicationException)).thenReturn("web-error");
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
RuntimeException actual = Assertions.assertThrows(RuntimeException.class, () -> underTest.startStackDeletion(clusterId, false));
Assertions.assertEquals("Cannot delete cluster, error happened during the operation: web-error", actual.getMessage());
verify(stackV4Endpoint).deleteInternal(eq(0L), eq(null), eq(false), nullable(String.class));
}
Aggregations