Search in sources :

Example 86 with Selectable

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());
}
Also used : ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.Test)

Example 87 with Selectable

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());
}
Also used : ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) Test(org.junit.Test)

Example 88 with Selectable

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());
}
Also used : ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.Test)

Example 89 with Selectable

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);
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.Test)

Example 90 with Selectable

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());
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)283 Test (org.junit.jupiter.api.Test)93 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)48 Map (java.util.Map)47 List (java.util.List)36 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)35 Collectors (java.util.stream.Collectors)35 PollerException (com.dyngr.exception.PollerException)32 PollerStoppedException (com.dyngr.exception.PollerStoppedException)32 UserBreakException (com.dyngr.exception.UserBreakException)32 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)30 Optional (java.util.Optional)30 Set (java.util.Set)30 Bean (org.springframework.context.annotation.Bean)28 Event (reactor.bus.Event)28 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)27 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)27 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)27 Inject (javax.inject.Inject)24 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)23