use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListServiceMacroDeleteWithPnfTest.
@Test
public void selectExecutionListServiceMacroDeleteWithPnfTest() throws Exception {
String gAction = "deleteInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("aaisi123");
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf();
pnf.setPnfId("pnfId123");
serviceInstanceMSO.getPnfs().add(pnf);
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListServiceMacroAssignTest.
/**
* SERVICE MACRO TESTS
*/
@Test
public void selectExecutionListServiceMacroAssignTest() throws Exception {
String gAction = "assignInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
HeatEnvironment volumeHeatEnv = new HeatEnvironment();
vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
HeatTemplate volumeHeatTemplate = new HeatTemplate();
vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
vfModuleCustomization.setVfModule(vfModule);
VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
HeatEnvironment heatEnvironment = new HeatEnvironment();
vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
HeatTemplate moduleHeatTemplate = new HeatTemplate();
vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
vfModuleCustomization2.setVfModule(vfModule2);
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString())).thenReturn(prepareListWithResources(false, false));
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionUnitTest method createFlowList.
private List<OrchestrationFlow> createFlowList(String... myList) {
List<OrchestrationFlow> result = new ArrayList<>();
for (String name : myList) {
OrchestrationFlow flow = new OrchestrationFlow();
flow.setFlowName(name);
result.add(flow);
}
return result;
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class ExecuteBuildingBlockBuilderTest method buildExecuteBuildingBlockListOrderOfVnf.
private void buildExecuteBuildingBlockListOrderOfVnf(int vnfCount, boolean addPnf, boolean priorities) {
WorkflowResourceIds wfIds = new WorkflowResourceIds();
wfIds.setServiceInstanceId("1");
List<Resource> resources = new ArrayList<>();
Resource r1 = new Resource(WorkflowType.SERVICE, "1", false, null);
resources.add(r1);
for (int i = 0; i < vnfCount; i++) {
Resource r2 = new Resource(WorkflowType.VNF, Integer.toString(2 + i * 3), false, r1);
Resource r3 = new Resource(WorkflowType.VFMODULE, Integer.toString(3 + i * 3), false, r2);
Resource r4 = new Resource(WorkflowType.VFMODULE, Integer.toString(4 + i * 3), false, r2);
r4.setBaseVfModule(true);
resources.add(r2);
resources.add(r3);
resources.add(r4);
if (priorities) {
r2.setProcessingPriority(vnfCount - i);
r3.setProcessingPriority(1);
r4.setProcessingPriority(2);
}
}
if (addPnf) {
Resource r5 = new Resource(WorkflowType.PNF, Integer.toString(5 + (vnfCount - 1) * 3), false, r1);
resources.add(r5);
}
OrchestrationFlow f1 = new OrchestrationFlow();
f1.setFlowName("AssignServiceInstanceBB");
OrchestrationFlow f2 = new OrchestrationFlow();
f2.setFlowName("AssignVnfBB");
OrchestrationFlow f3 = new OrchestrationFlow();
f3.setFlowName("AssignVfModuleBB");
OrchestrationFlow f4 = new OrchestrationFlow();
f4.setFlowName("ControllerExecutionBB");
f4.setBpmnAction("config-assign");
f4.setBpmnScope("vnf");
OrchestrationFlow f5 = new OrchestrationFlow();
f5.setFlowName("AssignPnfBB");
OrchestrationFlow f6 = new OrchestrationFlow();
f6.setFlowName("WaitForPnfReadyBB");
OrchestrationFlow f7 = new OrchestrationFlow();
f7.setFlowName("ControllerExecutionBB");
f7.setBpmnAction("config-assign");
f7.setBpmnScope("pnf");
OrchestrationFlow f8 = new OrchestrationFlow();
f8.setFlowName("ControllerExecutionBB");
f8.setBpmnAction("config-deploy");
f8.setBpmnScope("pnf");
OrchestrationFlow f9 = new OrchestrationFlow();
f9.setFlowName("ActivatePnfBB");
OrchestrationFlow f10 = new OrchestrationFlow();
f10.setFlowName("CreateVfModuleBB");
OrchestrationFlow f11 = new OrchestrationFlow();
f11.setFlowName("ActivateVfModuleBB");
OrchestrationFlow f12 = new OrchestrationFlow();
f12.setFlowName("ControllerExecutionBB");
f12.setBpmnAction("config-deploy");
f12.setBpmnScope("vnf");
OrchestrationFlow f13 = new OrchestrationFlow();
f13.setFlowName("ActivateVnfBB");
OrchestrationFlow f14 = new OrchestrationFlow();
f14.setFlowName("ActivateServiceInstanceBB");
List<OrchestrationFlow> flows = Arrays.asList(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14);
for (int i = 0; i < flows.size(); i++) {
OrchestrationFlow flow = flows.get(i);
flow.setId(i + 1);
flow.setSequenceNumber(i + 1);
flow.setFlowVersion(1.0);
flow.setAction("Service-Macro-Create");
}
List<ExecuteBuildingBlock> flowsToExecute = executeBBBuilder.buildExecuteBuildingBlockList(flows, resources, "1", "1", "1", WorkflowActionConstants.CREATE_INSTANCE, "type", wfIds, null, false);
for (ExecuteBuildingBlock block : flowsToExecute) {
String name = block.getBuildingBlock().getBpmnFlowName();
if (name.equals("ControllerExecutionBB"))
name += " [" + block.getBuildingBlock().getBpmnScope() + ", " + block.getBuildingBlock().getBpmnAction() + "]";
System.out.println(name);
}
assertNotNull(flowsToExecute);
assertEquals((addPnf ? 7 : 2) + vnfCount * 4L + vnfCount * 2L * 3, flowsToExecute.size());
for (ExecuteBuildingBlock block : flowsToExecute) assertNotNull(getResource(resources, block));
if (priorities) {
if (vnfCount > 1)
assertEquals("5", getResource(resources, flowsToExecute.get(1)).getResourceId());
else
assertEquals("3", getResource(resources, flowsToExecute.get(2)).getResourceId());
} else {
if (vnfCount > 1)
assertEquals("2", getResource(resources, flowsToExecute.get(1)).getResourceId());
else
assertEquals("4", getResource(resources, flowsToExecute.get(2)).getResourceId());
}
// AssignVfModuleBB
assertEquals(f3.getFlowName(), flowsToExecute.get(2).getBuildingBlock().getBpmnFlowName());
// ControllerExecutionBB
assertEquals(f4.getFlowName(), flowsToExecute.get(4).getBuildingBlock().getBpmnFlowName());
if (vnfCount > 1) {
// AssignVnfBB
if (addPnf)
assertEquals(f2.getFlowName(), flowsToExecute.get(5).getBuildingBlock().getBpmnFlowName());
else
assertEquals(f2.getFlowName(), flowsToExecute.get(11).getBuildingBlock().getBpmnFlowName());
}
int pnfOffset = -5;
if (addPnf) {
pnfOffset = (vnfCount - 1) * 4;
// AssignPnfBB
assertEquals(f5.getFlowName(), flowsToExecute.get(5 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// WaitForPnfReadyBB
assertEquals(f6.getFlowName(), flowsToExecute.get(6 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ControllerExecutionBB
assertEquals(f7.getFlowName(), flowsToExecute.get(7 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ControllerExecutionBB
assertEquals(f8.getFlowName(), flowsToExecute.get(8 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ActivatePnfBB
assertEquals(f9.getFlowName(), flowsToExecute.get(9 + pnfOffset).getBuildingBlock().getBpmnFlowName());
}
// CreateVfModuleBB
assertEquals(f10.getFlowName(), flowsToExecute.get(10 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ActivateVfModuleBB
assertEquals(f11.getFlowName(), flowsToExecute.get(11 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ControllerExecutionBB
assertEquals(f12.getFlowName(), flowsToExecute.get(14 + pnfOffset).getBuildingBlock().getBpmnFlowName());
// ActivateVnfBB
assertEquals(f13.getFlowName(), flowsToExecute.get(15 + pnfOffset).getBuildingBlock().getBpmnFlowName());
}
Aggregations