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