Search in sources :

Example 1 with DistroXMultiDeleteV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request in project cloudbreak by hortonworks.

the class DatahubDeletionService method waitDatahubClustersDeletion.

private void waitDatahubClustersDeletion(PollingConfig pollingConfig, Environment environment, Collection<StackViewV4Response> list, boolean force) {
    DistroXMultiDeleteV1Request multiDeleteRequest = new DistroXMultiDeleteV1Request();
    multiDeleteRequest.setCrns(list.stream().map(StackViewV4Response::getCrn).collect(Collectors.toSet()));
    LOGGER.debug("Calling distroXV1Endpoint.deleteMultiple with crn [{}]", multiDeleteRequest.getCrns());
    datahubService.deleteMultiple(environment.getResourceCrn(), multiDeleteRequest, force);
    LOGGER.debug("Starting poller to check all Datahub stacks for environment {} are deleted", environment.getName());
    try {
        Polling.stopAfterDelay(pollingConfig.getTimeout(), pollingConfig.getTimeoutTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccured()).waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).run(() -> periodicCheckForDeletion(environment));
    } catch (PollerStoppedException e) {
        LOGGER.info("Datahub cluster deletion timed out");
        throw new DatahubOperationFailedException("Datahub cluster deletion timed out", e);
    }
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) DatahubOperationFailedException(com.sequenceiq.environment.exception.DatahubOperationFailedException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 2 with DistroXMultiDeleteV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request 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 3 with DistroXMultiDeleteV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request 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)3 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)3 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2 PollingConfig (com.sequenceiq.environment.util.PollingConfig)2 Test (org.junit.jupiter.api.Test)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 DatahubOperationFailedException (com.sequenceiq.environment.exception.DatahubOperationFailedException)1