aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-flows/src/test
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2020-07-23 17:49:06 +0100
committertragait <rahul.tyagi@est.tech>2020-08-18 11:40:36 +0100
commite01546664d8d945ae83c625ab278b04ee0b9a331 (patch)
tree8bafaa6365cd410a937c69444bef903f64665ad7 /bpmn/so-bpmn-infrastructure-flows/src/test
parentc1b7f3805a5a3ed2ec8abcecb86f33415e4f0759 (diff)
[SO] create service upgrade workflow
Issue-ID: SO-2925 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: Ia10497fed1f42dea3e0469bc08ba0169862d3e71 Signed-off-by: tragait <rahul.tyagi@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-flows/src/test')
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java255
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json48
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json42
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json27
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json39
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json35
6 files changed, 446 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
new file mode 100644
index 0000000000..805597cd12
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
@@ -0,0 +1,255 @@
+/*-
+ * ============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.aaiclient.client.aai.AAIVersion;
+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.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.*;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
+
+/**
+ * Basic Integration test for ServiceLevelUpgrade.bpmn workflow.
+ */
+public class ServiceLevelUpgradeTest extends BaseBPMNTest {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private static final long WORKFLOW_WAIT_TIME = 1000L;
+
+ private static final String TEST_PROCESSINSTANCE_KEY = "ServiceLevelUpgrade";
+ private static final AAIVersion VERSION = AAIVersion.LATEST;
+ private static final Map<String, Object> executionVariables = new HashMap();
+ private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5";
+ private static final String SERVICE_INSTANCE_ID = "5df8b6de-2083-11e7-93ae-92361f002676";
+ private final String[] actionNames = new String[5];
+ private final String CLASSNAME = getClass().getSimpleName();
+ private String requestObject;
+ private String responseObject;
+
+ @Autowired
+ private GrpcNettyServer grpcNettyServer;
+
+ @Before
+ public void setUp() throws IOException {
+ actionNames[0] = "healthCheck";
+ actionNames[1] = "preCheck";
+ actionNames[2] = "downloadNESw";
+ actionNames[3] = "activateNESw";
+ actionNames[4] = "postCheck";
+
+ executionVariables.clear();
+
+ requestObject = FileUtil.readResourceFile("request/" + CLASSNAME + ".json");
+ responseObject = FileUtil.readResourceFile("response/" + CLASSNAME + ".json");
+
+ executionVariables.put("bpmnRequest", requestObject);
+ executionVariables.put("requestId", REQUEST_ID);
+ executionVariables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+
+
+ /**
+ * 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();
+ mockRequestDb();
+ 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("Event_02mc8tr", "Activity_18vue7u", "Activity_0qgmx7a",
+ "Activity_09bqns0", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_1q4o9fx",
+ "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7",
+ "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th");
+
+ List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
+ assertThat(detailedMessages.size() == 5);
+ 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/PnfHealthCheck_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("d88da85c-d9e8-4f73-b837-3a72a431622b");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
+ .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680");
+ }
+
+ private void mockAai() {
+
+ final String sIUrl =
+ "/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce";
+ final String aaiPnfEntry = FileUtil.readResourceFile("response/Pnf_aai.json");
+ final String aaiServiceInstanceEntry = FileUtil.readResourceFile("response/Service_instance_aai.json");
+
+ /**
+ * 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")));
+
+ /**
+ * Get the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(get(urlEqualTo("/aai/" + VERSION + sIUrl)).willReturn(okJson(aaiServiceInstanceEntry)));
+
+ /**
+ * Post the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + sIUrl)));
+ }
+
+ private void mockRequestDb() {
+ /**
+ * Update Request DB
+ */
+ wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID)));
+
+ }
+
+ /**
+ * Mock the catalobdb rest interface.
+ */
+ private void mockCatalogDb() {
+
+ String catalogdbClientResponse = FileUtil.readResourceFile("response/" + CLASSNAME + "_catalogdb.json");
+
+
+ /**
+ * Return valid json for the model UUID in the request file.
+ */
+ wireMockServer
+ .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(responseObject)));
+
+ /**
+ * Return valid json for the service model InvariantUUID as specified in the request file.
+ */
+ wireMockServer.stubFor(
+ get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=fe41489e-1563-46a3-b90a-1db629e4375b"))
+ .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=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(catalogdbClientResponse)));
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000000..b5cce60094
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails":{
+ "subscriberInfo":{
+ "globalSubscriberId":"ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ "requestInfo":{
+ "suppressRollback": false,
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "demo",
+ "instanceName":"testInstanceName",
+ "source":"VID"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f",
+ "cloudOwner": "CloudOwner"
+ },
+ "requestParameters":{
+ "subscriptionServiceType": "pNF",
+ "userParams":[
+ {
+ "name":"targetSoftwareVersion",
+ "value":"demo-sw-ver2.0.0"
+ },
+ {
+ "name":"pnfName",
+ "value":"PNFDemo"
+ }
+ ],
+ "aLaCarte": false,
+ "payload": "{\"k1\": \"v1\"}"
+ },
+ "project":{
+ "projectName": "ServiceLevelUpgrade"
+ },
+ "owningEntity":{
+ "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "owningEntityName":"OE-Test"
+ },
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
new file mode 100644
index 0000000000..865600c800
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
@@ -0,0 +1,42 @@
+{
+ "pnf-name": "PNFDemo",
+ "pnf-id": "27c6e19d-6d9f-4085-98a9-d3fcbaf3a616",
+ "equip-type": "val8",
+ "equip-vendor": "Ericsson",
+ "equip-model": "val6",
+ "ipaddress-v4-oam": "10.10.10.43",
+ "sw-version": "5gDUv18.05.201",
+ "in-maint": false,
+ "serial-number": "6061ZW3",
+ "ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
+ "resource-version": "1595010038094",
+ "nf-role": "gNB",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce/service-subscriptions/service-subscription/pNF/service-instances/service-instance/5df8b6de-2083-11e7-93ae-92361f002676",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "pNF"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5df8b6de-2083-11e7-93ae-92361f002676"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269"
+ }
+ ]
+ }
+ ]
+ }
+}, \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000000..ec92552c5e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
@@ -0,0 +1,27 @@
+{
+ "serviceResources":{
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ },
+ "serviceType":"pNF",
+ "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/ServiceLevelUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json
new file mode 100644
index 0000000000..faec947fec
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_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-infrastructure-flows/src/test/resources/response/Service_instance_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
new file mode 100644
index 0000000000..53fb210478
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
@@ -0,0 +1,35 @@
+{
+ "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676",
+ "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "resource-version": "1595258335377",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file