Search in sources :

Example 16 with StackViewV4Response

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());
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 17 with StackViewV4Response

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);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)

Example 18 with StackViewV4Response

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);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)

Example 19 with StackViewV4Response

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"));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) UserBreakException(com.dyngr.exception.UserBreakException) Environment(com.sequenceiq.environment.environment.domain.Environment) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 20 with StackViewV4Response

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"));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) Environment(com.sequenceiq.environment.environment.domain.Environment) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Aggregations

StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)32 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)18 Test (org.junit.jupiter.api.Test)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 Test (org.junit.Test)8 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)3 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 StackApiView (com.sequenceiq.cloudbreak.domain.view.StackApiView)2