use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE in project cloudbreak by hortonworks.
the class DatalakeService method addSharedServiceResponse.
public void addSharedServiceResponse(Stack stack, StackV4Response stackResponse) {
SharedServiceV4Response sharedServiceResponse = new SharedServiceV4Response();
if (!Strings.isNullOrEmpty(stack.getDatalakeCrn())) {
LOGGER.debug("Checking datalake through the datalakeCrn.");
Optional<ResourceBasicView> resourceBasicView = stackService.getResourceBasicViewByResourceCrn(stack.getDatalakeCrn());
if (resourceBasicView.isPresent()) {
ResourceBasicView s = resourceBasicView.get();
sharedServiceResponse.setSharedClusterId(s.getId());
sharedServiceResponse.setSharedClusterName(s.getName());
} else {
LOGGER.debug("Unable to find datalake with CRN {}", stack.getDatalakeCrn());
}
}
stackResponse.setSharedService(sharedServiceResponse);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE in project cloudbreak by hortonworks.
the class ImageCatalogChangeTest method testFreeipaImageCatalogChange.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a running Freeipa/Datalake/Datahub", when = "calling change image catalog", then = "it should have new image catalog")
public void testFreeipaImageCatalogChange(MockedTestContext testContext) {
// Freeipa
final String newImageCatalog = testContext.given(FreeIpaTestDto.class).getResponse().getImage().getCatalog() + "&changed=true";
testContext.given(FreeipaChangeImageCatalogTestDto.class).withImageCatalog(newImageCatalog).when(freeIpaTestClient.changeImageCatalog()).given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getImage().getCatalog();
if (!newImageCatalog.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Freeipa was not changed. Catalog : %s", actualCatalog));
}
return testDto;
});
// Datalake
testContext.given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING);
final StackImageV4Response sdxImage = testContext.given(SdxInternalTestDto.class).getResponse().getStackV4Response().getImage();
final String sdxNewImageCatalogName = createNewImageCatalog(testContext, sdxImage);
testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(sdxNewImageCatalogName).when(sdxTestClient.changeImageCatalog()).given(SdxInternalTestDto.class).when(sdxTestClient.describeInternal()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getStackV4Response().getImage().getCatalogName();
if (!sdxNewImageCatalogName.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Datalake was not changed. Catalog : %s", actualCatalog));
}
return testDto;
});
// Datahub
testContext.given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE);
final StackImageV4Response distroXImage = testContext.given(DistroXTestDto.class).getResponse().getImage();
final String distroXNewImageCatalogName = createNewImageCatalog(testContext, distroXImage);
testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(distroXNewImageCatalogName).when(distroXClient.changeImageCatalog()).given(DistroXTestDto.class).when(distroXClient.get()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getImage().getCatalogName();
if (!distroXNewImageCatalogName.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Datahub was not changed. Catalog : %s", actualCatalog));
}
return testDto;
}).validate();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE in project cloudbreak by hortonworks.
the class DatalakeUpgradeActions method imageChange.
@Bean(name = "DATALAKE_IMAGE_CHANGE_STATE")
public Action<?, ?> imageChange() {
return new AbstractSdxAction<>(DatalakeImageChangeEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeImageChangeEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeImageChangeEvent payload, Map<Object, Object> variables) {
LOGGER.info("Start Datalake upgrade image change for {} ", payload.getResourceId());
sdxUpgradeService.updateRuntimeVersionFromCloudbreak(payload.getResourceId());
String catalogName = sdxUpgradeService.getCurrentImageCatalogName(payload.getResourceId());
UpgradeOptionV4Response upgrade = new UpgradeOptionV4Response().upgrade(new ImageInfoV4Response().imageId(payload.getImageId()).imageCatalogName(catalogName));
sdxUpgradeService.changeImage(payload.getResourceId(), upgrade);
sendEvent(context, new DatalakeChangeImageWaitRequest(DATALAKE_IMAGE_CHANGE_IN_PROGRESS_EVENT.event(), context.getSdxId(), context.getUserId(), upgrade));
}
@Override
protected Object getFailurePayload(DatalakeImageChangeEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeUpgradeFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE in project cloudbreak by hortonworks.
the class SdxServiceTest method testCcmV2JumpgateVersionChecker.
@ParameterizedTest(name = "Runtime {0} is compatible with CCMv2JumpGate = {1}")
@MethodSource("ccmV2JumpgateScenarios")
void testCcmV2JumpgateVersionChecker(String runtime, boolean compatible) throws IOException {
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(runtime, LIGHT_DUTY);
when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.10/aws/light_duty.json");
lenient().when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.MOCK, Tunnel.CCMV2_JUMPGATE);
if (!compatible) {
assertThatThrownBy(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null))).isInstanceOf(BadRequestException.class).hasMessage(String.format("Runtime version %s does not support Cluster Connectivity Manager. " + "Please try creating a datalake with runtime version at least %s.", runtime, CCMV2_JUMPGATE_REQUIRED_VERSION));
} else {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE in project cloudbreak by hortonworks.
the class SdxServiceTest method testDeleteSdxWhenSdxHasStoppedDataHubsShouldSucceedWhenForced.
@Test
void testDeleteSdxWhenSdxHasStoppedDataHubsShouldSucceedWhenForced() {
SdxCluster sdxCluster = getSdxCluster();
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxReactorFlowManager.triggerSdxDeletion(any(SdxCluster.class), anyBoolean())).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setName("existingDistroXCluster");
stackViewV4Response.setStatus(Status.STOPPED);
mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response));
underTest.deleteSdx(USER_CRN, "sdx-cluster-name", true);
verify(sdxReactorFlowManager, times(1)).triggerSdxDeletion(sdxCluster, true);
ArgumentCaptor<SdxCluster> captor = ArgumentCaptor.forClass(SdxCluster.class);
verify(sdxClusterRepository, times(1)).save(captor.capture());
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETE_REQUESTED, "Datalake deletion requested", sdxCluster);
}
Aggregations