use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatalakeHandlerTest method testAcceptWhenUpgradeError.
@Test
void testAcceptWhenUpgradeError() {
SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.ERROR, new FlowIdentifier(FlowType.FLOW, "flowId"), "reason", "datalakeCrn");
when(sdxService.upgradeCcm(TEST_ENV_CRN)).thenReturn(response);
underTest.accept(mockEnvironmentDtoEvent);
verify(sdxUpgradeCcmPollerService, never()).waitForUpgradeCcm(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_DATALAKE_FAILED);
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaWrongStatuses.
@ParameterizedTest
@EnumSource(value = Status.class, names = { "AVAILABLE", "UPGRADE_CCM_FAILED" }, mode = EnumSource.Mode.EXCLUDE)
void testFreeIpaWrongStatuses(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, 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 UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaDoesNotExist.
@Test
void testFreeIpaDoesNotExist() {
when(freeIpaService.describe(any())).thenReturn(Optional.empty());
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 UpgradeCcmTunnelUpdateHandlerTest method acceptFailure.
@Test
void acceptFailure() {
when(environmentService.updateTunnelByEnvironmentId(any(), any())).thenThrow(new RuntimeException("internal error"));
underTest.accept(mockEnvironmentDtoEvent);
verify(environmentService).updateTunnelByEnvironmentId(TEST_ENV_ID, Tunnel.latestUpgradeTarget());
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_TUNNEL_UPDATE_FAILED);
}
use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method failedAction.
@Bean(name = "UPGRADE_CCM_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmFailedEvent.class) {
@Override
protected void doExecute(CommonContext context, UpgradeCcmFailedEvent payload, Map<Object, Object> variables) {
LOGGER.error(String.format("Failed to upgrade CCM in environment '%s'. Status: '%s'.", payload.getEnvironmentDto(), payload.getEnvironmentStatus()), payload.getException());
EnvironmentDto environmentDto = environmentStatusUpdateService.updateFailedEnvironmentStatusAndNotify(context, payload, payload.getEnvironmentStatus(), convertStatus(payload.getEnvironmentStatus()), UpgradeCcmState.UPGRADE_CCM_FAILED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_UPGRADE_CCM_FAILED, environmentDto, payload.getException());
sendEvent(context, HANDLED_FAILED_UPGRADE_CCM_EVENT.event(), payload);
}
private ResourceEvent convertStatus(EnvironmentStatus status) {
switch(status) {
case UPGRADE_CCM_VALIDATION_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_VALIDATION_FAILED;
case UPGRADE_CCM_TUNNEL_UPDATE_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_TUNNEL_UPDATE_FAILED;
case UPGRADE_CCM_ON_FREEIPA_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_FREEIPA_FAILED;
case UPGRADE_CCM_ON_DATALAKE_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_DATALAKE_FAILED;
case UPGRADE_CCM_ON_DATAHUB_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_DATAHUB_FAILED;
default:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_FAILED;
}
}
};
}
Aggregations