use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackCreationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StackCreationWaitRequest> handlerEvent) {
StackCreationWaitRequest stackCreationWaitRequest = handlerEvent.getData();
Long sdxId = stackCreationWaitRequest.getResourceId();
String userId = stackCreationWaitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("start polling stack creation process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
StackV4Response stackV4Response = provisionerService.waitCloudbreakClusterCreation(sdxId, pollingConfig);
SdxCluster sdxCluster = sdxService.getById(sdxId);
sdxService.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
setStackCreatedStatus(sdxId);
response = new StackCreationSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Polling exited before timeout for SDX: {}. Cause: ", sdxId, userBreakException);
response = new SdxCreateFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Poller stopped for SDX: {}", sdxId, pollerStoppedException);
response = new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack creation timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Polling failed for stack: {}", sdxId, exception);
response = new SdxCreateFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in stack creation wait phase", anotherException);
response = new SdxCreateFailedEvent(sdxId, userId, anotherException);
}
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeClusterSuccess.
@Test
void testSdxResizeClusterSuccess() throws Exception {
final String runtime = "7.2.10";
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setId(1L);
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
sdxCluster.setRuntime(runtime);
sdxCluster.setCloudStorageBaseLocation("s3a://some/dir/");
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
mockEnvironmentCall(sdxClusterResizeRequest, CloudPlatform.AWS);
when(sdxReactorFlowManager.triggerSdxResize(anyLong(), any(SdxCluster.class))).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
String mediumDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.10/aws/medium_duty_ha.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(mediumDutyJson, StackV4Request.class));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setStatus(Status.STOPPED);
when(stackV4Endpoint.get(anyLong(), anyString(), anySet(), anyString())).thenReturn(stackV4Response);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.resizeSdx(USER_CRN, sdxCluster.getClusterName(), sdxClusterResizeRequest));
SdxCluster createdSdxCluster = result.getLeft();
assertEquals(sdxCluster.getClusterName(), createdSdxCluster.getClusterName());
assertEquals(runtime, createdSdxCluster.getRuntime());
assertEquals("s3a://some/dir/", createdSdxCluster.getCloudStorageBaseLocation());
assertEquals("envir", createdSdxCluster.getEnvName());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCM.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no CM installed")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCM() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
stackV4Response.getCluster().setCm(null);
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(0)).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method getStackV4Response.
private StackV4Response getStackV4Response() {
ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
cdp.setName("CDH");
cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
cfm.setName("CFM");
cfm.setVersion("2.0.0.0");
ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
spark3.setName("SPARK3");
spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
cm.setProducts(List.of(cdp, cfm, spark3));
ClusterV4Response clusterV4Response = new ClusterV4Response();
clusterV4Response.setCm(cm);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setName("test-sdx-cluster");
stackV4Response.setCluster(clusterV4Response);
return stackV4Response;
}
Aggregations