Search in sources :

Example 81 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ClusterRepairFlowEventChainFactoryTest method testAddAwsNativeMigrationIfNeedWhenNotUpgrade.

@Test
public void testAddAwsNativeMigrationIfNeedWhenNotUpgrade() {
    Queue<Selectable> flowTriggers = new ConcurrentLinkedDeque<>();
    String groupName = "groupName";
    boolean upgrade = false;
    String variant = "variant";
    underTest.addAwsNativeEventMigrationIfNeed(flowTriggers, STACK_ID, groupName, upgrade, variant);
    Assertions.assertTrue(flowTriggers.isEmpty());
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) Test(org.junit.Test)

Example 82 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactoryTest method assertUpdateValidationEvent.

private void assertUpdateValidationEvent(FlowTriggerEventQueue flowChainQueue) {
    Selectable upgradeValidationEvent = flowChainQueue.getQueue().remove();
    assertEquals(START_CLUSTER_UPGRADE_VALIDATION_INIT_EVENT.event(), upgradeValidationEvent.selector());
    assertEquals(STACK_ID, upgradeValidationEvent.getResourceId());
    assertTrue(upgradeValidationEvent instanceof ClusterUpgradeValidationTriggerEvent);
    assertEquals(imageChangeDto.getImageId(), ((ClusterUpgradeValidationTriggerEvent) upgradeValidationEvent).getImageId());
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)

Example 83 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class CmSyncHandlerTest method testAcceptWhenSuccess.

@Test
void testAcceptWhenSuccess() {
    Set<String> candidateImageUuids = Set.of(IMAGE_UUID_1);
    HandlerEvent<CmSyncRequest> event = getCmSyncRequestHandlerEvent(candidateImageUuids);
    Stack stack = new Stack();
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    Set<Image> foundImages = Set.of(mock(Image.class));
    when(cmSyncImageCollectorService.collectImages(USER_CRN, stack, candidateImageUuids)).thenReturn(foundImages);
    CmSyncOperationStatus cmSyncOperationStatus = CmSyncOperationStatus.builder().withSuccess("").build();
    CmSyncOperationSummary cmSyncOperationSummary = new CmSyncOperationSummary(cmSyncOperationStatus);
    when(cmSyncerService.syncFromCmToDb(stack, foundImages)).thenReturn(cmSyncOperationSummary);
    Selectable result = underTest.doAccept(event);
    assertEquals("CMSYNCRESULT", result.selector());
    verify(stackService).getByIdWithListsInTransaction(STACK_ID);
    verify(cmSyncImageCollectorService).collectImages(USER_CRN, stack, candidateImageUuids);
    verify(cmSyncerService).syncFromCmToDb(stack, foundImages);
}
Also used : CmSyncOperationStatus(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus) CmSyncRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CmSyncOperationSummary(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 84 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ClusterUpgradeDiskSpaceValidationHandlerTest method testHandlerToRetrieveTheImageFromTheCurrentImageCatalog.

@Test
public void testHandlerToRetrieveTheImageFromTheCurrentImageCatalog() {
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    Selectable nextFlowStepSelector = underTest.doAccept(createEvent());
    assertEquals(FINISH_CLUSTER_UPGRADE_DISK_SPACE_VALIDATION_EVENT.name(), nextFlowStepSelector.selector());
    verify(stackService).getByIdWithListsInTransaction(STACK_ID);
    verify(diskSpaceValidationService).validateFreeSpaceForUpgrade(stack, REQUIRED_FREE_SPACE);
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.Test)

Example 85 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method testUpgradeCommandNotActiveNotSuccessfulRetryableAndEmptyactiveRuntimeParcelVersionThenValidationShouldPass.

@Test
public void testUpgradeCommandNotActiveNotSuccessfulRetryableAndEmptyactiveRuntimeParcelVersionThenValidationShouldPass() {
    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();
    when(connector.gatherInstalledParcels(STACK_NAME)).thenReturn(parcelNameToVersionMap);
    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)

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