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);
}
}
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"));
}
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"));
}
Aggregations