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);
}
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);
}
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);
}
Aggregations