Search in sources :

Example 1 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmActionsTest method stackUpgradeHappyPath.

@Test
void stackUpgradeHappyPath() {
    actionPayload = new UpgradeCcmStackEvent(ACTION_PAYLOAD_SELECTOR, SDX_ID, USER_ID);
    setupContextWithPayload();
    testUpgradeActionHappyPath(underTest::upgradeCcmStack);
    UpgradeCcmStackRequest payload = (UpgradeCcmStackRequest) payloadArgumentCaptor.getValue();
    assertThat(selectorArgumentCaptor.getValue()).isEqualTo(UpgradeCcmStackRequest.class.getSimpleName());
    assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
    assertThat(payload.getUserId()).isEqualTo(USER_ID);
}
Also used : UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) UpgradeCcmStackEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackEvent) Test(org.junit.jupiter.api.Test)

Example 2 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandlerTest method acceptSuccess.

@Test
void acceptSuccess() throws Exception {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxService.getById(any())).thenReturn(sdxCluster);
    UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
    PollingConfig expectedPollingConfig = new PollingConfig(1, TimeUnit.SECONDS, 2, TimeUnit.MINUTES);
    Event.Headers headers = new Event.Headers();
    Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
    Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
    UpgradeCcmSuccessEvent successEvent = new UpgradeCcmSuccessEvent(1L, "user");
    assertThat(selectable).usingRecursiveComparison().isEqualTo(successEvent);
    verify(ccmUpgradeService).initAndWaitForStackUpgrade(eq(sdxCluster), refEq(expectedPollingConfig));
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Event(reactor.bus.Event) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandlerTest method defaultFailureEvent.

@Test
void defaultFailureEvent() {
    Selectable failureEvent = underTest.defaultFailureEvent(1L, new Exception("error"), new Event<>(new UpgradeCcmStackRequest(1L, "user")));
    assertThat(failureEvent.selector()).isEqualTo("UpgradeCcmFailedEvent");
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmStackHandlerTest method acceptWithExceptions.

@ParameterizedTest
@ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class })
void acceptWithExceptions(Class<? extends Throwable> errorClass) throws Exception {
    UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
    Event.Headers headers = new Event.Headers();
    Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
    when(sdxService.getById(any())).thenReturn(getSdxCluster());
    doThrow(errorClass).when(ccmUpgradeService).initAndWaitForStackUpgrade(any(SdxCluster.class), any(PollingConfig.class));
    Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
    UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(1L, "user", new Exception("error"));
    assertThat(selectable).usingRecursiveComparison().isEqualTo(failedEvent);
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Event(reactor.bus.Event) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with UpgradeCcmStackRequest

use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest in project cloudbreak by hortonworks.

the class UpgradeCcmActions method upgradeCcmStack.

@Bean(name = "UPGRADE_CCM_UPGRADE_STACK_STATE")
public Action<?, ?> upgradeCcmStack() {
    return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmStackEvent.class) {

        @Override
        protected void doExecute(SdxContext context, UpgradeCcmStackEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Execute CCM upgrade stack flow for SDX: {}", payload.getResourceId());
            UpgradeCcmStackRequest request = UpgradeCcmStackRequest.from(context);
            sendEvent(context, request);
        }

        @Override
        protected Object getFailurePayload(UpgradeCcmStackEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return UpgradeCcmFailedEvent.from(payload, ex);
        }
    };
}
Also used : Optional(java.util.Optional) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) Map(java.util.Map) UpgradeCcmStackEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackEvent) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

UpgradeCcmStackRequest (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest)6 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 PollerException (com.dyngr.exception.PollerException)3 PollerStoppedException (com.dyngr.exception.PollerStoppedException)3 UserBreakException (com.dyngr.exception.UserBreakException)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 UpgradeCcmFailedEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)3 UpgradeCcmSuccessEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent)3 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 UpgradeCcmStackEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackEvent)2 Event (reactor.bus.Event)2 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 Bean (org.springframework.context.annotation.Bean)1