use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class OperationServiceTest method testGetOperationProgressByResourceCrnWithDatalake.
@Test
public void testGetOperationProgressByResourceCrnWithDatalake() {
// GIVEN
ProvisionFlowEventChainFactory provisionFlowEventChainFactory = new ProvisionFlowEventChainFactory();
FlowTriggerEventQueue eventQueue = provisionFlowEventChainFactory.createFlowTriggerEventQueue(new StackEvent(null, null));
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATALAKE, EXPECTED_TYPE_LIST)).willReturn(operationView);
// WHEN
OperationView result = underTest.getOperationProgressByResourceCrn(TEST_DATALAKE_CRN, true);
// THEN
assertEquals(operationView, result);
verify(operationDetailsPopulator, times(1)).createOperationView(operationFlowsView, OperationResource.DATALAKE, EXPECTED_TYPE_LIST);
// Checks that the number of provision flows are the same as in the operation check
assertEquals(eventQueue.getQueue().size(), EXPECTED_TYPE_LIST.size());
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class ClusterRepairFlowEventChainFactoryTest method testRepairOneNodeFromEachHostGroupAtOnce.
@Test
public void testRepairOneNodeFromEachHostGroupAtOnce() {
Stack stack = getStack(MULTIPLE_GATEWAY);
when(stackService.findClustersConnectedToDatalakeByDatalakeStackId(STACK_ID)).thenReturn(Set.of());
HostGroup masterHostGroup = setupHostGroup("hostGroup-master", setupInstanceGroup(InstanceGroupType.GATEWAY));
when(hostGroupService.findHostGroupInClusterByName(anyLong(), eq("hostGroup-master"))).thenReturn(Optional.of(masterHostGroup));
HostGroup coreHostGroup = setupHostGroup("hostGroup-core", setupInstanceGroup(InstanceGroupType.CORE));
when(hostGroupService.findHostGroupInClusterByName(anyLong(), eq("hostGroup-core"))).thenReturn(Optional.of(coreHostGroup));
HostGroup auxiliaryHostGroup = setupHostGroup("hostGroup-auxiliary", setupInstanceGroup(InstanceGroupType.CORE));
when(hostGroupService.findHostGroupInClusterByName(anyLong(), eq("hostGroup-auxiliary"))).thenReturn(Optional.of(auxiliaryHostGroup));
when(entitlementService.isDatalakeZduOSUpgradeEnabled(anyString())).thenReturn(true);
setupStackView();
setupPrimaryGateway();
InstanceMetaData primaryGWInstanceMetadata = new InstanceMetaData();
primaryGWInstanceMetadata.setDiscoveryFQDN("failedNode-FQDN-primary-gateway");
when(instanceMetaDataService.getPrimaryGatewayInstanceMetadata(STACK_ID)).thenReturn(Optional.of(primaryGWInstanceMetadata));
Crn crn = mock(Crn.class);
when(crn.getAccountId()).thenReturn("accountid");
when(stackService.getCrnById(anyLong())).thenReturn(crn);
ClusterRepairTriggerEvent triggerEvent = new TriggerEventBuilder(stack).withFailedPrimaryGateway().withFailedSecondaryGateway().with3FailedCore().withFailedAuxiliary().withOneNodeFromEachHostGroupAtOnce().build();
FlowTriggerEventQueue eventQueues = underTest.createFlowTriggerEventQueue(triggerEvent);
List<String> triggeredOperations = eventQueues.getQueue().stream().map(Selectable::selector).collect(Collectors.toList());
assertEquals(List.of("FLOWCHAIN_INIT_TRIGGER_EVENT", "STACK_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "FULL_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "FULL_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "RESCHEDULE_STATUS_CHECK_TRIGGER_EVENT", "FLOWCHAIN_FINALIZE_TRIGGER_EVENT"), triggeredOperations);
Set<String> downscaledMasterHosts = new HashSet<>();
Set<String> downscaledCoreHosts = new HashSet<>();
Set<String> downscaledAuxHosts = new HashSet<>();
Set<String> upscaledMasterHosts = new HashSet<>();
Set<String> upscaledCoreHosts = new HashSet<>();
Set<String> upscaledAuxHosts = new HashSet<>();
eventQueues.getQueue().remove();
StackDownscaleTriggerEvent downscale1 = (StackDownscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> firstDownscaledHostsInMaster = downscale1.getHostGroupsWithHostNames().get("hostGroup-master");
assertEquals(1, firstDownscaledHostsInMaster.size());
String firstDownscaledMasterHost = firstDownscaledHostsInMaster.iterator().next();
downscaledMasterHosts.add(firstDownscaledMasterHost);
assertEquals("failedNode-FQDN-primary-gateway", firstDownscaledMasterHost);
Set<String> firstDownscaledHostsInCore = downscale1.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, firstDownscaledHostsInCore.size());
String firstDownscaleCoreHost = firstDownscaledHostsInCore.iterator().next();
downscaledCoreHosts.add(firstDownscaleCoreHost);
Set<String> firstDownscaledHostsInAux = downscale1.getHostGroupsWithHostNames().get("hostGroup-auxiliary");
assertEquals(1, firstDownscaledHostsInAux.size());
String downscaledAuxHost = firstDownscaledHostsInAux.iterator().next();
downscaledAuxHosts.add(downscaledAuxHost);
StackAndClusterUpscaleTriggerEvent upscale1 = (StackAndClusterUpscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> firstUpscaledHostsInMaster = upscale1.getHostGroupsWithHostNames().get("hostGroup-master");
assertEquals(1, firstUpscaledHostsInMaster.size());
String firstUpscaledMasterHost = firstUpscaledHostsInMaster.iterator().next();
assertEquals("failedNode-FQDN-primary-gateway", firstUpscaledMasterHost);
upscaledMasterHosts.add(firstUpscaledMasterHost);
Set<String> firstUpscaledHostsInCore = upscale1.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, firstUpscaledHostsInCore.size());
upscaledCoreHosts.add(firstUpscaledHostsInCore.iterator().next());
Set<String> firstUpscaledHostsInAux = upscale1.getHostGroupsWithHostNames().get("hostGroup-auxiliary");
assertEquals(1, firstUpscaledHostsInAux.size());
upscaledAuxHosts.add(firstUpscaledHostsInAux.iterator().next());
ClusterAndStackDownscaleTriggerEvent downscale2 = (ClusterAndStackDownscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> secondDownscaledHostsInMaster = downscale2.getHostGroupsWithHostNames().get("hostGroup-master");
assertEquals(1, secondDownscaledHostsInMaster.size());
String secondDownscaledMasterHost = secondDownscaledHostsInMaster.iterator().next();
downscaledMasterHosts.add(secondDownscaledMasterHost);
assertEquals("failedNode-FQDN-secondary-gateway", secondDownscaledMasterHost);
Set<String> secondDownscaledHostsInCore = downscale2.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, secondDownscaledHostsInCore.size());
String secondDownscaleCoreHost = secondDownscaledHostsInCore.iterator().next();
downscaledCoreHosts.add(secondDownscaleCoreHost);
StackAndClusterUpscaleTriggerEvent upscale2 = (StackAndClusterUpscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> secondUpscaledHostsInMaster = upscale2.getHostGroupsWithHostNames().get("hostGroup-master");
assertEquals(1, secondUpscaledHostsInMaster.size());
String secondUpscaledMasterHost = secondUpscaledHostsInMaster.iterator().next();
assertEquals("failedNode-FQDN-secondary-gateway", secondUpscaledMasterHost);
upscaledMasterHosts.add(secondUpscaledMasterHost);
Set<String> secondUpscaledHostsInCore = upscale2.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, secondUpscaledHostsInCore.size());
upscaledCoreHosts.add(secondUpscaledHostsInCore.iterator().next());
ClusterAndStackDownscaleTriggerEvent downscale3 = (ClusterAndStackDownscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> thirdDownscaledHostsInCore = downscale3.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, thirdDownscaledHostsInCore.size());
String thirdDownscaleCoreHost = thirdDownscaledHostsInCore.iterator().next();
downscaledCoreHosts.add(thirdDownscaleCoreHost);
StackAndClusterUpscaleTriggerEvent upscale3 = (StackAndClusterUpscaleTriggerEvent) eventQueues.getQueue().poll();
Set<String> thirdUpscaledHostsInCore = upscale3.getHostGroupsWithHostNames().get("hostGroup-core");
assertEquals(1, thirdUpscaledHostsInCore.size());
upscaledCoreHosts.add(thirdUpscaledHostsInCore.iterator().next());
assertThat(downscaledCoreHosts, containsInAnyOrder("core1", "core2", "core3"));
assertThat(downscaledMasterHosts, containsInAnyOrder(FAILED_NODE_FQDN_PRIMARY_GATEWAY, FAILED_NODE_FQDN_SECONDARY_GATEWAY));
assertThat(downscaledAuxHosts, containsInAnyOrder("aux1"));
assertThat(upscaledCoreHosts, containsInAnyOrder("core1", "core2", "core3"));
assertThat(upscaledMasterHosts, containsInAnyOrder(FAILED_NODE_FQDN_PRIMARY_GATEWAY, FAILED_NODE_FQDN_SECONDARY_GATEWAY));
assertThat(upscaledAuxHosts, containsInAnyOrder("aux1"));
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class ClusterRepairFlowEventChainFactoryTest method testRepairSingleGatewayWithAttached.
@Test
public void testRepairSingleGatewayWithAttached() {
Stack stack = getStack(NOT_MULTIPLE_GATEWAY);
when(stackService.findClustersConnectedToDatalakeByDatalakeStackId(STACK_ID)).thenReturn(Set.of(ATTACHED_WORKLOAD));
setupStackView();
setupHostGroup(true);
FlowTriggerEventQueue eventQueues = underTest.createFlowTriggerEventQueue(new TriggerEventBuilder(stack).withFailedPrimaryGateway().build());
List<String> triggeredOperations = eventQueues.getQueue().stream().map(Selectable::selector).collect(Collectors.toList());
assertEquals(List.of("FLOWCHAIN_INIT_TRIGGER_EVENT", "STACK_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "RESCHEDULE_STATUS_CHECK_TRIGGER_EVENT", "FLOWCHAIN_FINALIZE_TRIGGER_EVENT"), triggeredOperations);
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class ProvisionFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackEvent event) {
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new StackEvent(StackProvisionEvent.START_CREATION_EVENT.event(), event.getResourceId(), event.accepted()));
flowEventChain.add(new StackEvent(FreeIpaProvisionEvent.FREEIPA_PROVISION_EVENT.event(), event.getResourceId()));
return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class UpgradeCcmFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(UpgradeCcmFlowChainTriggerEvent event) {
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new UpgradeCcmTriggerEvent(UpgradeCcmStateSelector.UPGRADE_CCM_TRIGGER_EVENT.event(), event.getOperationId(), event.getResourceId(), event.getOldTunnel(), event.accepted()).withIsChained(true).withIsFinal(false));
flowEventChain.add(new UserDataUpdateRequest(UpdateUserDataEvents.UPDATE_USERDATA_TRIGGER_EVENT.event(), event.getResourceId(), event.getOldTunnel()).withOperationId(event.getOperationId()).withIsChained(true).withIsFinal(true));
return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Aggregations