Search in sources :

Example 16 with UserBreakException

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());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Test(org.junit.jupiter.api.Test)

Example 17 with UserBreakException

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());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Event(reactor.bus.Event) SdxDeletionFailedEvent(com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent) StackDeletionSuccessEvent(com.sequenceiq.datalake.flow.delete.event.StackDeletionSuccessEvent) StackDeletionWaitRequest(com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 18 with UserBreakException

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());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) Test(org.junit.jupiter.api.Test)

Example 19 with UserBreakException

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());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Test(org.junit.jupiter.api.Test)

Example 20 with UserBreakException

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;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxCertRenewalFailedEvent(com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

UserBreakException (com.dyngr.exception.UserBreakException)41 PollerException (com.dyngr.exception.PollerException)30 PollerStoppedException (com.dyngr.exception.PollerStoppedException)30 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)28 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)21 Test (org.junit.jupiter.api.Test)10 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)7 SdxCreateFailedEvent (com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent)5 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)4 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)4 DatalakeUpgradeFailedEvent (com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent)3 SdxDeletionFailedEvent (com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent)3 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)3 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 StackCreationSuccessEvent (com.sequenceiq.datalake.flow.create.event.StackCreationSuccessEvent)2 StackCreationWaitRequest (com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest)2