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