diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2020-02-28 08:26:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-28 08:26:00 +0000 |
commit | a9e3132226baa83fdf1c5f05ddd30017b6d1b3f9 (patch) | |
tree | d1a913d541f58d110984cb8c8f20963a458d1e59 | |
parent | 193879d40aaf11af615ff4daffbf4c17caaa6227 (diff) | |
parent | ca5b7107f23562bf81267292a47d7fb2f30ebaf9 (diff) |
Merge "SW UP building block and workflow"
28 files changed, 1650 insertions, 43 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index ebced8e933..51b1a218c8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -58,7 +58,7 @@ public class AbstractCDSProcessingBBUtils { private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; private static final String RESPONSE_PAYLOAD = "CDSResponsePayload"; - private static final String CDS_STATUS = "CDSStatus"; + private static final String CDS_STATUS = "ControllerStatus"; private static final String EXEC_INPUT = "executionServiceInput"; private static final String EXECUTION_OBJECT = "executionObject"; private static final String EXCEPTION = "Exception"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java index 24962a0c14..998976589c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java @@ -55,7 +55,7 @@ public class GeneratePayloadForCdsTest { private static final String VF_SCOPE = "vfModule"; private static final String ASSIGN_ACTION = "configAssign"; private static final String DEPLOY_ACTION = "configDeploy"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; private static final String MSO_REQUEST_ID = "1234"; private static final String BUILDING_BLOCK = "buildingBlock"; private static final String PUBLIC_NET_ID = "public-net-id"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java index e5cbc9a369..88559280b6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java @@ -40,8 +40,8 @@ public class PnfCDSRequestProviderTest { @InjectMocks private PnfCDSRequestProvider pnfCDSRequestProvider; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28"; private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id"; private static final String TEST_PROCESS_KEY = "processKey1"; diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index f9db93e3f7..80fd3eede4 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -58,6 +58,12 @@ public class PnfManagementTestImpl implements PnfManagement { serviceAndPnfRelationMap.put(serviceInstanceId, pnfName); } + @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) { + created.put(pnfCorrelationId, entry); + } + + public Map<String, Pnf> getCreated() { return created; } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn index 11d77bf97a..88e5eadef2 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn @@ -12,7 +12,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -34,7 +34,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("CDSStatus").equals("Success")}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("ControllerStatus").equals("Success")}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn index 92ac5f9f5b..3993eca467 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -18,7 +18,7 @@ <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="executionObject" target="executionObject" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming> <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing> @@ -39,7 +39,7 @@ <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" /> <bpmn:endEvent id="EndEvent_0wwnq4u"> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index 32d3bce469..279fdc0983 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -13,7 +13,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -35,7 +35,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java new file mode 100644 index 0000000000..4482d2a327 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -0,0 +1,165 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; + +/** + * This implementation of {@link JavaDelegate} is used to populate the execution object for pnf software upgrade + */ +@Component +public class NfSoftwareUpgradeDispatcher implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid"; + private static final String PNF_NAME = "pnfName"; + + // ERROR CODE for variable not found in the delegation Context + private static final int ERROR_CODE = 601; + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName(); + final String pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME); + final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid(); + final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams(); + final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName); + final List<PnfResourceCustomization> pnfCustomizations = + getPnfResourceCustomizations(delegateExecution, serviceModelUuid); + final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + + populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, + pnfName, serviceModelUuid, userParams); + + logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue( + JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, + PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, + String serviceModelUuid, List<Map<String, Object>> userParams) { + + delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); + delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); + delegateExecution.setVariable(PNF_CORRELATION_ID, pnfName); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + delegateExecution.setVariable(PNF_UUID, pnf.getPnfId()); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(RESOURCE_CUSTOMIZATION_UUID_PARAM, + pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor()); + + for (Map<String, Object> param : userParams) { + if (param.containsKey("name") && param.containsKey("value")) { + delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); + } + } + } + + private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { + Optional<Pnf> pnfOptional = null; + try { + pnfOptional = pnfManagement.getEntryFor(pnfName); + } catch (IOException e) { + logger.warn(e.getMessage(), e); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to fetch from AAI" + e.getMessage()); + } + if (pnfOptional == null || !pnfOptional.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "AAI entry for PNF: " + pnfName + " does not exist"); + } + return pnfOptional.get(); + } + + private List<PnfResourceCustomization> getPnfResourceCustomizations(DelegateExecution delegateExecution, + String serviceModelUuid) { + List<PnfResourceCustomization> pnfCustomizations = + catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid); + + if (pnfCustomizations == null || pnfCustomizations.isEmpty()) { + logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + return pnfCustomizations; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + logger.warn("Unable to find the parameter: {} in the execution context", param); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find parameter " + param); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java new file mode 100644 index 0000000000..f85be8aab7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@Component +public class UpdatePnfEntryInAai implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(UpdatePnfEntryInAai.class); + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Override + public void execute(DelegateExecution execution) throws Exception { + String pnfCorrelationId = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + Optional<Pnf> pnfAaiEntry = pnfManagement.getEntryFor(pnfCorrelationId); + + if (!pnfAaiEntry.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(execution, 404, + "AAI entry for PNF: " + PNF_CORRELATION_ID + " does not exist"); + } + + Pnf pnf = pnfAaiEntry.get(); + String pnfSoftwareVersion = String.valueOf(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)); + pnf.setSwVersion(pnfSoftwareVersion); + + pnfManagement.updateEntry(pnfCorrelationId, pnf); + logger.debug("AAI entry is updated for pnf correlation id: {}, pnf uuid: {} with swVersion: {}", + pnf.getPnfName(), pnfCorrelationId, pnfSoftwareVersion); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java index 9e720fe0a4..46937d0d8c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java @@ -30,5 +30,7 @@ public interface PnfManagement { void createEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index b1af8b1e0b..e6df8070a3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -44,6 +44,11 @@ public class PnfManagementImpl implements PnfManagement { restClient.createPnf(pnfCorrelationId, entry); } + public void updateEntry(String pnfCorrelationId, Pnf entry) { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + restClient.updatePnf(pnfCorrelationId, entry); + } + @Override public void createRelation(String serviceInstanceId, String pnfName) { AAIResourceUri serviceInstanceURI = diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java new file mode 100644 index 0000000000..3c568ffc83 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.RequestParameters; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.IOException; +import java.util.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@RunWith(SpringJUnit4ClassRunner.class) +public class NfSoftwareUpgradeDispatcherTest { + + private static final String TEST_PROCESS_KEY = "processKey1"; + private static final String PROCESS_KEY = "testProcessKey"; + private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1"; + private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144"; + private static final String TEST_PNF_CORRELATION_ID = "PNFDemo"; + private static final String TEST_PNF_UUID = "FakeID"; + private static final String TEST_PRC_CONTROLLER_ACTOR = "cds"; + private static final String TEST_TARGET_SOFTWARE_VERSION = "demo-sw-ver2.0.0"; + + private static final String TEST_BPMN_REQUEST = "{\"requestDetails\":{" + "\"requestInfo\":{" + + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"demo\"," + + "\"productFamilyId\":\"SWUPid\"}," + "\"modelInfo\":{" + + "\"modelType\":\"service\",\"modelInvariantUuid\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelInvariantId\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelUuid\":\"42daaac6-5017-4e1e-96c8-6a27dfbe1421\",\"modelName\":\"PNF_int_service_2\"," + + "\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[{\"name\":\"aic_zone\"," + + "\"value\":\"nova\"},{\"name\":\"pnfId\",\"value\":\"PNFDemo\"},{\"name\":\"targetSoftwareVersion\",\"value\":\"demo-sw-ver2.0.0\"}]," + + "\"subscriptionServiceType\":\"SWUP\",\"aLaCarte\":false,\"pnfCorrelationId\":\"PNFDemo\"}," + + "\"cloudConfiguration\":{\"lcpCloudRegionId\":\"regionOne\",\"tenantId\":\"09a63533072f4a579d5c99c3b8fe94c6\"}," + + "\"subscriberInfo\":{\"globalSubscriberId\":\"ADemoCustomerInEric\"},\"project\":{\"projectName\":\"Project-Demonstration\"}," + + "\"owningEntity\":{\"owningEntityId\":\"5eae949c-1c50-4780-b8b5-7cbeb08856b4\",\"owningEntityName\":\"OE-Demonstration\"}}}"; + /** + * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO. + */ + private static final String TEST_MODEL_UUID = "42daaac6-5017-4e1e-96c8-6a27dfbe1421"; + + @InjectMocks + private NfSoftwareUpgradeDispatcher nfSoftwareUpgradeDispatcher; + + @Mock + private PnfManagement pnfManagement; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private ObjectMapper mapper; + + private DelegateExecution execution = new DelegateExecutionFake(); + + @Before + public void setUp() throws IOException { + List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>(); + pnfResourceCustomizations.add(buildPnfResourceCustomization()); + given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID)) + .willReturn(pnfResourceCustomizations); + execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY); + execution.setVariable("bpmnRequest", TEST_BPMN_REQUEST); + mockMapper(); + mockAai(); + + } + + + @Test + public void testExecution_validCatalogDb_skipVariableSet() { + try { + nfSoftwareUpgradeDispatcher.execute(execution); + assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID); + assertThat(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)).isEqualTo(TEST_TARGET_SOFTWARE_VERSION); + assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME); + assertThat(execution.getVariable(PNF_CORRELATION_ID)).isEqualTo(TEST_PNF_CORRELATION_ID); + assertThat(execution.getVariable(PNF_UUID)).isEqualTo(TEST_PNF_UUID); + assertThat(execution.getVariable(PRC_CONTROLLER_ACTOR)).isEqualTo(TEST_PRC_CONTROLLER_ACTOR); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception thrown" + e.getMessage()); + } + } + + private void mockAai() throws IOException { + Pnf pnf = new Pnf(); + pnf.setPnfId(TEST_PNF_UUID); + when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf)); + } + + private PnfResourceCustomization buildPnfResourceCustomization() { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setSkipPostInstConf(true); + pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME); + pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + pnfResourceCustomization.setControllerActor(TEST_PRC_CONTROLLER_ACTOR); + return pnfResourceCustomization; + } + + private void mockMapper() throws IOException { + RequestDetails bpmnRequestDetails = new RequestDetails(); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("demo"); + bpmnRequestDetails.setRequestInfo(requestInfo); + + RequestParameters requestParameters = new RequestParameters(); + List<Map<String, Object>> userParams = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("name", "targetSoftwareVersion"); + map.put("value", TEST_TARGET_SOFTWARE_VERSION); + userParams.add(map); + map = new HashMap<>(); + map.put("name", "pnfName"); + map.put("value", "PNFDemo"); + userParams.add(map); + requestParameters.setUserParams(userParams); + + bpmnRequestDetails.setRequestParameters(requestParameters); + + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantUuid("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelInvariantId("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelUuid("42daaac6-5017-4e1e-96c8-6a27dfbe1421"); + modelInfo.setModelName("PNF_int_service_2"); + modelInfo.setModelVersion("1.0"); + + bpmnRequestDetails.setModelInfo(modelInfo); + + + doReturn(bpmnRequestDetails).when(mapper).readValue( + JsonUtils.getJsonValue(String.valueOf(execution.getVariable("bpmnRequest")), "requestDetails"), + RequestDetails.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 8577d9555b..b93902d9f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -50,6 +50,11 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + created.put(pnfCorrelationId, entry); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) {} public Map<String, Pnf> getCreated() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java index f9b467c650..77377db9d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -38,6 +38,11 @@ public class PnfManagementThrowingException implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + throw new IOException(); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) throws IOException { throw new IOException(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java new file mode 100644 index 0000000000..bddfe5b180 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.*; +import java.io.IOException; +import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + +@RunWith(SpringJUnit4ClassRunner.class) +public class UpdatePnfEntryInAaiTest { + + @InjectMocks + private UpdatePnfEntryInAai updatePnfEntryInAai; + + @Mock + private PnfManagement pnfManagementTest; + + private DelegateExecution execution; + + + + @Test + public void shouldSetSwVersion() throws Exception { + // given + setupPnf(); + setupExecution(); + + // when + updatePnfEntryInAai.execute(execution); + + // verify + Optional<Pnf> modifiedEntry = pnfManagementTest.getEntryFor("testPnfCorrelationId"); + assertNotNull(modifiedEntry.get()); + assertThat(modifiedEntry.get().getPnfId()).isEqualTo("testtest"); + assertThat(modifiedEntry.get().getPnfName()).isEqualTo("testPnfCorrelationId"); + assertThat(modifiedEntry.get().getSwVersion()).isEqualTo("demo-1.2"); + verify(pnfManagementTest, times(2)).getEntryFor(anyString()); + } + + private void setupPnf() { + try { + Pnf pnf = new Pnf(); + pnf.setSwVersion("1"); + pnf.setPnfId("testtest"); + pnf.setPnfName("testPnfCorrelationId"); + doReturn(Optional.of(pnf)).when(pnfManagementTest).getEntryFor(anyString()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void setupExecution() { + execution = mock(DelegateExecution.class); + given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId"); + given(execution.getVariable(eq(PNF_UUID))).willReturn("testtest"); + given(execution.getVariable(eq(PRC_TARGET_SOFTWARE_VERSION))).willReturn("demo-1.2"); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn index 693dd922e2..234c744e4a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn @@ -22,7 +22,7 @@ <bpmn:outgoing>SequenceFlow_1w4p9f7</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1owbpsy" name="Success" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="Task_14cwhgk"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_01jwwmc" default="SequenceFlow_0d24h26"> <bpmn:incoming>SequenceFlow_02919fh</bpmn:incoming> @@ -30,7 +30,7 @@ <bpmn:outgoing>SequenceFlow_0d24h26</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1n080up" name="Success" sourceRef="ExclusiveGateway_01jwwmc" targetRef="EndEvent_0xky46v"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1w4p9f7" name="Failure" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="EndEvent_16620h9" /> <bpmn:endEvent id="EndEvent_16620h9"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn new file mode 100644 index 0000000000..24ca7104a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSWUPDownload" name="PNFSWUPDownload" isExecutable="true"> + <bpmn:startEvent id="download_StartEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1fdclh0</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_1mpt2eq" name="NF Download Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1fdclh0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12155q6</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="download_EndEvent" name="End"> + <bpmn:incoming>SequenceFlow_1d2rfyx</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_1kiurmf" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ja7grm" default="SequenceFlow_078xmlz"> + <bpmn:incoming>SequenceFlow_0o6b6a8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_078xmlz</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0qznt4u</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1j64ij1"> + <bpmn:incoming>SequenceFlow_078xmlz</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0b3kbjs" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1rj84ne" default="SequenceFlow_1tfbzn1"> + <bpmn:incoming>SequenceFlow_1ccldpp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0s6i4o9</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1tfbzn1</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ubpef4"> + <bpmn:incoming>SequenceFlow_1tfbzn1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0wevx6s" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_08lusga" default="SequenceFlow_1gawssm"> + <bpmn:incoming>SequenceFlow_1kaikh5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1d2rfyx</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1gawssm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_11hee4g"> + <bpmn:incoming>SequenceFlow_1gawssm</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_12tyzwb" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:serviceTask id="ServiceTask_0yavde3" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0s6i4o9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6b6a8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1wxo7xz" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0qznt4u</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1kaikh5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1nl90ao" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12155q6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ccldpp</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1fdclh0" sourceRef="download_StartEvent" targetRef="ServiceTask_1mpt2eq" /> + <bpmn:sequenceFlow id="SequenceFlow_12155q6" sourceRef="ServiceTask_1mpt2eq" targetRef="ServiceTask_1nl90ao" /> + <bpmn:sequenceFlow id="SequenceFlow_1d2rfyx" name="Success" sourceRef="ExclusiveGateway_08lusga" targetRef="download_EndEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0o6b6a8" sourceRef="ServiceTask_0yavde3" targetRef="ExclusiveGateway_1ja7grm" /> + <bpmn:sequenceFlow id="SequenceFlow_078xmlz" name="Failure" sourceRef="ExclusiveGateway_1ja7grm" targetRef="EndEvent_1j64ij1" /> + <bpmn:sequenceFlow id="SequenceFlow_1ccldpp" sourceRef="ServiceTask_1nl90ao" targetRef="ExclusiveGateway_1rj84ne" /> + <bpmn:sequenceFlow id="SequenceFlow_0s6i4o9" name="Success" sourceRef="ExclusiveGateway_1rj84ne" targetRef="ServiceTask_0yavde3"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1tfbzn1" name="Failure" sourceRef="ExclusiveGateway_1rj84ne" targetRef="EndEvent_1ubpef4" /> + <bpmn:sequenceFlow id="SequenceFlow_1kaikh5" sourceRef="ServiceTask_1wxo7xz" targetRef="ExclusiveGateway_08lusga" /> + <bpmn:sequenceFlow id="SequenceFlow_1gawssm" name="Failure" sourceRef="ExclusiveGateway_08lusga" targetRef="EndEvent_11hee4g" /> + <bpmn:sequenceFlow id="SequenceFlow_0qznt4u" name="Success" sourceRef="ExclusiveGateway_1ja7grm" targetRef="ServiceTask_1wxo7xz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmn:error id="Error_1q14dnd" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSWUPDownload"> + <bpmndi:BPMNShape id="StartEvent_1k8gssq_di" bpmnElement="download_StartEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1mpt2eq_di" bpmnElement="ServiceTask_1mpt2eq"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1e4dq7w_di" bpmnElement="download_EndEvent"> + <dc:Bounds x="1312" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1321" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1ja7grm_di" bpmnElement="ExclusiveGateway_1ja7grm" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1j64ij1_di" bpmnElement="EndEvent_1j64ij1"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1rj84ne_di" bpmnElement="ExclusiveGateway_1rj84ne" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ubpef4_di" bpmnElement="EndEvent_1ubpef4"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_08lusga_di" bpmnElement="ExclusiveGateway_08lusga" isMarkerVisible="true"> + <dc:Bounds x="1155" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_11hee4g_di" bpmnElement="EndEvent_11hee4g"> + <dc:Bounds x="1162" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0yavde3_di" bpmnElement="ServiceTask_0yavde3"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1wxo7xz_di" bpmnElement="ServiceTask_1wxo7xz"> + <dc:Bounds x="1000" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1nl90ao_di" bpmnElement="ServiceTask_1nl90ao"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1fdclh0_di" bpmnElement="SequenceFlow_1fdclh0"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12155q6_di" bpmnElement="SequenceFlow_12155q6"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1d2rfyx_di" bpmnElement="SequenceFlow_1d2rfyx"> + <di:waypoint x="1205" y="120" /> + <di:waypoint x="1312" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1214" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o6b6a8_di" bpmnElement="SequenceFlow_0o6b6a8"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_078xmlz_di" bpmnElement="SequenceFlow_078xmlz"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ccldpp_di" bpmnElement="SequenceFlow_1ccldpp"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0s6i4o9_di" bpmnElement="SequenceFlow_0s6i4o9"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tfbzn1_di" bpmnElement="SequenceFlow_1tfbzn1"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1kaikh5_di" bpmnElement="SequenceFlow_1kaikh5"> + <di:waypoint x="1100" y="120" /> + <di:waypoint x="1155" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gawssm_di" bpmnElement="SequenceFlow_1gawssm"> + <di:waypoint x="1180" y="145" /> + <di:waypoint x="1180" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1178" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qznt4u_di" bpmnElement="SequenceFlow_0qznt4u"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1000" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="951" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn new file mode 100644 index 0000000000..8d59dac8ac --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSoftwareUpgrade" name="PNFSoftwareUpgrade" isExecutable="true"> + <bpmn:startEvent id="softwareUpgrade_startEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_042uz7n" name="NF Upgrade Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1ng4b6l</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12ejx4m</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_12ejx4m" sourceRef="ServiceTask_042uz7n" targetRef="ServiceTask_0slpahe" /> + <bpmn:endEvent id="softwareUpgrade_endEvent" name="End"> + <bpmn:incoming>SequenceFlow_1atiydu</bpmn:incoming> + <bpmn:terminateEventDefinition /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ng4b6l" sourceRef="softwareUpgrade_startEvent" targetRef="ServiceTask_042uz7n" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0v3l3wv" default="SequenceFlow_1lr7vgu"> + <bpmn:incoming>SequenceFlow_0cchgih</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1lr7vgu</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1eljvek</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0bnbfds"> + <bpmn:incoming>SequenceFlow_1lr7vgu</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1sjbsm2" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_0x6h0ni" default="SequenceFlow_0piri91"> + <bpmn:incoming>SequenceFlow_0j26xlx</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1nsmyr5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0piri91</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1nsmyr5" name="Success" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="ServiceTask_0x5cje8"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_180lm4y"> + <bpmn:incoming>SequenceFlow_0piri91</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0fm5he7" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0piri91" name="Failure" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="EndEvent_180lm4y" /> + <bpmn:sequenceFlow id="SequenceFlow_1lr7vgu" name="Failure" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="EndEvent_0bnbfds" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ch3fef" default="SequenceFlow_0dqnb6c"> + <bpmn:incoming>SequenceFlow_015y785</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dqnb6c</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0eiif6e</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ms4wdz"> + <bpmn:incoming>SequenceFlow_0dqnb6c</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_15s8fgk" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0dqnb6c" name="Failure" sourceRef="ExclusiveGateway_0ch3fef" targetRef="EndEvent_1ms4wdz" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ny9b1z" default="SequenceFlow_1p0axph"> + <bpmn:incoming>SequenceFlow_0g3qcd0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1p0axph</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1atiydu</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0l6n6x5"> + <bpmn:incoming>SequenceFlow_1p0axph</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1l0gsy0" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1p0axph" name="Failure" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="EndEvent_0l6n6x5" /> + <bpmn:sequenceFlow id="SequenceFlow_1eljvek" name="Success" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="ServiceTask_02lxf48"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1atiydu" name="Success" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="softwareUpgrade_endEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0eiif6e" name="Success" sourceRef="ExclusiveGateway_0ch3fef" targetRef="ServiceTask_1jo8vn7"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="ServiceTask_0x5cje8" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1nsmyr5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cchgih</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0cchgih" sourceRef="ServiceTask_0x5cje8" targetRef="ExclusiveGateway_0v3l3wv" /> + <bpmn:serviceTask id="ServiceTask_02lxf48" name="Activate" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">activateNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1eljvek</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_015y785</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_015y785" sourceRef="ServiceTask_02lxf48" targetRef="ExclusiveGateway_0ch3fef" /> + <bpmn:serviceTask id="ServiceTask_0y2uysu" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_084orr1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g3qcd0</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0g3qcd0" sourceRef="ServiceTask_0y2uysu" targetRef="ExclusiveGateway_1ny9b1z" /> + <bpmn:serviceTask id="ServiceTask_0slpahe" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j26xlx</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0j26xlx" sourceRef="ServiceTask_0slpahe" targetRef="ExclusiveGateway_0x6h0ni" /> + <bpmn:serviceTask id="ServiceTask_1jo8vn7" name="Update Pnf in AAI" camunda:delegateExpression="${UpdatePnfEntryInAai}"> + <bpmn:incoming>SequenceFlow_0eiif6e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_084orr1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_084orr1" sourceRef="ServiceTask_1jo8vn7" targetRef="ServiceTask_0y2uysu" /> + </bpmn:process> + <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0nmskzh" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSoftwareUpgrade"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="softwareUpgrade_startEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_042uz7n_di" bpmnElement="ServiceTask_042uz7n"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1w3jv30_di" bpmnElement="softwareUpgrade_endEvent"> + <dc:Bounds x="1662" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1671" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0v3l3wv_di" bpmnElement="ExclusiveGateway_0v3l3wv" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1040" y="65" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0bnbfds_di" bpmnElement="EndEvent_0bnbfds"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1044" y="295" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0x6h0ni_di" bpmnElement="ExclusiveGateway_0x6h0ni" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1nsmyr5_di" bpmnElement="SequenceFlow_1nsmyr5"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_180lm4y_di" bpmnElement="EndEvent_180lm4y"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1lr7vgu_di" bpmnElement="SequenceFlow_1lr7vgu"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ch3fef_di" bpmnElement="ExclusiveGateway_0ch3fef" isMarkerVisible="true"> + <dc:Bounds x="1125" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ms4wdz_di" bpmnElement="EndEvent_1ms4wdz"> + <dc:Bounds x="1132" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0dqnb6c_di" bpmnElement="SequenceFlow_0dqnb6c"> + <di:waypoint x="1150" y="145" /> + <di:waypoint x="1150" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1148" y="230" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1ny9b1z_di" bpmnElement="ExclusiveGateway_1ny9b1z" isMarkerVisible="true"> + <dc:Bounds x="1505" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0l6n6x5_di" bpmnElement="EndEvent_0l6n6x5"> + <dc:Bounds x="1512" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1p0axph_di" bpmnElement="SequenceFlow_1p0axph"> + <di:waypoint x="1530" y="145" /> + <di:waypoint x="1530" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1528" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1eljvek_di" bpmnElement="SequenceFlow_1eljvek"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1010" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="938" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1atiydu_di" bpmnElement="SequenceFlow_1atiydu"> + <di:waypoint x="1555" y="120" /> + <di:waypoint x="1662" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1564" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eiif6e_di" bpmnElement="SequenceFlow_0eiif6e"> + <di:waypoint x="1175" y="120" /> + <di:waypoint x="1210" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1169" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0x5cje8_di" bpmnElement="ServiceTask_0x5cje8"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cchgih_di" bpmnElement="SequenceFlow_0cchgih"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_02lxf48_di" bpmnElement="ServiceTask_02lxf48"> + <dc:Bounds x="1010" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_015y785_di" bpmnElement="SequenceFlow_015y785"> + <di:waypoint x="1110" y="120" /> + <di:waypoint x="1125" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0y2uysu_di" bpmnElement="ServiceTask_0y2uysu"> + <dc:Bounds x="1370" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0g3qcd0_di" bpmnElement="SequenceFlow_0g3qcd0"> + <di:waypoint x="1470" y="120" /> + <di:waypoint x="1505" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0slpahe_di" bpmnElement="ServiceTask_0slpahe"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1jo8vn7_di" bpmnElement="ServiceTask_1jo8vn7"> + <dc:Bounds x="1210" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_084orr1_di" bpmnElement="SequenceFlow_084orr1"> + <di:waypoint x="1310" y="120" /> + <di:waypoint x="1370" y="120" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index aea06b5fc9..d426dc3f66 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -20,22 +20,9 @@ package org.onap.so.bpmn.infrastructure.process; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; -import java.io.IOException; -import java.util.List; -import java.util.UUID; +import com.google.protobuf.Struct; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -47,7 +34,21 @@ import org.onap.so.client.aai.AAIVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** @@ -62,10 +63,10 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); private String testBusinessKey; private String requestObject; private String responseObject; - private String msoRequestId; @Autowired private GrpcNettyServer grpcNettyServer; @@ -76,25 +77,25 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); - variables.put("bpmnRequest", requestObject); + executionVariables.clear(); + + executionVariables.put("bpmnRequest", requestObject); /** * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. */ - variables.put("isAsyncProcess", "true"); + executionVariables.put("isAsyncProcess", "true"); /** * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api * handler and then convert to CamudaInput */ - variables.put("pnfCorrelationId", "PNFDemo"); + executionVariables.put("pnfCorrelationId", "PNFDemo"); /** * Create mso-request-id. */ - msoRequestId = UUID.randomUUID().toString(); - variables.put("mso-request-id", msoRequestId); /** * Create Business key for the process instance @@ -113,8 +114,11 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { mockAai(); mockDmaapForPnf(); + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put("mso-request-id", msoRequestId); + ProcessInstance pi = - runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); int waitCount = 10; while (!isProcessInstanceEnded() && waitCount >= 0) { @@ -129,14 +133,24 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { "callCompleteMsoProcess_CallActivity", "ScriptTask_2", "CreateVCPE_EndEvent"); List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); - assertThat(detailedMessages).hasSize(2); + assertThat(detailedMessages.size() == 2); + int count = 0; try { - checkConfigAssign(detailedMessages.get(0)); - checkConfigDeploy(detailedMessages.get(1)); + for (ExecutionServiceInput eSI : detailedMessages) { + if ("config-assign".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigAssign(eSI, msoRequestId); + count++; + } + if ("config-deploy".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigDeploy(eSI, msoRequestId); + count++; + } + } } catch (Exception e) { e.printStackTrace(); fail("ConfigAssign/deploy request exception", e); } + assertThat(count == 2); } private boolean isProcessInstanceEnded() { @@ -144,7 +158,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .singleResult() == null; } - private void checkConfigAssign(ExecutionServiceInput executionServiceInput) { + private void checkConfigAssign(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configAssign request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); @@ -175,7 +189,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .isEqualTo("68dc9a92-214c-11e7-93ae-92361f002680"); } - private void checkConfigDeploy(ExecutionServiceInput executionServiceInput) { + private void checkConfigDeploy(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configDeploy request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java new file mode 100644 index 0000000000..065d2a54a8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java @@ -0,0 +1,230 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.assertj.core.api.Assertions; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. + */ +public class PNFSWUPDownloadTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[3]; + private String responseObject; + private String requestObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", + "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", + "ExclusiveGateway_08lusga", "download_EndEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 3); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action, msoRequestId); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSWUPDownload request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action, String msoRequestId) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + Assertions.assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + Assertions.assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + Assertions.assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + Assertions.assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + Assertions.assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java new file mode 100644 index 0000000000..a9bf4352bf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java @@ -0,0 +1,236 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. + */ +public class PNFSoftwareUpgradeTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[4]; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "activateNESw"; + actionNames[3] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", + "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", "ExclusiveGateway_0v3l3wv", + "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", "ExclusiveGateway_1ny9b1z", + "softwareUpgrade_endEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 4); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSoftwareUpgrade request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /* + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = + FileUtil.readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..a101118623 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json @@ -0,0 +1,54 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"SWUPid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + }, + { + "name":"targetSoftwareVersion", + "value":"demo-sw-ver2.0.0" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"SWUP", + "aLaCarte":false + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInEric" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..32539844ba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json new file mode 100644 index 0000000000..faec947fec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_software_upgrade_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java index 275cd18f0b..d2f52dac4c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java @@ -56,8 +56,8 @@ public class ControllerExecutionDETestIT extends BaseIntegrationTest { @Rule public final SpringMethodRule smr = new SpringMethodRule(); - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String PRECHECK_ACTION = "precheck"; private static final String POSTCHECK_ACTION = "postcheck"; private static final String ASSIGN_ACTION = "config-assign"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java index c69adeec50..583e139edd 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java @@ -66,8 +66,8 @@ public class GenericPnfCDSProcessingDETest extends BaseTaskTest { private AbstractCDSProcessingBBUtils cdsDispather; private static final String PRECHECK_ACTION = "precheck"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String POSTCHECK_ACTION = "postcheck"; private String description; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java index 8bc709b276..2698bc347f 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java @@ -38,4 +38,6 @@ public interface AAIRestClientI { Optional<Pnf> getPnfByName(String pnfId); void createPnf(String pnfId, Pnf pnf); + + void updatePnf(String pnfId, Pnf pnf); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java index 03e2eaea1f..f2f96ca905 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java @@ -92,4 +92,9 @@ public class AAIRestClientImpl implements AAIRestClientI { new AAIResourcesClient().createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); } + + @Override + public void updatePnf(String pnfId, Pnf pnf) { + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); + } } |