use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.
the class SdxServiceTest method testDeleteSdxWhenSdxHasAttachedDataHubsShouldThrowBadRequestBecauseSdxCanNotDeletedIfAttachedClustersAreAvailable.
@Test
void testDeleteSdxWhenSdxHasAttachedDataHubsShouldThrowBadRequestBecauseSdxCanNotDeletedIfAttachedClustersAreAvailable() {
SdxCluster sdxCluster = getSdxCluster();
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setName("existingDistroXCluster");
stackViewV4Response.setStatus(Status.AVAILABLE);
mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.deleteSdx(USER_CRN, "sdx-cluster-name", false));
assertEquals("The following Data Hub cluster(s) must be stopped before attempting SDX deletion [existingDistroXCluster].", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.
the class StackOperations method listByStackIds.
public StackViewV4Responses listByStackIds(Long workspaceId, List<Long> stackIds, String environmentCrn, List<StackType> stackTypes) {
Set<StackViewV4Response> stackViewResponses;
stackViewResponses = stackApiViewService.retrieveStackViewsByStackIdsAndEnvironmentCrn(workspaceId, stackIds, environmentCrn, stackTypes).stream().map(s -> stackApiViewToStackViewV4ResponseConverter.convert(s)).collect(Collectors.toSet());
LOGGER.info("Adding environment name and credential to the responses.");
NameOrCrn nameOrCrn = Strings.isNullOrEmpty(environmentCrn) ? NameOrCrn.empty() : NameOrCrn.ofCrn(environmentCrn);
environmentServiceDecorator.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
LOGGER.info("Adding SDX CRN and name to the responses.");
sdxServiceDecorator.prepareMultipleSdxAttributes(stackViewResponses);
return new StackViewV4Responses(stackViewResponses);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.
the class StackOperations method listByEnvironmentName.
public StackViewV4Responses listByEnvironmentName(Long workspaceId, String environmentName, List<StackType> stackTypes) {
Set<StackViewV4Response> stackViewResponses;
LOGGER.info("List for Stack in workspace {} and environmentName {}.", workspaceId, environmentName);
stackViewResponses = stackApiViewService.retrieveStackViewsByWorkspaceIdAndEnvironmentName(workspaceId, environmentName, stackTypes).stream().map(s -> stackApiViewToStackViewV4ResponseConverter.convert(s)).collect(Collectors.toSet());
LOGGER.info("Adding environment name and credential to the responses.");
NameOrCrn nameOrCrn = StringUtils.isEmpty(environmentName) ? NameOrCrn.empty() : NameOrCrn.ofName(environmentName);
environmentServiceDecorator.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
LOGGER.info("Adding SDX CRN and name to the responses.");
sdxServiceDecorator.prepareMultipleSdxAttributes(stackViewResponses);
return new StackViewV4Responses(stackViewResponses);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.
the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironmentFail.
@Test
void deleteDatahubClustersForEnvironmentFail() {
PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(10).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
Environment environment = new Environment();
environment.setResourceCrn(ENV_CRN);
StackViewV4Response datahub1 = new StackViewV4Response();
datahub1.setCrn("crn1");
StackViewV4Response datahub2 = new StackViewV4Response();
datahub2.setCrn("crn2");
datahub2.setStatus(Status.DELETE_FAILED);
when(datahubService.list(anyString())).thenReturn(new StackViewV4Responses(Set.of(datahub1, datahub2)), new StackViewV4Responses(Set.of(datahub2)), new StackViewV4Responses(Set.of(datahub2)));
assertThatThrownBy(() -> underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true)).isInstanceOf(UserBreakException.class).hasCauseInstanceOf(IllegalStateException.class);
ArgumentCaptor<DistroXMultiDeleteV1Request> captor = ArgumentCaptor.forClass(DistroXMultiDeleteV1Request.class);
verify(datahubService).deleteMultiple(anyString(), captor.capture(), eq(true));
DistroXMultiDeleteV1Request multiDeleteRequest = captor.getValue();
assertThat(multiDeleteRequest.getCrns()).hasSameElementsAs(Set.of("crn1", "crn2"));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.
the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironment.
@Test
void deleteDatahubClustersForEnvironment() {
PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(10).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
Environment environment = new Environment();
environment.setResourceCrn(ENV_CRN);
StackViewV4Response distrox1 = new StackViewV4Response();
distrox1.setCrn("crn1");
StackViewV4Response distrox2 = new StackViewV4Response();
distrox2.setCrn("crn2");
when(datahubService.list(anyString())).thenReturn(new StackViewV4Responses(Set.of(distrox1, distrox2)), new StackViewV4Responses(Set.of(distrox2)), new StackViewV4Responses(Set.of()));
underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true);
ArgumentCaptor<DistroXMultiDeleteV1Request> captor = ArgumentCaptor.forClass(DistroXMultiDeleteV1Request.class);
verify(datahubService).deleteMultiple(anyString(), captor.capture(), eq(true));
DistroXMultiDeleteV1Request multiDeleteRequest = captor.getValue();
assertThat(multiDeleteRequest.getCrns()).hasSameElementsAs(Set.of("crn1", "crn2"));
}
Aggregations