use of com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTestPollerStackOtherError.
@Test
void acceptTestPollerStackOtherError() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerException("stack error")).when(provisionerService).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), 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("SdxCreateFailedEvent", eventNotified);
Assertions.assertEquals(SdxCreateFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((SdxCreateFailedEvent) event.getData()).getResourceId());
Assertions.assertEquals(PollerException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
use of com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest in project cloudbreak by hortonworks.
the class StackCreationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StackCreationWaitRequest> handlerEvent) {
StackCreationWaitRequest stackCreationWaitRequest = handlerEvent.getData();
Long sdxId = stackCreationWaitRequest.getResourceId();
String userId = stackCreationWaitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("start polling stack creation process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
StackV4Response stackV4Response = provisionerService.waitCloudbreakClusterCreation(sdxId, pollingConfig);
SdxCluster sdxCluster = sdxService.getById(sdxId);
sdxService.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
setStackCreatedStatus(sdxId);
response = new StackCreationSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Polling exited before timeout for SDX: {}. Cause: ", sdxId, userBreakException);
response = new SdxCreateFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Poller stopped for SDX: {}", sdxId, pollerStoppedException);
response = new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack creation timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Polling failed for stack: {}", sdxId, exception);
response = new SdxCreateFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in stack creation wait phase", anotherException);
response = new SdxCreateFailedEvent(sdxId, userId, anotherException);
}
return response;
}
use of com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTest.
@Test
void acceptTest() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
StackV4Response stackV4Response = new StackV4Response();
when(provisionerService.waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class))).thenReturn(stackV4Response);
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(sdxService, times(1)).updateRuntimeVersionFromStackResponse(any(), eq(stackV4Response));
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("StackCreationSuccessEvent", eventNotified);
Assertions.assertEquals(StackCreationSuccessEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((StackCreationSuccessEvent) event.getData()).getResourceId());
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(STACK_CREATION_FINISHED, "Datalake stack created", (Long) stackId);
}
use of com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTestPollerStackTimeout.
@Test
void acceptTestPollerStackTimeout() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerStoppedException("stack timeout")).when(provisionerService).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), 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("SdxCreateFailedEvent", eventNotified);
Assertions.assertEquals(SdxCreateFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((SdxCreateFailedEvent) event.getData()).getResourceId());
Assertions.assertEquals(PollerStoppedException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
use of com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTestPollerStackFailed.
@Test
void acceptTestPollerStackFailed() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new UserBreakException("stack failed")).when(provisionerService).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), 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("SdxCreateFailedEvent", eventNotified);
Assertions.assertEquals(SdxCreateFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((SdxCreateFailedEvent) event.getData()).getResourceId());
Assertions.assertEquals(UserBreakException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
Aggregations