use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveSuccessfulNotRetryableThenValidationShouldPass.
@Test
public void testUpgradeCommandNotActiveSuccessfulNotRetryableThenValidationShouldPass() {
ClusterManagerCommand command = new ClusterManagerCommand();
command.setActive(false);
command.setSuccess(true);
command.setRetryable(false);
when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
assertEquals(FINISH_CLUSTER_UPGRADE_EXISTING_UPGRADE_COMMAND_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail.
@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildNotMatchThenValidationShouldFail() {
ClusterManagerCommand command = new ClusterManagerCommand();
command.setActive(false);
command.setSuccess(false);
command.setRetryable(true);
when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
Map<String, String> parcelNameToVersionMap = Map.of(CDH, "7.2.7-1.cdh7.2.7.p7.12569826");
when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent("23569826"));
assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
String expectedMessage = "Existing upgrade command found for active runtime 7.2.7-1.cdh7.2.7.p7.12569826, upgrading to a different runtime version " + "(7.2.7-23569826) is not allowed! Possible solutions: " + "#1, retry the upgrade with the same target runtime. " + "#2, complete the upgrade manually in Cloudera Manager. " + "#3, recover the cluster";
assertEquals(expectedMessage, ((ClusterUpgradeValidationFailureEvent) nextFlowStepSelector).getException().getMessage());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildMatchThenValidationShouldPass.
@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndActiveRuntimeParcelVersionAndTargetBuildMatchThenValidationShouldPass() {
ClusterManagerCommand command = new ClusterManagerCommand();
command.setActive(false);
command.setSuccess(false);
command.setRetryable(true);
when(clusterStatusService.findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER)).thenReturn(Optional.of(command));
Map<String, String> parcelNameToVersionMap = Map.of(CDH, "7.2.7-1.cdh7.2.7.p7.12569826");
when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent("12569826"));
assertEquals(FINISH_CLUSTER_UPGRADE_EXISTING_UPGRADE_COMMAND_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterUpgradeFreeIpaStatusValidationHandlerTest method testFreeIpaValidationReturnsNotAvailableThenThrowError.
@Test
public void testFreeIpaValidationReturnsNotAvailableThenThrowError() {
when(freeipaService.checkFreeipaRunning(ENV_CRN)).thenReturn(false);
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
assertEquals(FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.selector(), nextFlowStepSelector.selector());
verify(freeipaService).checkFreeipaRunning(ENV_CRN);
verify(stackService).getViewByIdWithoutAuth(STACK_ID);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class DiagnosticsCleanupHandlerTest method testFailureEvent.
@Test
public void testFailureEvent() {
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(CLEANUP_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters(), Set.of(), Set.of(), Set.of());
Selectable result = underTest.defaultFailureEvent(STACK_ID, new IllegalArgumentException("ex"), new Event<>(event));
assertEquals(FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector(), result.selector());
}
Aggregations