use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatalakeHandlerTest method testAcceptWhenUpgradeSkipped.
@Test
void testAcceptWhenUpgradeSkipped() {
SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.SKIP, new FlowIdentifier(FlowType.FLOW, "flowId"), "reason", "datalakeCrn");
when(sdxService.upgradeCcm(TEST_ENV_CRN)).thenReturn(response);
underTest.accept(mockEnvironmentDtoEvent);
verify(sdxUpgradeCcmPollerService, never()).waitForUpgradeCcm(any(), any());
UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATAHUB_EVENT");
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatalakeHandlerTest method testAcceptWhenUpgradeTriggered.
@Test
void testAcceptWhenUpgradeTriggered() {
SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.TRIGGERED, new FlowIdentifier(FlowType.FLOW, "flowId"), "reason", "datalakeCrn");
when(sdxService.upgradeCcm(TEST_ENV_CRN)).thenReturn(response);
underTest.accept(mockEnvironmentDtoEvent);
verify(sdxUpgradeCcmPollerService).waitForUpgradeCcm(TEST_ENV_ID, "datalakeCrn");
UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATAHUB_EVENT");
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaAcceptedStatuses.
@ParameterizedTest
@EnumSource(value = Status.class, names = { "AVAILABLE", "UPGRADE_CCM_FAILED" }, mode = EnumSource.Mode.INCLUDE)
void testFreeIpaAcceptedStatuses(Status status) {
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setStatus(status);
freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
Optional<DescribeFreeIpaResponse> freeipaOpt = Optional.of(freeipa);
when(freeIpaService.describe(any())).thenReturn(freeipaOpt);
underTest.accept(mockEnvironmentDtoEvent);
verify(freeIpaPollerService).waitForCcmUpgrade(TEST_ENV_ID, TEST_ENV_CRN);
UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_TUNNEL_UPDATE_EVENT");
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmTunnelUpdateHandlerTest method accept.
@Test
void accept() {
underTest.accept(mockEnvironmentDtoEvent);
verify(environmentService).updateTunnelByEnvironmentId(TEST_ENV_ID, Tunnel.latestUpgradeTarget());
UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATALAKE_EVENT");
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActionsTest method setUp.
@BeforeEach
void setUp() {
FlowParameters flowParameters = new FlowParameters(FLOW_ID, FLOW_TRIGGER_USER_CRN, null);
when(stateContext.getMessageHeader(MessageFactory.HEADERS.FLOW_PARAMETERS.name())).thenReturn(flowParameters);
actionPayload = new UpgradeCcmEvent(ACTION_PAYLOAD_SELECTOR, ENVIRONMENT_ID, ENVIRONMENT_NAME, ENVIRONMENT_CRN);
when(stateContext.getMessageHeader(MessageFactory.HEADERS.DATA.name())).thenReturn(actionPayload);
when(stateContext.getExtendedState()).thenReturn(extendedState);
when(extendedState.getVariables()).thenReturn(new HashMap<>());
when(stateContext.getStateMachine()).thenReturn(stateMachine);
when(stateMachine.getState()).thenReturn(state);
lenient().when(reactorEventFactory.createEvent(anyMap(), isNotNull())).thenReturn(event);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(tracer.buildSpan(anyString())).thenReturn(spanBuilder);
when(spanBuilder.addReference(anyString(), any())).thenReturn(spanBuilder);
when(spanBuilder.ignoreActiveSpan()).thenReturn(spanBuilder);
when(spanBuilder.start()).thenReturn(span);
when(tracer.activateSpan(span)).thenReturn(scope);
when(span.context()).thenReturn(spanContext);
when(flowEvent.name()).thenReturn("eventName");
}
Aggregations