Search in sources :

Example 1 with DistroXUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactoryTest method testChainQueueForNonReplaceVms.

@Test
public void testChainQueueForNonReplaceVms() {
    ReflectionTestUtils.setField(underTest, "upgradeValidationEnabled", true);
    DistroXUpgradeTriggerEvent event = new DistroXUpgradeTriggerEvent(FlowChainTriggers.DISTROX_CLUSTER_UPGRADE_CHAIN_TRIGGER_EVENT, STACK_ID, imageChangeDto, false, false, "variant");
    FlowTriggerEventQueue flowChainQueue = underTest.createFlowTriggerEventQueue(event);
    assertEquals(4, flowChainQueue.getQueue().size());
    assertUpdateValidationEvent(flowChainQueue);
    assertSaltUpdateEvent(flowChainQueue);
    assertUpgradeEvent(flowChainQueue);
    assertImageUpdateEvent(flowChainQueue);
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) DistroXUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent) Test(org.junit.jupiter.api.Test)

Example 2 with DistroXUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactoryTest method testChainQueueForReplaceVms.

@Test
public void testChainQueueForReplaceVms() {
    ReflectionTestUtils.setField(underTest, "upgradeValidationEnabled", true);
    Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
    when(clusterRepairService.validateRepair(any(), any(), any(), eq(false))).thenReturn(repairStartResult);
    DistroXUpgradeTriggerEvent event = new DistroXUpgradeTriggerEvent(FlowChainTriggers.DISTROX_CLUSTER_UPGRADE_CHAIN_TRIGGER_EVENT, STACK_ID, imageChangeDto, true, true, "variant");
    FlowTriggerEventQueue flowChainQueue = underTest.createFlowTriggerEventQueue(event);
    assertEquals(5, flowChainQueue.getQueue().size());
    assertUpdateValidationEvent(flowChainQueue);
    assertSaltUpdateEvent(flowChainQueue);
    assertUpgradeEvent(flowChainQueue);
    assertImageUpdateEvent(flowChainQueue);
    assertRepairEvent(flowChainQueue);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) DistroXUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 3 with DistroXUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DistroXUpgradeTriggerEvent event) {
    LOGGER.debug("Creating flow trigger event queue for distrox upgrade with event {}", event);
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    createUpgradeValidationEvent(event).ifPresent(flowEventChain::add);
    flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new ClusterUpgradeTriggerEvent(CLUSTER_UPGRADE_INIT_EVENT.event(), event.getResourceId(), event.accepted(), event.getImageChangeDto().getImageId()));
    flowEventChain.add(new StackImageUpdateTriggerEvent(FlowChainTriggers.STACK_IMAGE_UPDATE_TRIGGER_EVENT, event.getImageChangeDto()));
    if (event.isReplaceVms()) {
        Map<String, List<String>> nodeMap = getReplaceableInstancesByHostgroup(event);
        flowEventChain.add(new ClusterRepairTriggerEvent(FlowChainTriggers.CLUSTER_REPAIR_TRIGGER_EVENT, event.getResourceId(), nodeMap, true, event.getTriggeredStackVariant()));
    }
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : ClusterRepairTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterRepairTriggerEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) ClusterUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)

Aggregations

FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)3 DistroXUpgradeTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.DistroXUpgradeTriggerEvent)2 Test (org.junit.jupiter.api.Test)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 ClusterUpgradeTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent)1 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 ClusterRepairTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterRepairTriggerEvent)1 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 Collectors.toList (java.util.stream.Collectors.toList)1