use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaMissingAvailabilityStatus.
@ParameterizedTest
@EnumSource(Status.class)
void testFreeIpaMissingAvailabilityStatus(Status status) {
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setStatus(status);
freeipa.setAvailabilityStatus(null);
Optional<DescribeFreeIpaResponse> freeipaOpt = Optional.of(freeipa);
when(freeIpaService.describe(any())).thenReturn(freeipaOpt);
underTest.accept(mockEnvironmentDtoEvent);
verify(freeIpaPollerService, never()).waitForCcmUpgrade(any(), any());
UpgradeCcmFailedEvent capturedUpgradeCcmEvent = (UpgradeCcmFailedEvent) 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("FAILED_UPGRADE_CCM_EVENT");
assertThat(capturedUpgradeCcmEvent.getEnvironmentStatus()).isEqualTo(UPGRADE_CCM_ON_FREEIPA_FAILED);
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActionsTest method failureAction.
@Test
void failureAction() {
EnvironmentDto environmentDto = mock(EnvironmentDto.class);
IllegalStateException failureException = new IllegalStateException(MESSAGE);
UpgradeCcmFailedEvent failedActionPayload = new UpgradeCcmFailedEvent(environmentDto, failureException, EnvironmentStatus.UPGRADE_CCM_FAILED);
when(stateContext.getMessageHeader(MessageFactory.HEADERS.DATA.name())).thenReturn(failedActionPayload);
testUpgradeActionHappyPath(underTest::failedAction, HANDLED_FAILED_UPGRADE_CCM_EVENT.selector());
verify(environmentStatusUpdateService).updateFailedEnvironmentStatusAndNotify(any(), any(), eq(EnvironmentStatus.UPGRADE_CCM_FAILED), eq(ResourceEvent.ENVIRONMENT_UPGRADE_CCM_FAILED), any());
verify(metricService).incrementMetricCounter(eq(MetricType.ENV_UPGRADE_CCM_FAILED), (EnvironmentDto) any(), eq(failureException));
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatahubHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnDatahubHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
// TODO action here
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.FINISH_UPGRADE_CCM_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("FINISH_UPGRADE_CCM_EVENT event sent");
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_DATAHUB_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_ON_DATAHUB_FAILED event sent");
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnFreeIpaHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
freeIpaService.describe(environmentDto.getResourceCrn()).ifPresentOrElse(freeIpa -> {
if (freeIpa.getStatus() == null || freeIpa.getAvailabilityStatus() == null) {
throw new FreeIpaOperationFailedException("FreeIPA status is unpredictable, upgrading of Cluster Connectivity Manager will be interrupted.");
} else if (!freeIpa.getStatus().isCcmUpgradeablePhase()) {
throw new FreeIpaOperationFailedException("FreeIPA is not in a valid state to upgrade Cluster Connectivity Manager. Current state is: " + freeIpa.getStatus().name());
} else {
LOGGER.info("CCM on FreeIPA will be upgraded.");
freeIpaPollerService.waitForCcmUpgrade(environmentDto.getId(), environmentDto.getResourceCrn());
}
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_TUNNEL_UPDATE_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_TUNNEL_UPDATE_EVENT event sent");
}, () -> {
throw new FreeIpaOperationFailedException(String.format("FreeIPA cannot be found for environment %s", environmentDto.getName()));
});
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_ON_FREEIPA_FAILED event sent");
}
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class ValidateUpgradeCcmHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In ValidateUpgradeCcmHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_FREEIPA_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_FREEIPA_EVENT event sent");
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_VALIDATION_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_VALIDATION_FAILED event sent");
}
}
Aggregations