use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class CloudbreakPollerTest method testStartFailedStack.
@Test
public void testStartFailedStack() {
whenCheckFlowState().thenReturn(FlowState.UNKNOWN);
whenCheckStackStatus().thenReturn(statusResponse(Status.START_FAILED, "Stack start failed"));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
UserBreakException exception = assertThrows(UserBreakException.class, () -> underTest.pollStartUntilAvailable(sdxCluster, pollingConfig));
assertEquals("Start failed on 'clusterName' cluster. Reason: Stack start failed", exception.getMessage());
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestStackDeletionFailed.
@Test
void acceptTestStackDeletionFailed() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new UserBreakException("stack deletion failed")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxDeletionFailedEvent", eventNotified);
Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class CloudbreakPollerTest method testFlowFinishedClusterNotFailedNotAvailable.
@Test
public void testFlowFinishedClusterNotFailedNotAvailable() {
whenCheckFlowState().thenReturn(FlowState.FINISHED);
whenCheckStackStatus().thenReturn(statusResponse(Status.UPDATE_IN_PROGRESS, Status.UPDATE_IN_PROGRESS));
when(sdxStatusService.getShortStatusMessage(any(StackStatusV4Response.class))).thenReturn("testMessage");
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
UserBreakException exception = assertThrows(UserBreakException.class, () -> underTest.pollStartUntilAvailable(sdxCluster, pollingConfig));
assertEquals("Start failed on 'clusterName' cluster. Reason: testMessage", exception.getMessage());
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class CloudbreakPollerTest method testStartFailedCluster.
@Test
public void testStartFailedCluster() {
whenCheckFlowState().thenReturn(FlowState.UNKNOWN);
whenCheckStackStatus().thenReturn(statusResponse(Status.AVAILABLE, Status.START_FAILED, "Cluster start failed"));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
UserBreakException exception = assertThrows(UserBreakException.class, () -> underTest.pollStartUntilAvailable(sdxCluster, pollingConfig));
assertEquals("Start failed on 'clusterName' cluster. Reason: Cluster start failed", exception.getMessage());
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class SdxCertRenewWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxCertRenewalWaitEvent> event) {
SdxEvent sdxEvent = event.getData();
Long sdxId = sdxEvent.getResourceId();
String userId = sdxEvent.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack cert renewal process.");
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
certRenewalService.waitForCloudbreakClusterCertRenewal(sdxId, pollingConfig);
response = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINISHED_EVENT.event(), sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Cert renewal polling exited before timeout. Cause: ", userBreakException);
response = new SdxCertRenewalFailedEvent(sdxId, userId, userBreakException.getMessage());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Cert renewal poller stopped.");
response = new SdxCertRenewalFailedEvent(sdxId, userId, "Datalake cert renewal timed out after " + durationInMinutes + " minutes");
} catch (PollerException exception) {
LOGGER.error("Cert renewal polling failed. Cause: ", exception);
response = new SdxCertRenewalFailedEvent(sdxId, userId, exception.getMessage());
}
return response;
}
Aggregations