From c4c512c8b0a46d92f7862b9f01a7969975937e06 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 14 Mar 2018 15:07:31 -0700 Subject: Refactor homing flows for OOF/HPA 1. Split Homing into OOF and SNIRO versions 2. Added OOF API interactions 3. Added Unit tests for OOF Homing Code Issue-ID: SO-404 Change-Id: Ifeeeec9ea450d8b330110a565208ed89a1e18cde Signed-off-by: Marcus G K Williams --- .../mso/bpmn/common/scripts/Homing.groovy | 274 ------- .../mso/bpmn/common/scripts/OofHoming.groovy | 289 ++++++++ .../mso/bpmn/common/scripts/OofUtils.groovy | 405 ++++++++++ .../mso/bpmn/common/scripts/SNIROUtils.groovy | 2 +- .../mso/bpmn/common/scripts/SniroHoming.groovy | 274 +++++++ .../resources/subprocess/BuildingBlock/Homing.bpmn | 663 ++++++++++------- .../org/openecomp/mso/bpmn/common/HomingTest.java | 546 -------------- .../openecomp/mso/bpmn/common/OofHomingTest.java | 824 +++++++++++++++++++++ .../openecomp/mso/bpmn/common/SniroHomingTest.java | 548 ++++++++++++++ .../openecomp/mso/bpmn/mock/StubResponseOof.java | 67 ++ .../__files/BuildingBlocks/oofCallback2AR1Vnf | 109 +++ .../__files/BuildingBlocks/oofCallback2AR1Vnf2Net | 116 +++ .../__files/BuildingBlocks/oofCallbackInfraVnf | 47 ++ .../BuildingBlocks/oofCallbackNoSolutionFound | 10 + .../BuildingBlocks/oofCallbackPolicyException | 9 + .../BuildingBlocks/oofCallbackServiceException | 12 + .../__files/BuildingBlocks/oofCatalogResp.json | 47 ++ .../resources/__files/BuildingBlocks/oofRequest | 99 +++ .../__files/BuildingBlocks/oofRequest_infravnf | 56 ++ .../src/test/resources/mso.bpmn.urn.properties | 266 +++---- 20 files changed, 3453 insertions(+), 1210 deletions(-) delete mode 100755 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy create mode 100755 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SniroHoming.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf2Net create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackInfraVnf create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackPolicyException create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackServiceException create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCatalogResp.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest_infravnf (limited to 'bpmn/MSOCommonBPMN') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy deleted file mode 100755 index 2325e6c3d3..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy +++ /dev/null @@ -1,274 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.common.scripts - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.domain.InventoryType -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.Subscriber -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor - -import org.json.JSONArray -import org.json.JSONObject - -import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*; - -/** - * This class is contains the scripts used - * by the Homing Subflow building block. The - * subflow attempts to home the provided - * resources by calling sniro. - * - * @author cb645j - * - */ -class Homing extends AbstractServiceTaskProcessor{ - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - SNIROUtils sniroUtils = new SNIROUtils(this) - - /** - * This method validates the incoming variables. - * The method then prepares the sniro request - * and posts it to sniro's rest api. - * - * @param execution - * - * @author cb645j - */ - public void callSniro(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix","HOME_") - utils.log("DEBUG", "*** Started Homing Call Sniro ***", isDebugEnabled) - try{ - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - - String requestId = execution.getVariable("msoRequestId") - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - String serviceInstanceId = execution.getVariable("serviceInstanceId") - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - utils.log("DEBUG", "Incoming Service Decomposition is: " + serviceDecomposition, isDebugEnabled) - String subscriberInfo = execution.getVariable("subscriberInfo") - utils.log("DEBUG", "Incoming Subscriber Information is: " + subscriberInfo, isDebugEnabled) - - if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){ - exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null") - }else{ - String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") - String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") - String subCommonSiteId = "" - if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){ - subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") - } - Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) - - String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used - String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format - - //Authentication - def authHeader = "" - String basicAuth = execution.getVariable("URN_mso_sniro_auth") - String msokey = execution.getVariable("URN_mso_msoKey") - String basicAuthValue = utils.encrypt(basicAuth, msokey) - if(basicAuthValue != null){ - utils.log("DEBUG", "Obtained BasicAuth username and password for SNIRO Adapter: " + basicAuthValue, isDebugEnabled) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue",authHeader) - } catch (Exception ex) { - utils.log("DEBUG", "Unable to encode username and password string: " + ex, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to encode username and password string") - } - }else{ - utils.log("DEBUG", "Unable to obtain BasicAuth - BasicAuth value null" , isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth value null") - } - - //Prepare Callback - String timeout = execution.getVariable("timeout") - if(isBlank(timeout)){ - timeout = execution.getVariable("URN_mso_sniro_timeout"); - if(isBlank(timeout)) { - timeout = "PT30M"; - } - } - utils.log("DEBUG", "Async Callback Timeout will be: " + timeout, isDebugEnabled) - - execution.setVariable("timeout", timeout); - execution.setVariable("correlator", requestId); - execution.setVariable("messageType", "SNIROResponse"); - - //Build Request & Call Sniro - String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters) - execution.setVariable("sniroRequest", sniroRequest) - utils.log("DEBUG", "SNIRO Request is: " + sniroRequest, isDebugEnabled) - - String endpoint = execution.getVariable("URN_mso_service_agnostic_sniro_endpoint") - String host = execution.getVariable("URN_mso_service_agnostic_sniro_host") - String url = host + endpoint - utils.log("DEBUG", "Posting to Sniro Url: " + url, isDebugEnabled) - - logDebug( "URL to be used is: " + url, isDebugEnabled) - - RESTConfig config = new RESTConfig(url); - RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json") - APIResponse response = client.httpPost(sniroRequest) - - int responseCode = response.getStatusCode() - execution.setVariable("syncResponseCode", responseCode); - logDebug("SNIRO sync response code is: " + responseCode, isDebugEnabled) - String syncResponse = response.getResponseBodyAsString() - execution.setVariable("syncResponse", syncResponse); - logDebug("SNIRO sync response is: " + syncResponse, isDebugEnabled) - - utils.log("DEBUG", "*** Completed Homing Call Sniro ***", isDebugEnabled) - } - }catch(BpmnError b){ - throw b - }catch(Exception e){ - utils.log("DEBUG", "Error encountered within Homing CallSniro method: " + e, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage()) - } - } - - /** - * This method processes the callback response - * and the contained homing solution. It sets - * homing solution assignment and license - * information to the corresponding resources - * - * @param execution - * - * @author cb645j - */ - public void processHomingSolution(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled) - try{ - String response = execution.getVariable("asyncCallbackResponse") - utils.log("DEBUG", "Sniro Async Callback Response is: " + response, isDebugEnabled) - utils.logAudit("Sniro Async Callback Response is: " + response) - - sniroUtils.validateCallbackResponse(execution, response) - String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") - - ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") - utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled) - - List resourceList = decomposition.getServiceResources() - JSONArray arr = new JSONArray(placements) - for(int i = 0; i < arr.length(); i++){ - JSONObject placement = arr.getJSONObject(i) - String jsonServiceResourceId = placement.getString("serviceResourceId") - for(Resource resource:resourceList){ - String serviceResourceId = resource.getResourceId() - if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ - //match - String inventoryType = placement.getString("inventoryType") - resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) - resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId")) - resource.getHomingSolution().setRehome(placement.getBoolean("isRehome")) - JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") - Map assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue") - resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) - resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli")) - resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion")) - if(inventoryType.equalsIgnoreCase("service")){ - VnfResource vnf = new VnfResource() - vnf.setVnfHostname(assignmentMap.get("vnfHostName")) - resource.getHomingSolution().setVnf(vnf) - resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) - } - } - } - } - if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){ - String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo") - JSONArray licenseArr = new JSONArray(licenseInfo) - for(int l = 0; l < licenseArr.length(); l++){ - JSONObject license = licenseArr.getJSONObject(l) - String jsonServiceResourceId = license.getString("serviceResourceId") - for(Resource resource:resourceList){ - String serviceResourceId = resource.getResourceId() - if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ - //match - String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList") - List entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) - resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) - - String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList") - List licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) - resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) - } - } - } - } - execution.setVariable("serviceDecomposition", decomposition) - execution.setVariable("homingSolution", placements) //TODO - can be removed as output variable - - utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled) - }catch(BpmnError b){ - throw b - }catch(Exception e){ - utils.log("DEBUG", "Error encountered within Homing ProcessHomingSolution method: " + e, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing ProcessHomingSolution") - } - } - - /** - * This method logs the start of DHVCreateService - * to make debugging easier. - * - * @param - execution - * @author cb645j - */ - public String logStart(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String requestId = execution.getVariable("testReqId") - if(isBlank(requestId)){ - requestId = execution.getVariable("msoRequestId") - } - execution.setVariable("DHVCS_requestId", requestId) - utils.log("DEBUG", "***** STARTED Homing Subflow for request: " + requestId + " *****", "true") - utils.log("DEBUG", "****** Homing Subflow Global Debug Enabled: " + isDebugEnabled + " *****", "true") - utils.logAudit("***** STARTED Homing Subflow for request: " + requestId + " *****") - } - - - /** - * Auto-generated method stub - */ - public void preProcessRequest(DelegateExecution execution){} - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy new file mode 100644 index 0000000000..5e7ed982a6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy @@ -0,0 +1,289 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; + +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.core.domain.InventoryType +import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.Subscriber +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor + +import org.json.JSONArray +import org.json.JSONObject + +import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.* + +/** + * This class contains the scripts used + * by the OOF Homing Subflow building block. The + * subflow attempts to home the provided + * resources by calling OOF. + */ +class OofHoming extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + OofUtils oofUtils = new OofUtils(this) + + /** + * This method validates the incoming variables. + * The method then prepares the OOF request + * and posts it to OOF's rest api. + * + * @param execution + */ + public void callOof(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", "HOME_") + utils.log("DEBUG", "*** Started Homing Call OOF ***", isDebugEnabled) + try { + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + + String requestId = execution.getVariable("msoRequestId") + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + utils.log("DEBUG", "Incoming Service Decomposition is: " + serviceDecomposition, isDebugEnabled) + String subscriberInfo = execution.getVariable("subscriberInfo") + utils.log("DEBUG", "Incoming Subscriber Information is: " + subscriberInfo, isDebugEnabled) + Map customerLocation = execution.getVariable("customerLocation") + utils.log("DEBUG", "Incoming Customer Location is: " + customerLocation.toString(), isDebugEnabled) + String cloudOwner = execution.getVariable("cloudOwner") + utils.log("DEBUG", "Incoming cloudOwner is: " + cloudOwner, isDebugEnabled) + String cloudRegionId = execution.getVariable("cloudRegionId") + utils.log("DEBUG", "Incoming cloudRegionId is: " + cloudRegionId, isDebugEnabled) + + if (isBlank(requestId) || + isBlank(serviceInstanceId) || + isBlank(serviceDecomposition.toString()) || + isBlank(subscriberInfo) || + isBlank(customerLocation.toString()) || + isBlank(cloudOwner) || + isBlank(cloudRegionId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 4000, + "A required input variable is missing or null") + } else { + String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") + String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") + String subCommonSiteId = "" + if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { + subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + } + Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) + + //Authentication + def authHeader = "" + String basicAuth = execution.getVariable("URN_mso_oof_auth") + String msokey = execution.getVariable("URN_mso_msoKey") + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + utils.log("DEBUG", "Obtained BasicAuth username and password for OOF Adapter: " + basicAuthValue, + isDebugEnabled) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + utils.log("DEBUG", "Unable to encode username and password string: " + ex, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + utils.log("DEBUG", "Unable to obtain BasicAuth - BasicAuth value null", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + + //Prepare Callback + String timeout = execution.getVariable("timeout") + if (isBlank(timeout)) { + timeout = execution.getVariable("URN_mso_oof_timeout"); + if (isBlank(timeout)) { + timeout = "PT30M" + } + } + utils.log("DEBUG", "Async Callback Timeout will be: " + timeout, isDebugEnabled) + + execution.setVariable("timeout", timeout) + execution.setVariable("correlator", requestId) + execution.setVariable("messageType", "oofResponse") + + //Build Request & Call OOF + String oofRequest = oofUtils.buildRequest(execution, requestId, serviceDecomposition, + subscriber, customerLocation) + execution.setVariable("oofRequest", oofRequest) + utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled) + + String endpoint = execution.getVariable("URN_mso_service_agnostic_oof_endpoint") + String host = execution.getVariable("URN_mso_service_agnostic_oof_host") + String url = host + endpoint + utils.log("DEBUG", "Posting to OOF Url: " + url, isDebugEnabled) + + logDebug("URL to be used is: " + url, isDebugEnabled) + + RESTConfig config = new RESTConfig(url) + RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader). + addHeader("Content-Type", "application/json") + APIResponse response = client.httpPost(oofRequest) + + int responseCode = response.getStatusCode() + execution.setVariable("syncResponseCode", responseCode) + logDebug("OOF sync response code is: " + responseCode, isDebugEnabled) + String syncResponse = response.getResponseBodyAsString() + execution.setVariable("syncResponse", syncResponse) + logDebug("OOF sync response is: " + syncResponse, isDebugEnabled) + + utils.log("DEBUG", "*** Completed Homing Call OOF ***", isDebugEnabled) + } + } catch (BpmnError b) { + throw b + } catch (Exception e) { + utils.log("DEBUG", "Error encountered within Homing callOof method: " + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Internal Error - Occured in Homing callOof: " + e.getMessage()) + } + } + + /** + * This method processes the callback response + * and the contained homing solution. It sets + * homing solution assignment and license + * information to the corresponding resources + * + * @param execution + */ + public void processHomingSolution(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled) + try { + String response = execution.getVariable("asyncCallbackResponse") + utils.log("DEBUG", "OOF Async Callback Response is: " + response, isDebugEnabled) + utils.logAudit("OOF Async Callback Response is: " + response) + + oofUtils.validateCallbackResponse(execution, response) + String placements = jsonUtil.getJsonValue(response, "solutions.placementSolutions") + utils.log("DEBUG", "****** Solution Placements: " + placements + " *****", isDebugEnabled) + + ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") + utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled) + + List resourceList = decomposition.getServiceResources() + JSONArray arr = new JSONArray(placements) + for (int i = 0; i < arr.length(); i++) { + JSONObject placement = arr.getJSONObject(i) + utils.log("DEBUG", "****** JSONObject is: " + placement + " *****", "true") + String jsonServiceResourceId = placement.getString("serviceResourceId") + for (Resource resource : resourceList) { + String serviceResourceId = resource.getResourceId() + if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) { + JSONObject solution = placement.getJSONObject("solution") + String solutionType = solution.getString("identifierType") + String inventoryType = "" + if (solutionType.equalsIgnoreCase("serviceInstanceId")) { + inventoryType = "service" + } else { + inventoryType = "cloud" + + } + resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) + + // TODO Deal with Placement Solutions & Assignment Info here + JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") + Map assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "key", "value") + resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) + resource.getHomingSolution().setCloudRegionId(assignmentMap.get("cloudRegionId")) + if (inventoryType.equalsIgnoreCase("service")) { + resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean()) + VnfResource vnf = new VnfResource() + vnf.setVnfHostname(assignmentMap.get("vnfHostName")) + resource.getHomingSolution().setVnf(vnf) + resource.getHomingSolution().setServiceInstanceId(solution.getJSONArray("identifiers")[0].toString()) + } + } + } + } + if (JsonUtils.jsonElementExist(response, "solutions.licenseSolutions")) { + String licenseSolutions = jsonUtil.getJsonValue(response, "solutions.licenseSolutions") + JSONArray licenseArr = new JSONArray(licenseSolutions) + for (int l = 0; l < licenseArr.length(); l++) { + JSONObject license = licenseArr.getJSONObject(l) + String jsonServiceResourceId = license.getString("serviceResourceId") + for (Resource resource : resourceList) { + String serviceResourceId = resource.getResourceId() + if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) { + String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolUUID") + List entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) + resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) + + String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupUUID") + List licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) + resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) + } + } + } + } + execution.setVariable("serviceDecomposition", decomposition) + execution.setVariable("homingSolution", placements) //TODO - can be removed as output variable + + utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled) + } catch (BpmnError b) { + throw b + } catch (Exception e) { + utils.log("DEBUG", "Error encountered within Homing ProcessHomingSolution method: " + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution") + } + } + + /** + * This method logs the start of DHVCreateService + * to make debugging easier. + * + * @param - execution + */ + public String logStart(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String requestId = execution.getVariable("testReqId") + if (isBlank(requestId)) { + requestId = execution.getVariable("msoRequestId") + } + execution.setVariable("DHVCS_requestId", requestId) + utils.log("DEBUG", "***** STARTED Homing Subflow for request: " + requestId + " *****", "true") + utils.log("DEBUG", "****** Homing Subflow Global Debug Enabled: " + isDebugEnabled + " *****", "true") + utils.logAudit("***** STARTED Homing Subflow for request: " + requestId + " *****") + } + + /** + * Auto-generated method stub + */ + public void preProcessRequest(DelegateExecution execution) {} + // Not Implemented Method +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy new file mode 100644 index 0000000000..fc7c62baa7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy @@ -0,0 +1,405 @@ +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.domain.HomingSolution +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.ServiceInstance +import org.openecomp.mso.bpmn.core.domain.Subscriber +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.json.JsonUtils + +import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.* + +class OofUtils { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + private AbstractServiceTaskProcessor utils + + public MsoUtils msoUtils = new MsoUtils() + + public OofUtils(AbstractServiceTaskProcessor taskProcessor) { + this.utils = taskProcessor + } + + /** + * This method builds the service-agnostic + * OOF json request to get a homing solution + * and license solution + * + * @param execution + * @param requestId + * @param decomposition - ServiceDecomposition object + * @param customerLocation - + * @param existingCandidates - + * @param excludedCandidates - + * @param requiredCandidates - + * + * @return request - OOF v1 payload - https://wiki.onap.org/pages/viewpage.action?pageId=25435066 + */ + String buildRequest(DelegateExecution execution, + String requestId, + ServiceDecomposition decomposition, + Subscriber subscriber, + Map customerLocation, + ArrayList existingCandidates = null, + ArrayList excludedCandidates = null, + ArrayList requiredCandidates = null) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", "Started Building OOF Request", isDebugEnabled) + def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(execution, "oofResponse", requestId) + def transactionId = requestId + //ServiceInstance Info + ServiceInstance serviceInstance = decomposition.getServiceInstance() + def serviceInstanceId = "" + def serviceInstanceName = "" + if (serviceInstance == null) { + utils.log("DEBUG", "Unable to obtain Service Instance Id, ServiceInstance Object is null", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " + + "obtain Service Instance Id, ServiceInstance Object is null") + } else { + serviceInstanceId = serviceInstance.getInstanceId() + serviceInstanceName = serviceInstance.getInstanceName() + } + //Model Info + ModelInfo model = decomposition.getModelInfo() + String modelType = model.getModelType() + String modelInvariantId = model.getModelInvariantUuid() + String modelVersionId = model.getModelUuid() + String modelName = model.getModelName() + String modelVersion = model.getModelVersion() + //Subscriber Info + String subscriberId = subscriber.getGlobalId() + String subscriberName = subscriber.getName() + String commonSiteId = subscriber.getCommonSiteId() + + //Determine RequestType + //TODO Figure out better way to determine this + String requestType = "create" + List resources = decomposition.getServiceResources() + for(Resource r:resources){ + HomingSolution currentSolution = (HomingSolution) r.getCurrentHomingSolution() + if(currentSolution != null){ + requestType = "speed changed" + } + } + + //Demands + String placementDemands = "" + StringBuilder sb = new StringBuilder() + List resourceList = decomposition.getServiceAllottedResources() + List vnfResourceList = decomposition.getServiceVnfs() + + if (resourceList.isEmpty() || resourceList == null) { + utils.log("DEBUG", "Allotted Resources List is empty - will try to get service VNFs instead.", + isDebugEnabled) + resourceList = decomposition.getServiceVnfs() + } + + if (resourceList.isEmpty() || resourceList == null) { + utils.log("DEBUG", "Resources List is Empty", isDebugEnabled) + } else { + for (Resource resource : resourceList) { + ModelInfo resourceModelInfo = resource.getModelInfo() + def serviceResourceId = resource.getResourceId() + def resourceModuleName = resource.getResourceType() + def resouceModelInvariantId = resourceModelInfo.getModelInvariantUuid() + def resouceModelName = resourceModelInfo.getModelName() + def resouceModelVersion = resourceModelInfo.getModelVersion() + def resouceModelVersionId = resourceModelInfo.getModelUuid() + def resouceModelType = resourceModelInfo.getModelType() + def tenantId = execution.getTenantId() + def requiredCandidatesJson = "" + + requiredCandidatesJson = createCandidateJson( + existingCandidates, + excludedCandidates, + requiredCandidates) + + String demand = + "{\n" + + "\"resourceModuleName\": \"${resourceModuleName}\",\n" + + "\"serviceResourceId\": \"${serviceResourceId}\",\n" + + "\"tenantId\": \"${tenantId}\",\n" + + "\"resourceModelInfo\": {\n" + + " \"modelInvariantId\": \"${resouceModelInvariantId}\",\n" + + " \"modelVersionId\": \"${resouceModelVersionId}\",\n" + + " \"modelName\": \"${resouceModelName}\",\n" + + " \"modelType\": \"${resouceModelType}\",\n" + + " \"modelVersion\": \"${resouceModelVersion}\",\n" + + " \"modelCustomizationName\": \"\"\n" + + " }" + requiredCandidatesJson + "\n" + + "}," + + placementDemands = sb.append(demand) + } + placementDemands = placementDemands.substring(0, placementDemands.length() - 1) + } + + String licenseDemands = "" + sb = new StringBuilder() + if (vnfResourceList.isEmpty() || vnfResourceList == null) { + utils.log("DEBUG", "Vnf Resources List is Empty", isDebugEnabled) + } else { + for (VnfResource vnfResource : vnfResourceList) { + ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo() + def resourceInstanceType = vnfResource.getResourceType() + def serviceResourceId = vnfResource.getResourceId() + def resourceModuleName = vnfResource.getResourceType() + def resouceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid() + def resouceModelName = vnfResourceModelInfo.getModelName() + def resouceModelVersion = vnfResourceModelInfo.getModelVersion() + def resouceModelVersionId = vnfResourceModelInfo.getModelUuid() + def resouceModelType = vnfResourceModelInfo.getModelType() + + // TODO Add Existing Licenses to demand + //"existingLicenses": { + //"entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", + // "43257b49-9602-4fe5-9337-094e52bc9435"], + //"licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", + // "43257b49-9602-4fe5-9337-094e52bc9435"] + //} + + String licenseDemand = + "{\n" + + "\"resourceModuleName\": \"${resourceModuleName}\",\n" + + "\"serviceResourceId\": \"${serviceResourceId}\",\n" + + "\"resourceInstanceType\": \"${resourceInstanceType}\",\n" + + "\"resourceModelInfo\": {\n" + + " \"modelInvariantId\": \"${resouceModelInvariantId}\",\n" + + " \"modelVersionId\": \"${resouceModelVersionId}\",\n" + + " \"modelName\": \"${resouceModelName}\",\n" + + " \"modelType\": \"${resouceModelType}\",\n" + + " \"modelVersion\": \"${resouceModelVersion}\",\n" + + " \"modelCustomizationName\": \"\"\n" + + " }\n" + "}," + + licenseDemands = sb.append(licenseDemand) + } + licenseDemands = licenseDemands.substring(0, licenseDemands.length() - 1) + } + + String request = + "{\n" + + " \"requestInfo\": {\n" + + " \"transactionId\": \"${transactionId}\",\n" + + " \"requestId\": \"${requestId}\",\n" + + " \"callbackUrl\": \"${callbackUrl}\",\n" + + " \"sourceId\": \"so\",\n" + + " \"requestType\": \"${requestType}\"," + + " \"numSolutions\": 1,\n" + + " \"optimizers\": [\"placement\"],\n" + + " \"timeout\": 600\n" + + " },\n" + + " \"placementInfo\": {\n" + + " \"requestParameters\": {\n" + + " \"customerLatitude\": \"${customerLocation.customerLatitude}\",\n" + + " \"customerLongitude\": \"${customerLocation.customerLongitude}\",\n" + + " \"customerName\": \"${customerLocation.customerName}\"\n" + + " }," + + " \"subscriberInfo\": { \n" + + " \"globalSubscriberId\": \"${subscriberId}\",\n" + + " \"subscriberName\": \"${subscriberName}\",\n" + + " \"subscriberCommonSiteId\": \"${commonSiteId}\"\n" + + " },\n" + + " \"placementDemands\": [\n" + + " ${placementDemands}\n" + + " ]\n" + + " },\n" + + " \"serviceInfo\": {\n" + + " \"serviceInstanceId\": \"${serviceInstanceId}\",\n" + + " \"serviceName\": \"${serviceInstanceName}\",\n" + + " \"modelInfo\": {\n" + + " \"modelType\": \"${modelType}\",\n" + + " \"modelInvariantId\": \"${modelInvariantId}\",\n" + + " \"modelVersionId\": \"${modelVersionId}\",\n" + + " \"modelName\": \"${modelName}\",\n" + + " \"modelVersion\": \"${modelVersion}\",\n" + + " \"modelCustomizationName\": \"\"\n" + + " }\n" + + " },\n" + + " \"licenseInfo\": {\n" + + " \"licenseDemands\": [\n" + + " ${licenseDemands}\n" + + " }]\n" + + " }\n" + + "}" + + + utils.log("DEBUG", "Completed Building OOF Request", isDebugEnabled) + return request + } + + /** + * This method validates the callback response + * from OOF. If the response contains an + * exception the method will build and throw + * a workflow exception. + * + * @param execution + * @param response - the async callback response from oof + */ + Void validateCallbackResponse(DelegateExecution execution, String response) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String placements = "" + if (isBlank(response)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "OOF Async Callback Response is Empty") + } else { + if (JsonUtils.jsonElementExist(response, "solutions.placementSolutions")) { + placements = jsonUtil.getJsonValue(response, "solutions.placementSolutions") + if (isBlank(placements) || placements.equalsIgnoreCase("[]")) { + String statusMessage = jsonUtil.getJsonValue(response, "statusMessage") + if (isBlank(statusMessage)) { + utils.log("DEBUG", "Error Occurred in Homing: OOF Async Callback Response does " + + "not contain placement solution.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 400, + "OOF Async Callback Response does not contain placement solution.") + } else { + utils.log("DEBUG", "Error Occurred in Homing: " + statusMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 400, statusMessage) + } + } else { + return + } + } else if (JsonUtils.jsonElementExist(response, "requestError") == true) { + String errorMessage = "" + if (response.contains("policyException")) { + String text = jsonUtil.getJsonValue(response, "requestError.policyException.text") + errorMessage = "OOF Async Callback Response contains a Request Error Policy Exception: " + text + } else if (response.contains("serviceException")) { + String text = jsonUtil.getJsonValue(response, "requestError.serviceException.text") + errorMessage = "OOF Async Callback Response contains a Request Error Service Exception: " + text + } else { + errorMessage = "OOF Async Callback Response contains a Request Error. Unable to determine the Request Error Exception." + } + utils.log("DEBUG", "Error Occurred in Homing: " + errorMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 400, errorMessage) + + } else { + utils.log("DEBUG", "Error Occurred in Homing: Received an Unknown Async Callback Response from OOF.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Received an Unknown Async Callback Response from OOF.") + } + } + + } + + /** + * This method creates candidates json for placement Demands. + * + * @param execution + * @param existingCandidates - + * @param excludedCandidates - + * @param requiredCandidates - + * + * @return candidatesJson - a JSON string with candidates + */ + String createCandidateJson(ArrayList existingCandidates = null, + ArrayList excludedCandidates = null, + ArrayList requiredCandidates = null) { + def candidatesJson = "" + def type = "" + if (existingCandidates != null && existingCandidates != {}) { + sb = new StringBuilder() + sb.append(",\n" + + " \"existingCandidates\": [\n") + def existingCandidateJson = "" + existingCandidates.each { + type = existingCandidate.get('identifierType') + if (type == 'vimId') { + def cloudOwner = existingCandidate.get('cloudOwner') + def cloudRegionId = existingCandidate.get('identifiers') + existingCandidateJson = "{\n" + + " \"identifierType\": \"vimId\",\n" + + " \"cloudOwner\": \"${cloudOwner}\",\n" + + " \"identifiers\": [\"${cloudRegionId}\"]\n" + + " }," + sb.append(existingCandidateJson) + } + if (type == 'serviceInstanceId') { + def serviceInstanceId = existingCandidate.get('identifiers') + existingCandidateJson += "{\n" + + " \"identifierType\": \"serviceInstanceId\",\n" + + " \"identifiers\": [\"${serviceInstanceId}\"]\n" + + " }," + sb.append(existingCandidateJson) + } + } + if (existingCandidateJson != "") { + sb.setLength(sb.length() - 1) + candidatesJson = sb.append(",\n],") + } + } + if (excludedCandidates != null && excludedCandidates != {}) { + sb = new StringBuilder() + sb.append(",\n" + + " \"excludedCandidates\": [\n") + def excludedCandidateJson = "" + excludedCandidates.each { + type = excludedCandidate.get('identifierType') + if (type == 'vimId') { + def cloudOwner = excludedCandidate.get('cloudOwner') + def cloudRegionId = excludedCandidate.get('identifiers') + excludedCandidateJson = "{\n" + + " \"identifierType\": \"vimId\",\n" + + " \"cloudOwner\": \"${cloudOwner}\",\n" + + " \"identifiers\": [\"${cloudRegionId}\"]\n" + + " }," + sb.append(excludedCandidateJson) + } + if (type == 'serviceInstanceId') { + def serviceInstanceId = excludedCandidate.get('identifiers') + excludedCandidateJson += "{\n" + + " \"identifierType\": \"serviceInstanceId\",\n" + + " \"identifiers\": [\"${serviceInstanceId}\"]\n" + + " }," + sb.append(excludedCandidateJson) + } + } + if (excludedCandidateJson != "") { + sb.setLength(sb.length() - 1) + candidatesJson = sb.append(",\n],") + } + } + if (requiredCandidates != null && requiredCandidates != {}) { + sb = new StringBuilder() + sb.append(",\n" + + " \"requiredCandidates\": [\n") + def requiredCandidatesJson = "" + requiredCandidates.each { + type = requiredCandidate.get('identifierType') + if (type == 'vimId') { + def cloudOwner = requiredCandidate.get('cloudOwner') + def cloudRegionId = requiredCandidate.get('identifiers') + requiredCandidatesJson = "{\n" + + " \"identifierType\": \"vimId\",\n" + + " \"cloudOwner\": \"${cloudOwner}\",\n" + + " \"identifiers\": [\"${cloudRegionId}\"]\n" + + " }," + sb.append(requiredCandidatesJson) + } + if (type == 'serviceInstanceId') { + def serviceInstanceId = requiredCandidate.get('identifiers') + requiredCandidatesJson += "{\n" + + " \"identifierType\": \"serviceInstanceId\",\n" + + " \"identifiers\": [\"${serviceInstanceId}\"]\n" + + " }," + sb.append(requiredCandidatesJson) + } + } + if (requiredCandidatesJson != "") { + sb.setLength(sb.length() - 1) + candidatesJson = sb.append(",\n],") + } + } + if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)} + return candidatesJson + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy index ab215c9949..88ed9fb330 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy @@ -96,7 +96,7 @@ class SNIROUtils{ String requestType = "initial" List resources = decomposition.getServiceResources() for(Resource r:resources){ - HomingSolution currentSolution = r.getCurrentHomingSolution() + HomingSolution currentSolution = (HomingSolution) r.getCurrentHomingSolution() if(currentSolution != null){ requestType = "speed changed" } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SniroHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SniroHoming.groovy new file mode 100755 index 0000000000..3f534377d8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SniroHoming.groovy @@ -0,0 +1,274 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.common.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; + +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.core.domain.InventoryType +import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.Subscriber +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor + +import org.json.JSONArray +import org.json.JSONObject + +import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*; + +/** + * This class is contains the scripts used + * by the Homing Subflow building block. The + * subflow attempts to home the provided + * resources by calling sniro. + * + * @author cb645j + * + */ +class SniroHoming extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + SNIROUtils sniroUtils = new SNIROUtils(this) + + /** + * This method validates the incoming variables. + * The method then prepares the sniro request + * and posts it to sniro's rest api. + * + * @param execution + * + * @author cb645j + */ + public void callSniro(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", "HOME_") + utils.log("DEBUG", "*** Started Homing Call Sniro ***", isDebugEnabled) + try { + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + + String requestId = execution.getVariable("msoRequestId") + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + utils.log("DEBUG", "Incoming Service Decomposition is: " + serviceDecomposition, isDebugEnabled) + String subscriberInfo = execution.getVariable("subscriberInfo") + utils.log("DEBUG", "Incoming Subscriber Information is: " + subscriberInfo, isDebugEnabled) + + if (isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null") + } else { + String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") + String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") + String subCommonSiteId = "" + if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { + subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + } + Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) + + String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used + String homingParameters = execution.getVariable("homingParameters") + // (aka. request parameters) Should be json format. TODO confirm its json format + + //Authentication + def authHeader = "" + String basicAuth = execution.getVariable("URN_mso_sniro_auth") + String msokey = execution.getVariable("URN_mso_msoKey") + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + utils.log("DEBUG", "Obtained BasicAuth username and password for SNIRO Adapter: " + basicAuthValue, isDebugEnabled) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + utils.log("DEBUG", "Unable to encode username and password string: " + ex, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to encode username and password string") + } + } else { + utils.log("DEBUG", "Unable to obtain BasicAuth - BasicAuth value null", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth value null") + } + + //Prepare Callback + String timeout = execution.getVariable("timeout") + if (isBlank(timeout)) { + timeout = execution.getVariable("URN_mso_sniro_timeout"); + if (isBlank(timeout)) { + timeout = "PT30M"; + } + } + utils.log("DEBUG", "Async Callback Timeout will be: " + timeout, isDebugEnabled) + + execution.setVariable("timeout", timeout); + execution.setVariable("correlator", requestId); + execution.setVariable("messageType", "SNIROResponse"); + + //Build Request & Call Sniro + String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters) + execution.setVariable("sniroRequest", sniroRequest) + utils.log("DEBUG", "SNIRO Request is: " + sniroRequest, isDebugEnabled) + + String endpoint = execution.getVariable("URN_mso_service_agnostic_sniro_endpoint") + String host = execution.getVariable("URN_mso_service_agnostic_sniro_host") + String url = host + endpoint + utils.log("DEBUG", "Posting to Sniro Url: " + url, isDebugEnabled) + + logDebug("URL to be used is: " + url, isDebugEnabled) + + RESTConfig config = new RESTConfig(url) + RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json") + APIResponse response = client.httpPost(sniroRequest) + + int responseCode = response.getStatusCode() + execution.setVariable("syncResponseCode", responseCode); + logDebug("SNIRO sync response code is: " + responseCode, isDebugEnabled) + String syncResponse = response.getResponseBodyAsString() + execution.setVariable("syncResponse", syncResponse); + logDebug("SNIRO sync response is: " + syncResponse, isDebugEnabled) + + utils.log("DEBUG", "*** Completed Homing Call Sniro ***", isDebugEnabled) + } + } catch (BpmnError b) { + throw b + } catch (Exception e) { + utils.log("DEBUG", "Error encountered within Homing CallSniro method: " + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage()) + } + } + + /** + * This method processes the callback response + * and the contained homing solution. It sets + * homing solution assignment and license + * information to the corresponding resources + * + * @param execution + * + * @author cb645j + */ + public void processHomingSolution(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled) + try { + String response = execution.getVariable("asyncCallbackResponse") + utils.log("DEBUG", "Sniro Async Callback Response is: " + response, isDebugEnabled) + utils.logAudit("Sniro Async Callback Response is: " + response) + + sniroUtils.validateCallbackResponse(execution, response) + String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") + + ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") + utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled) + + List resourceList = decomposition.getServiceResources() + JSONArray arr = new JSONArray(placements) + for (int i = 0; i < arr.length(); i++) { + JSONObject placement = arr.getJSONObject(i) + String jsonServiceResourceId = placement.getString("serviceResourceId") + for (Resource resource : resourceList) { + String serviceResourceId = resource.getResourceId() + if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) { + //match + String inventoryType = placement.getString("inventoryType") + resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) + resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId")) + resource.getHomingSolution().setRehome(placement.getBoolean("isRehome")) + JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") + Map assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue") + resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) + resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli")) + resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion")) + if (inventoryType.equalsIgnoreCase("service")) { + VnfResource vnf = new VnfResource() + vnf.setVnfHostname(assignmentMap.get("vnfHostName")) + resource.getHomingSolution().setVnf(vnf) + resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) + } + } + } + } + if (JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")) { + String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo") + JSONArray licenseArr = new JSONArray(licenseInfo) + for (int l = 0; l < licenseArr.length(); l++) { + JSONObject license = licenseArr.getJSONObject(l) + String jsonServiceResourceId = license.getString("serviceResourceId") + for (Resource resource : resourceList) { + String serviceResourceId = resource.getResourceId() + if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) { + //match + String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList") + List entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) + resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) + + String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList") + List licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) + resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) + } + } + } + } + execution.setVariable("serviceDecomposition", decomposition) + execution.setVariable("homingSolution", placements) //TODO - can be removed as output variable + + utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled) + } catch (BpmnError b) { + throw b + } catch (Exception e) { + utils.log("DEBUG", "Error encountered within Homing ProcessHomingSolution method: " + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing ProcessHomingSolution") + } + } + + /** + * This method logs the start of DHVCreateService + * to make debugging easier. + * + * @param - execution + * @author cb645j + */ + public String logStart(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String requestId = execution.getVariable("testReqId") + if (isBlank(requestId)) { + requestId = execution.getVariable("msoRequestId") + } + execution.setVariable("DHVCS_requestId", requestId) + utils.log("DEBUG", "***** STARTED Homing Subflow for request: " + requestId + " *****", "true") + utils.log("DEBUG", "****** Homing Subflow Global Debug Enabled: " + isDebugEnabled + " *****", "true") + utils.logAudit("***** STARTED Homing Subflow for request: " + requestId + " *****") + } + + /** + * Auto-generated method stub + */ + public void preProcessRequest(DelegateExecution execution) {} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn index 481d1dfa6f..91a6546621 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn @@ -1,259 +1,404 @@ - - - - - SequenceFlow_1x9usa6 - - - SequenceFlow_1x9usa6 - SequenceFlow_10x3ocp - - - - - - SequenceFlow_1rf4vs8 - - - - SequenceFlow_00nlh7l - - - - SequenceFlow_00nlh7l - SequenceFlow_1rf4vs8 - - - - - - - - SequenceFlow_0kamg53 - SequenceFlow_1o7154s - - - - SequenceFlow_0kamg53 - - - - SequenceFlow_1o7154s - - - - - - - SequenceFlow_043r3j8 - SequenceFlow_1h9opg9 - - - - SequenceFlow_10x3ocp - badResponse - goodResponse - - - - badResponse - SequenceFlow_0clfkld - - - - - - SequenceFlow_0clfkld - - - - - - - - - - - - - - - - goodResponse - SequenceFlow_043r3j8 - - - - SequenceFlow_1h9opg9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + SequenceFlow_1x9usa6 + + + sniroCall + SequenceFlow_0gajic6 + + + + + + SequenceFlow_1rf4vs8 + + + + SequenceFlow_00nlh7l + + + + SequenceFlow_00nlh7l + SequenceFlow_1rf4vs8 + + + + + + + + SequenceFlow_0kamg53 + SequenceFlow_1o7154s + + + + SequenceFlow_0kamg53 + + + + SequenceFlow_1o7154s + + + + + + + sniroProcess + SequenceFlow_1h9opg9 + + + + SequenceFlow_12t0lqb + SequenceFlow_0gajic6 + badResponse + goodResponse + + + badResponse + SequenceFlow_0clfkld + + + + + + SequenceFlow_0clfkld + + + + + + + + + + + + + + + goodResponse + SequenceFlow_1fipbmk + + + + SequenceFlow_1h9opg9 + SequenceFlow_07u9d7f + + + + SequenceFlow_1x9usa6 + sniroCall + oofCall + SequenceFlow_02eywxz + + + oofCall + SequenceFlow_12t0lqb + + + + + + + + + + + + SequenceFlow_1fipbmk + sniroProcess + oofProcess + + + + + + + + + + oofProcess + SequenceFlow_07u9d7f + + + + + SequenceFlow_1bub8mj + + + + SequenceFlow_02eywxz + SequenceFlow_1bub8mj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java deleted file mode 100644 index 79bc96d6fd..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java +++ /dev/null @@ -1,546 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -package org.openecomp.mso.bpmn.common; - -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; -import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; -import org.junit.Test; - -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.bpmn.core.domain.*; -import org.openecomp.mso.bpmn.mock.FileUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; - - -/** - * Test the Homing subflow building block. - * - * @author cb645j - */ -public class HomingTest extends WorkflowTest { - - ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); - String subscriber = ""; - String subscriber2 = ""; - - private final CallbackSet callbacks = new CallbackSet(); - - public HomingTest() throws IOException { - String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf"); - String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net"); - String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf"); - String sniroCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound"); - String sniroCallbackPolicyException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException"); - String sniroCallbackServiceException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException"); - callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback); - callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2); - callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3); - callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution); - callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException); - callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException); - - // Service Model - ModelInfo sModel = new ModelInfo(); - sModel.setModelCustomizationUuid("testModelCustomizationUuid"); - sModel.setModelInstanceName("testModelInstanceName"); - sModel.setModelInvariantUuid("testModelInvariantId"); - sModel.setModelName("testModelName"); - sModel.setModelUuid("testModelUuid"); - sModel.setModelVersion("testModelVersion"); - // Service Instance - ServiceInstance si = new ServiceInstance(); - si.setInstanceId("testServiceInstanceId123"); - // Allotted Resources - List arList = new ArrayList(); - AllottedResource ar = new AllottedResource(); - ar.setResourceId("testResourceIdAR"); - ar.setResourceInstanceName("testARInstanceName"); - ModelInfo arModel = new ModelInfo(); - arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); - arModel.setModelInvariantUuid("testModelInvariantIdAR"); - arModel.setModelName("testModelNameAR"); - arModel.setModelVersion("testModelVersionAR"); - arModel.setModelUuid("testARModelUuid"); - arModel.setModelType("testModelTypeAR"); - ar.setModelInfo(arModel); - AllottedResource ar2 = new AllottedResource(); - ar2.setResourceId("testResourceIdAR2"); - ar2.setResourceInstanceName("testAR2InstanceName"); - ModelInfo arModel2 = new ModelInfo(); - arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); - arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); - arModel2.setModelName("testModelNameAR2"); - arModel2.setModelVersion("testModelVersionAR2"); - arModel2.setModelUuid("testAr2ModelUuid"); - arModel2.setModelType("testModelTypeAR2"); - ar2.setModelInfo(arModel2); - arList.add(ar); - arList.add(ar2); - // Vnfs - List vnfList = new ArrayList(); - VnfResource vnf = new VnfResource(); - vnf.setResourceId("testResourceIdVNF"); - vnf.setResourceInstanceName("testVnfInstanceName"); - ModelInfo vnfModel = new ModelInfo(); - vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF"); - vnfModel.setModelInvariantUuid("testModelInvariantIdVNF"); - vnfModel.setModelName("testModelNameVNF"); - vnfModel.setModelVersion("testModelVersionVNF"); - vnfModel.setModelUuid("testVnfModelUuid"); - vnfModel.setModelType("testModelTypeVNF"); - vnf.setModelInfo(vnfModel); - vnfList.add(vnf); - System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); - serviceDecomposition.setModelInfo(sModel); - serviceDecomposition.setServiceAllottedResources(arList); - serviceDecomposition.setServiceVnfs(vnfList); - serviceDecomposition.setServiceInstance(si); - - // Subscriber - subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(verifySniroRequest(), expectedSniroRequest); - - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf2Net() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables2(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro2"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet"); - HomingSolution resourceNetHoming = resourceNet.getHomingSolution(); - Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2"); - HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution(); - - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - String resourceNetHomingString = resourceNetHoming.toString(); - resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " "); - String resourceNetHoming2String = resourceNetHoming2.toString(); - resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " "); - expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic", "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String); - assertEquals(verifySniroRequest(), expectedSniroRequest); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_vnfResourceList() throws Exception { - - // Create a Service Decomposition - MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); - String busKey = UUID.randomUUID().toString(); - Map vars = new HashMap<>(); - setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); - invokeSubProcess("DecomposeService", busKey, vars); - - ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition"); - List vnfResourceList = sd.getServiceVnfs(); - vnfResourceList.get(0).setResourceId("test-resource-id-000"); - - // Invoke Homing - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", sd); - variables.put("subscriberInfo", subscriber2); - - invokeSubProcess("Homing", businessKey, variables); - injectWorkflowMessages(callbacks, "sniro3"); - waitForProcessEnd(businessKey, 10000); - - //Get Variables - - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - - Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); - HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); - - String resourceVnfHomingString = resourceVnfHoming.toString(); - resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); - - assertNull(workflowException); - - //Verify request - String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "")); - - assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "att-aic", "mtmnj1a", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_existingLicense() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - setVariablesExistingLicense(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - sniroRequest = sniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(verifySniroRequest_existingLicense(), sniroRequest); - - } - - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_inputVariable() throws Exception { - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables3(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_badResponse() throws Exception { - mockSNIRO_500(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro.]", workflowException.toString()); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroNoSolution() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroNoSol"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroPolicyException() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroPolicyEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroServiceException() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroServiceEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", workflowException.toString()); - } - - - - private void setVariables(Map variables) { - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - - } - - private void setVariables2(Map variables) { - List netList = new ArrayList(); - NetworkResource net = new NetworkResource(); - net.setResourceId("testResourceIdNet"); - ModelInfo netModel = new ModelInfo(); - netModel.setModelCustomizationUuid("testModelCustomizationUuidNet"); - netModel.setModelInvariantUuid("testModelInvariantIdNet"); - netModel.setModelName("testModelNameNet"); - netModel.setModelVersion("testModelVersionNet"); - net.setModelInfo(netModel); - netList.add(net); - NetworkResource net2 = new NetworkResource(); - net2.setResourceId("testResourceIdNet2"); - ModelInfo netModel2 = new ModelInfo(); - netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2"); - netModel2.setModelInvariantUuid("testModelInvariantIdNet2"); - netModel2.setModelName("testModelNameNet2"); - netModel2.setModelVersion("testModelVersionNet2"); - net2.setModelInfo(netModel2); - netList.add(net2); - serviceDecomposition.setServiceNetworks(netList); - - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - } - - private void setVariables3(Map variables) { - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", null); - variables.put("subscriberInfo", subscriber2); - - } - - private void setVariablesExistingLicense(Map variables) { - HomingSolution currentHomingSolution = new HomingSolution(); - serviceDecomposition.getServiceVnfs().get(0).setCurrentHomingSolution(currentHomingSolution); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2"); - - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2"); - - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - - } - - private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; - }else{ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; - }else{ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private void setVariablesForServiceDecomposition(Map variables, String requestId, String siId) { - variables.put("isDebugLogEnabled", "true"); - variables.put("mso-request-id", requestId); - variables.put("msoRequestId", requestId); - variables.put("serviceInstanceId",siId); - - String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + - "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\"," + - "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\"," + - "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," + - "\"modelVersion\": \"5.0\"," + - "}"; - variables.put("serviceModelInfo", serviceModelInfo); - } - - private String verifySniroRequest(){ - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"initial\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; - return request; - } - - private String verifySniroRequest_existingLicense(){ - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\",\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\",\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; - return request; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java new file mode 100644 index 0000000000..45645be7cd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java @@ -0,0 +1,824 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +package org.openecomp.mso.bpmn.common; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.core.domain.AllottedResource; +import org.openecomp.mso.bpmn.core.domain.HomingSolution; +import org.openecomp.mso.bpmn.core.domain.ModelInfo; +import org.openecomp.mso.bpmn.core.domain.NetworkResource; +import org.openecomp.mso.bpmn.core.domain.Resource; +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.bpmn.core.domain.ServiceInstance; +import org.openecomp.mso.bpmn.core.domain.VnfResource; +import org.openecomp.mso.bpmn.mock.FileUtil; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; +import static org.openecomp.mso.bpmn.mock.StubResponseOof.mockOof; +import static org.openecomp.mso.bpmn.mock.StubResponseOof.mockOof_500; + + +/** + * Test the OOF Homing subflow building block. + */ +public class OofHomingTest extends WorkflowTest { + + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); + String subscriber = ""; + String subscriber2 = ""; + + private final CallbackSet callbacks = new CallbackSet(); + + public OofHomingTest() throws IOException { + String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf"); + String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf"); + String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net"); + + String oofCallbackNoSolution = FileUtil. + readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound"); + String oofCallbackPolicyException = FileUtil. + readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException"); + String oofCallbackServiceException = FileUtil. + readResourceFile("__files/BuildingBlocks/oofCallbackServiceException"); + + callbacks.put("oof", JSON, "oofResponse", oofCallback); + callbacks.put("oof2", JSON, "oofResponse", oofCallback2); + callbacks.put("oof3", JSON, "oofResponse", oofCallback3); + callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution); + callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException); + callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException); + + // Service Model + ModelInfo sModel = new ModelInfo(); + sModel.setModelCustomizationName("testModelCustomizationName"); + sModel.setModelInstanceName("testModelInstanceName"); + sModel.setModelInvariantUuid("testModelInvariantId"); + sModel.setModelName("testModelName"); + sModel.setModelUuid("testModelUuid"); + sModel.setModelVersion("testModelVersion"); + // Service Instance + ServiceInstance si = new ServiceInstance(); + si.setInstanceId("testServiceInstanceId123"); + // Allotted Resources + List arList = new ArrayList(); + AllottedResource ar = new AllottedResource(); + ar.setResourceId("testResourceIdAR"); + ar.setResourceInstanceName("testARInstanceName"); + ModelInfo arModel = new ModelInfo(); + arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); + arModel.setModelInvariantUuid("testModelInvariantIdAR"); + arModel.setModelName("testModelNameAR"); + arModel.setModelVersion("testModelVersionAR"); + arModel.setModelUuid("testARModelUuid"); + arModel.setModelType("testModelTypeAR"); + ar.setModelInfo(arModel); + AllottedResource ar2 = new AllottedResource(); + ar2.setResourceId("testResourceIdAR2"); + ar2.setResourceInstanceName("testAR2InstanceName"); + ModelInfo arModel2 = new ModelInfo(); + arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); + arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); + arModel2.setModelName("testModelNameAR2"); + arModel2.setModelVersion("testModelVersionAR2"); + arModel2.setModelUuid("testAr2ModelUuid"); + arModel2.setModelType("testModelTypeAR2"); + ar2.setModelInfo(arModel2); + arList.add(ar); + arList.add(ar2); + // Vnfs + List vnfList = new ArrayList(); + VnfResource vnf = new VnfResource(); + vnf.setResourceId("testResourceIdVNF"); + vnf.setResourceInstanceName("testVnfInstanceName"); + ModelInfo vnfModel = new ModelInfo(); + vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF"); + vnfModel.setModelInvariantUuid("testModelInvariantIdVNF"); + vnfModel.setModelName("testModelNameVNF"); + vnfModel.setModelVersion("testModelVersionVNF"); + vnfModel.setModelUuid("testVnfModelUuid"); + vnfModel.setModelType("testModelTypeVNF"); + vnf.setModelInfo(vnfModel); + vnfList.add(vnf); + System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); + serviceDecomposition.setModelInfo(sModel); + serviceDecomposition.setServiceAllottedResources(arList); + serviceDecomposition.setServiceVnfs(vnfList); + serviceDecomposition.setServiceInstance(si); + + // Subscriber + subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; + subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_2AR1Vnf() throws Exception { + + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "oof2"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, + "serviceDecomposition"); + String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + expectedOofRequest = expectedOofRequest.replaceAll("\\s+", ""); + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", + resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx", + "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", + "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), + resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", + resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2", + null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3", + "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", + "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), + resourceVNFHomingString); + assertEquals(verifyOofRequest(), expectedOofRequest); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_2AR1Vnf2Net() throws Exception { + + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables2(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "oof3"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, + "serviceDecomposition"); + String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); + Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet"); + HomingSolution resourceNetHoming = resourceNet.getHomingSolution(); + Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2"); + HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution(); + + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + String resourceNetHomingString = resourceNetHoming.toString(); + resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " "); + String resourceNetHoming2String = resourceNetHoming2.toString(); + resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " "); + expectedOofRequest = expectedOofRequest.replaceAll("\\s+", ""); + + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", + resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx", + "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", + "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), + resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", + resourceARHoming2.getVnf().getResourceId(), + "aic", "testCloudRegionId2", + null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud","aic", + "testCloudRegionId3", + "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", + "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), + resourceVNFHomingString); + assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", + "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic", + "testCloudRegionIdNet", + null, null), resourceNetHomingString); + assertEquals(homingSolutionCloud("cloud", "aic", + "testCloudRegionIdNet2", + "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", + "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), + resourceNetHoming2String); + assertEquals(verifyOofRequest(), expectedOofRequest); + + } + + @Test + @Ignore + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_vnfResourceList() throws Exception { + + // Create a Service Decomposition + MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", + "/BuildingBlocks/oofCatalogResp.json"); + String busKey = UUID.randomUUID().toString(); + Map vars = new HashMap<>(); + setVariablesForServiceDecomposition(vars, "testRequestId123", + "ff5256d2-5a33-55df-13ab-12abad84e7ff"); + invokeSubProcess("DecomposeService", busKey, vars); + + ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, + "serviceDecomposition"); + System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd); + List vnfResourceList = sd.getServiceVnfs(); +//System.out.println(" vnfResourceList = " + vnfResourceList); + vnfResourceList.get(0).setResourceId("test-resource-id-000"); + + // Invoke Homing + + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + variables.put("homingService", "oof"); + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", sd); + variables.put("subscriberInfo", subscriber2); + HashMap customerLocation = new HashMap(); + customerLocation.put("customerLatitude", "32.89748"); + customerLocation.put("customerLongitude", "-97.040443"); + customerLocation.put("customerName", "xyz"); + variables.put("customerLatitude", "32.89748"); + variables.put("customerLongitude", "-97.040443"); + variables.put("customerName", "xyz"); + variables.put("customerLocation", customerLocation); + variables.put("cloudOwner", "amazon"); + variables.put("cloudRegionId", "TNZED"); + + invokeSubProcess("Homing", businessKey, variables); + injectWorkflowMessages(callbacks, "oof3"); + waitForProcessEnd(businessKey, 10000); + + //Get Variables + + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, + "serviceDecomposition"); + System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp); + + Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); + System.out.println("resourceVnf is: " + resourceVnf); + HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); + + String resourceVnfHomingString = resourceVnfHoming.toString(); + System.out.println("resourceVnfHomingString is: " + resourceVnfHomingString); + resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); + System.out.println("Now resourceVnfHomingString is: " + resourceVnfHomingString); + + assertNull(workflowException); + + //Verify request + String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); + System.out.println("oofRequest is: " + oofRequest); + assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf"). + replaceAll("\n", "").replaceAll("\r", ""). + replaceAll("\t", ""), oofRequest.replaceAll("\n", ""). + replaceAll("\r", "").replaceAll("\t", "")); + + //System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId()); + + assertEquals(homingSolutionService("service", "service-instance-01234", + "MDTNJ01", "test-resource-id-000","att-aic", + "mtmnj1a", + "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"", + "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString); + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_existingLicense() throws Exception { + + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesExistingLicense(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniro"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); + String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution(); + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + oofRequest = oofRequest.replaceAll("\\s+", ""); + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", + "aic", "dfwtx", "KDTNJ01", + "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", + "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), + resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", + resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2", + null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud", "aic", + "testCloudRegionId3", + "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", + "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), + resourceVNFHomingString); + assertEquals(verifyOofRequestExistingLicense(), oofRequest); + + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_inputVariable() throws Exception { + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables3(variables); + + invokeSubProcess("Homing", businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " + + "input variable is missing or null]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_badResponse() throws Exception { + mockOof_500(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a " + + "Bad Sync Response from Sniro/OOF.]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_oofNoSolution() throws Exception { + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "oofNoSol"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found " + + "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_oofPolicyException() throws Exception { + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "oofPolicyEx"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + + "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " + + "limit]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_oofServiceException() throws Exception { + mockOof(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "oofServiceEx"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, + "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + + "Response contains a Request Error Service Exception: OOF PlacementError: " + + "requests.exceptions.HTTPError: 404 Client Error: Not Found for " + + "url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", + workflowException.toString()); + } + + + private void setVariables(Map variables) { + variables.put("homingService", "oof"); + HashMap customerLocation = new HashMap(); + customerLocation.put("customerLatitude", "32.89748"); + customerLocation.put("customerLongitude", "-97.040443"); + customerLocation.put("customerName", "xyz"); + variables.put("customerLatitude", "32.89748"); + variables.put("customerLongitude", "-97.040443"); + variables.put("customerName", "xyz"); + variables.put("customerLocation", customerLocation); + variables.put("cloudOwner", "amazon"); + variables.put("cloudRegionId", "TNZED"); + variables.put("isDebugLogEnabled", "true"); + // variables.put("mso-request-id", "testRequestId"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + } + + private void setVariables2(Map variables) { + List netList = new ArrayList(); + NetworkResource net = new NetworkResource(); + net.setResourceId("testResourceIdNet"); + ModelInfo netModel = new ModelInfo(); + netModel.setModelCustomizationUuid("testModelCustomizationUuidNet"); + netModel.setModelInvariantUuid("testModelInvariantIdNet"); + netModel.setModelName("testModelNameNet"); + netModel.setModelVersion("testModelVersionNet"); + net.setModelInfo(netModel); + netList.add(net); + NetworkResource net2 = new NetworkResource(); + net2.setResourceId("testResourceIdNet2"); + ModelInfo netModel2 = new ModelInfo(); + netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2"); + netModel2.setModelCustomizationName("testModelCustomizationNameNet2"); + netModel2.setModelInvariantUuid("testModelInvariantIdNet2"); + netModel2.setModelName("testModelNameNet2"); + netModel2.setModelVersion("testModelVersionNet2"); + net2.setModelInfo(netModel2); + netList.add(net2); + serviceDecomposition.setServiceNetworks(netList); + + variables.put("homingService", "oof"); + HashMap customerLocation = new HashMap(); + customerLocation.put("customerLatitude", "32.89748"); + customerLocation.put("customerLongitude", "-97.040443"); + customerLocation.put("customerName", "xyz"); + variables.put("customerLatitude", "32.89748"); + variables.put("customerLongitude", "-97.040443"); + variables.put("customerName", "xyz"); + variables.put("customerLocation", customerLocation); + variables.put("cloudOwner", "amazon"); + variables.put("cloudRegionId", "TNZED"); + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + } + + private void setVariables3(Map variables) { + variables.put("homingService", "oof"); + HashMap customerLocation = new HashMap(); + customerLocation.put("customerLatitude", "32.89748"); + customerLocation.put("customerLongitude", "-97.040443"); + customerLocation.put("customerName", "xyz"); + variables.put("customerLatitude", "32.89748"); + variables.put("customerLongitude", "-97.040443"); + variables.put("customerName", "xyz"); + variables.put("customerLocation", customerLocation); + variables.put("cloudOwner", "amazon"); + variables.put("cloudRegionId", "TNZED"); + variables.put("isDebugLogEnabled", "true"); + // variables.put("mso-request-id", "testRequestId"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", null); + variables.put("subscriberInfo", subscriber2); + } + + private void setVariablesExistingLicense(Map variables) { + HomingSolution currentHomingSolution = new HomingSolution(); + serviceDecomposition.getServiceVnfs().get(0).setCurrentHomingSolution(currentHomingSolution); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1"); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2"); + + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1"); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2"); + + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + + } + + /*private String homingSolutionService(String resourceModuleName, String serviceInstanceId, String vnfHostname, String cloudOwner, + String cloudRegionId, String licenseList) { + String solution = ""; + if (licenseList == null || licenseList == "") { + solution = "{\n" + + " \"resourceModuleName\": \"" + resourceModuleName + "\",\n" + + " \"serviceResourceId\": \"some_resource_id\",\n" + + " \"solution\": {\n" + + " \"identifierType\": \"serviceInstanceId\",\n" + + " \"identifiers\": [\"" + serviceInstanceId + "\"]\n" + + " }\n" + + " \"assignmentInfo\": [\n" + + " { \"key\": \"cloudOwner\", \"value\": \"" + cloudOwner + "\" },\n" + + " { \"key\": \"vnfHostName\", \"value\": \"" + vnfHostname + "\" },\n" + + " { \"key\": \"isRehome\", \"value\": \"False\" },\n" + + " { \"key\": \"cloudRegionId\", \"value\": \"" + cloudRegionId + "\" }\n" + + " ]\n" + + " }"; + } else { + solution = "{\n" + + " \"resourceModuleName\": \"" + resourceModuleName + "\",\n" + + " \"serviceResourceId\": \"some_resource_id\",\n" + + " \"solution\": {\n" + + " \"identifierType\": \"service_instance_id\",\n" + + " \"identifiers\": [\"" + serviceInstanceId + "\"]\n" + + " }\n" + + " \"assignmentInfo\": [\n" + + " { \"key\": \"cloudOwner\", \"value\": \"" + cloudOwner + "\" },\n" + + " { \"key\": \"vnfHostName\", \"value\": \"" + vnfHostname + "\" },\n" + + " { \"key\": \"isRehome\", \"value\": \"False\" },\n" + + " { \"key\": \"cloudRegionId\", \"value\": \"" + cloudRegionId + "\" }\n" + + " ], " + + " \"licenseSolutions\" : [ {\"licenseKeyGroupUUID\": [" + licenseList + "]} ] " + + "}"; + } + return solution; + }*/ + private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, + String vnfResourceId, String cloudOwner, + String cloudRegionId, String enList, + String licenseList){ + + String solution = ""; + if(enList == null){ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + + cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId + + "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" + + " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," + + " \"rehome\" : false } }"; + }else{ + //language=JSON + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + + cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" + + " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" + + " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" + + " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; + } + return solution; + } + + /*private String homingSolutionCloud(String resourceModuleName, String cloudOwner, + String cloudRegionId, String licenseList) { + String solution = ""; + if (licenseList == null || licenseList == "") { + solution = "{\n" + + " \"resourceModuleName\": \"" + resourceModuleName + "\",\n" + + " \"serviceResourceId\": \"some_resource_id\",\n" + + " \"solution\": {\n" + + " \"identifierType\": \"cloudRegionId\",\n" + + " \"cloudOwner\": \"" + cloudOwner + "\",\n" + + " \"identifiers\": [\"" + cloudRegionId + "\"]\n" + + " }\n" + + " \"assignmentInfo\": [\n" + + " { \"key\": \"cloudOwner\", \"value\": \"" + cloudOwner + "\" },\n" + + " { \"key\": \"cloudRegionId\", \"value\": \"" + cloudRegionId + "\" }\n" + + " ]\n" + + "}"; + } else { + solution = "{\n" + + " \"resourceModuleName\": \"" + resourceModuleName + "\",\n" + + " \"serviceResourceId\": \"some_resource_id\",\n" + + " \"solution\": {\n" + + " \"identifierType\": \"cloudRegionId\",\n" + + " \"cloudOwner\": \"" + cloudOwner + "\",\n" + + " \"identifiers\": [\"" + cloudRegionId + "\"]\n" + + " }\n" + + " \"assignmentInfo\": [\n" + + " { \"key\": \"cloudOwner\", \"value\": \"" + cloudOwner + "\" },\n" + + " { \"key\": \"cloudRegionId\", \"value\": \"" + cloudRegionId + "\" }\n" + + " ]," + + " \"licenseSolutions\" : [ {\"licenseKeyGroupUUID\": [" + licenseList + "]} ] } " + + "}"; + } + return solution; + }*/ + private String homingSolutionCloud(String type, String cloudOwner, + String cloudRegionId, String enList, + String licenseList){ + String solution = ""; + if(enList == null){ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + + "\", \"license\" : { }, \"rehome\" : false } }"; + }else{ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + + licenseList + " ] }, \"rehome\" : false } }"; + } + return solution; + } + + private void setVariablesForServiceDecomposition(Map variables, String requestId, String siId) { + variables.put("homingService", "oof"); + variables.put("isDebugLogEnabled", "true"); + variables.put("mso-request-id", requestId); + variables.put("msoRequestId", requestId); + variables.put("serviceInstanceId", siId); + HashMap customerLocation = new HashMap(); + customerLocation.put("customerLatitude", "32.89748"); + customerLocation.put("customerLongitude", "-97.040443"); + customerLocation.put("customerName", "xyz"); + variables.put("customerLatitude", "32.89748"); + variables.put("customerLongitude", "-97.040443"); + variables.put("customerName", "xyz"); + variables.put("customerLocation", customerLocation); + variables.put("cloudOwner", "amazon"); + variables.put("cloudRegionId", "TNZED"); + + + String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" + + "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}"; + variables.put("serviceModelInfo", serviceModelInfo); + } + + private String verifyOofRequest() { + String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," + + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," + + "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," + + "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" + + "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" + + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," + + "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" + + ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" + + "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," + + "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" + + "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," + + "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," + + "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," + + "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," + + "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," + + "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" + + "{\"serviceInstanceId\":\"testServiceInstanceId123\"," + + "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" + + "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," + + "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" + + "\"}},\"licenseInfo\":{\"licenseDemands\":[{\"resourceModuleName\":\"VNF\",\"serviceResourceId\":" + + "\"testResourceIdVNF\",\"resourceInstanceType\":\"VNF\",\"resourceModelInfo\":{\"modelInvariantId\":" + + "\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":" + + "\"testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"," + + "\"modelCustomizationName\":\"\"}}]}}"; + return request; + } + + private String verifyOofRequestExistingLicense(){ + String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," + + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," + + "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," + + "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," + + "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" + + "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" + + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," + + "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" + + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," + + "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," + + "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," + + "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" + + "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" + + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" + + "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," + + "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," + + "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," + + "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" + + "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," + + "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" + + "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," + + "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," + + "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," + + "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," + + "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," + + "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" + + "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; + return request; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java new file mode 100644 index 0000000000..541dc6e7a9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java @@ -0,0 +1,548 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; +import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*; +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; + +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.core.domain.*; +import org.openecomp.mso.bpmn.mock.FileUtil; + + +/** + * Test the SNIRO Homing subflow building block. + */ +public class SniroHomingTest extends WorkflowTest { + + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); + String subscriber = ""; + String subscriber2 = ""; + + private final CallbackSet callbacks = new CallbackSet(); + + public SniroHomingTest() throws IOException { + String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf"); + String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net"); + String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf"); + String sniroCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound"); + String sniroCallbackPolicyException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException"); + String sniroCallbackServiceException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException"); + callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback); + callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2); + callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3); + callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution); + callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException); + callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException); + + // Service Model + ModelInfo sModel = new ModelInfo(); + sModel.setModelCustomizationUuid("testModelCustomizationUuid"); + sModel.setModelInstanceName("testModelInstanceName"); + sModel.setModelInvariantUuid("testModelInvariantId"); + sModel.setModelName("testModelName"); + sModel.setModelUuid("testModelUuid"); + sModel.setModelVersion("testModelVersion"); + // Service Instance + ServiceInstance si = new ServiceInstance(); + si.setInstanceId("testServiceInstanceId123"); + // Allotted Resources + List arList = new ArrayList(); + AllottedResource ar = new AllottedResource(); + ar.setResourceId("testResourceIdAR"); + ar.setResourceInstanceName("testARInstanceName"); + ModelInfo arModel = new ModelInfo(); + arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); + arModel.setModelInvariantUuid("testModelInvariantIdAR"); + arModel.setModelName("testModelNameAR"); + arModel.setModelVersion("testModelVersionAR"); + arModel.setModelUuid("testARModelUuid"); + arModel.setModelType("testModelTypeAR"); + ar.setModelInfo(arModel); + AllottedResource ar2 = new AllottedResource(); + ar2.setResourceId("testResourceIdAR2"); + ar2.setResourceInstanceName("testAR2InstanceName"); + ModelInfo arModel2 = new ModelInfo(); + arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); + arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); + arModel2.setModelName("testModelNameAR2"); + arModel2.setModelVersion("testModelVersionAR2"); + arModel2.setModelUuid("testAr2ModelUuid"); + arModel2.setModelType("testModelTypeAR2"); + ar2.setModelInfo(arModel2); + arList.add(ar); + arList.add(ar2); + // Vnfs + List vnfList = new ArrayList(); + VnfResource vnf = new VnfResource(); + vnf.setResourceId("testResourceIdVNF"); + vnf.setResourceInstanceName("testVnfInstanceName"); + ModelInfo vnfModel = new ModelInfo(); + vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF"); + vnfModel.setModelInvariantUuid("testModelInvariantIdVNF"); + vnfModel.setModelName("testModelNameVNF"); + vnfModel.setModelVersion("testModelVersionVNF"); + vnfModel.setModelUuid("testVnfModelUuid"); + vnfModel.setModelType("testModelTypeVNF"); + vnf.setModelInfo(vnfModel); + vnfList.add(vnf); + System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); + serviceDecomposition.setModelInfo(sModel); + serviceDecomposition.setServiceAllottedResources(arList); + serviceDecomposition.setServiceVnfs(vnfList); + serviceDecomposition.setServiceInstance(si); + + // Subscriber + subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; + subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_2AR1Vnf() throws Exception { + + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniro"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); + String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); + assertEquals(verifySniroRequest(), expectedSniroRequest); + + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_2AR1Vnf2Net() throws Exception { + + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables2(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniro2"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); + String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); + Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet"); + HomingSolution resourceNetHoming = resourceNet.getHomingSolution(); + Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2"); + HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution(); + + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + String resourceNetHomingString = resourceNetHoming.toString(); + resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " "); + String resourceNetHoming2String = resourceNetHoming2.toString(); + resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " "); + expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); + assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic", "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString); + assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String); + assertEquals(verifySniroRequest(), expectedSniroRequest); + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_vnfResourceList() throws Exception { + + // Create a Service Decomposition + MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); + String busKey = UUID.randomUUID().toString(); + Map vars = new HashMap<>(); + setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); + invokeSubProcess("DecomposeService", busKey, vars); + + ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition"); + List vnfResourceList = sd.getServiceVnfs(); + vnfResourceList.get(0).setResourceId("test-resource-id-000"); + + // Invoke Homing + + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + variables.put("homingService", "sniro"); + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", sd); + variables.put("subscriberInfo", subscriber2); + + invokeSubProcess("Homing", businessKey, variables); + injectWorkflowMessages(callbacks, "sniro3"); + waitForProcessEnd(businessKey, 10000); + + //Get Variables + + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); + + Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); + HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); + + String resourceVnfHomingString = resourceVnfHoming.toString(); + resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); + + assertNull(workflowException); + + //Verify request + String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); + assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "")); + + assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "att-aic", "mtmnj1a", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString); + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_success_existingLicense() throws Exception { + + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesExistingLicense(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniro"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); + String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); + + Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); + HomingSolution resourceARHoming = resourceAR.getHomingSolution(); + Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); + HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); + Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); + HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); + String resourceARHomingString = resourceARHoming.toString(); + resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); + String resourceARHoming2String = resourceARHoming2.toString(); + resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); + String resourceVNFHomingString = resourceVNFHoming.toString(); + resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); + sniroRequest = sniroRequest.replaceAll("\\s+", ""); + + assertNull(workflowException); + assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); + assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); + assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); + assertEquals(verifySniroRequest_existingLicense(), sniroRequest); + + } + + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_inputVariable() throws Exception { + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables3(variables); + + invokeSubProcess("Homing", businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_badResponse() throws Exception { + mockSNIRO_500(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro/OOF.]", workflowException.toString()); + } + + @Test + @Ignore // 1802 merge + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_sniroNoSolution() throws Exception { + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniroNoSol"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_sniroPolicyException() throws Exception { + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniroPolicyEx"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]", workflowException.toString()); + } + + @Test + @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) + public void testHoming_error_sniroServiceException() throws Exception { + mockSNIRO(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariables(variables); + + invokeSubProcess("Homing", businessKey, variables); + + injectWorkflowMessages(callbacks, "sniroServiceEx"); + + waitForProcessEnd(businessKey, 10000); + + //Get Variables + WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + + assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", workflowException.toString()); + } + + + + private void setVariables(Map variables) { + variables.put("homingService", "sniro"); + variables.put("isDebugLogEnabled", "true"); + // variables.put("mso-request-id", "testRequestId"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + + } + + private void setVariables2(Map variables) { + List netList = new ArrayList(); + NetworkResource net = new NetworkResource(); + net.setResourceId("testResourceIdNet"); + ModelInfo netModel = new ModelInfo(); + netModel.setModelCustomizationUuid("testModelCustomizationUuidNet"); + netModel.setModelInvariantUuid("testModelInvariantIdNet"); + netModel.setModelName("testModelNameNet"); + netModel.setModelVersion("testModelVersionNet"); + net.setModelInfo(netModel); + netList.add(net); + NetworkResource net2 = new NetworkResource(); + net2.setResourceId("testResourceIdNet2"); + ModelInfo netModel2 = new ModelInfo(); + netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2"); + netModel2.setModelInvariantUuid("testModelInvariantIdNet2"); + netModel2.setModelName("testModelNameNet2"); + netModel2.setModelVersion("testModelVersionNet2"); + net2.setModelInfo(netModel2); + netList.add(net2); + serviceDecomposition.setServiceNetworks(netList); + + variables.put("homingService", "sniro"); + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + } + + private void setVariables3(Map variables) { + variables.put("homingService", "sniro"); + variables.put("isDebugLogEnabled", "true"); + // variables.put("mso-request-id", "testRequestId"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", null); + variables.put("subscriberInfo", subscriber2); + + } + + private void setVariablesExistingLicense(Map variables) { + HomingSolution currentHomingSolution = new HomingSolution(); + serviceDecomposition.getServiceVnfs().get(0).setCurrentHomingSolution(currentHomingSolution); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1"); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2"); + + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1"); + serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2"); + + variables.put("isDebugLogEnabled", "true"); + // variables.put("mso-request-id", "testRequestId"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "testServiceInstanceId"); + variables.put("serviceDecomposition", serviceDecomposition); + variables.put("subscriberInfo", subscriber2); + + } + + private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ + String solution = ""; + if(enList == null){ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; + }else{ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; + } + return solution; + } + + private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ + String solution = ""; + if(enList == null){ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; + }else{ + solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; + } + return solution; + } + + private void setVariablesForServiceDecomposition(Map variables, String requestId, String siId) { + variables.put("homingService", "sniro"); + variables.put("isDebugLogEnabled", "true"); + variables.put("mso-request-id", requestId); + variables.put("msoRequestId", requestId); + variables.put("serviceInstanceId",siId); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\"," + + "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\"," + + "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," + + "\"modelVersion\": \"5.0\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + } + + private String verifySniroRequest(){ + String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"initial\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; + return request; + } + + private String verifySniroRequest_existingLicense(){ + String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\",\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\",\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; + return request; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java new file mode 100644 index 0000000000..b969b382c0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +package org.openecomp.mso.bpmn.mock; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; + +/** + * StubResponseOof.java class + */ +public class StubResponseOof { + + public static void setupAllMocks() { + + } + + public static void mockOof() { + stubFor(post(urlEqualTo("/api/oof/v1/placement")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/json"))); + } + + public static void mockOof(String responseFile) { + stubFor(post(urlEqualTo("/api/oof/v1/placement")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + + public static void mockOof_400() { + stubFor(post(urlEqualTo("/api/oof/v1/placement")) + .willReturn(aResponse() + .withStatus(400) + .withHeader("Content-Type", "application/json"))); + } + + public static void mockOof_500() { + stubFor(post(urlEqualTo("/api/oof/v1/placement")) + .willReturn(aResponse() + .withStatus(500) + .withHeader("Content-Type", "application/json"))); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf new file mode 100644 index 0000000000..3559708728 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf @@ -0,0 +1,109 @@ +{ + "transactionId": "testRequestId", + "requestId": "testRequestId", + "requestState": "complete", + "statusMessage": "success", + "solutions": { + "licenseSolutions": [ + { + "entitlementPoolUUID": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupUUID": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_primary_1", + "serviceResourceId": "testResourceIdAR" + }, + { + "entitlementPoolUUID": [ + "91d563e8-e714-4393-8f99-cc480144a05e", + "21d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupUUID": [ + "31d563e8-e714-4393-8f99-cc480144a05e", + "71d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_secondary_1", + "serviceResourceId": "testResourceIdVNF" + } + ], + "placementSolutions": [ + { + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceInstanceId": "testSIID1", + "serviceResourceId": "testResourceIdAR", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["testSIID1"] + }, + "assignmentInfo": [ + { + "key": "cloudOwner", + "value": "aic" + }, + { + "key": "vnfHostName", + "value": "MDTNJ01" + }, + { + "key": "isRehome", + "value": "False" + }, + { + "key": "cloudRegionId", + "value": "dfwtx" + } + ] + }, + { "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceResourceId": "testResourceIdAR2", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["testSIID2"] + }, + "assignmentInfo": [ + { + "key": "cloudOwner", + "value": "aic" + }, + { + "key": "vnfHostName", + "value": "testVnfHostname2" + }, + { + "key": "isRehome", + "value": "False" + }, + { + "key": "cloudRegionId", + "value": "testCloudRegionId2" + } + ] + }, + { + "resourceModuleName": "VNF", + "serviceResourceId": "testResourceIdVNF", + "solution": { + "identifierType": "cloudRegionId", + "cloudOwner": "aic", + "identifiers": [ + "testCloudRegionId3" + ] + }, + "assignmentInfo": [ + { + "key": "cloudOwner", + "value": "aic" + }, + { + "key": "cloudRegionId", + "value": "testCloudRegionId3" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf2Net b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf2Net new file mode 100644 index 0000000000..30fa09afd9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf2Net @@ -0,0 +1,116 @@ +{ + "transactionId": "testRequestId", + "requestId": "testRequestId", + "requestState": "completed", + "statusMessage": "success", + "solutions": { + "licenseSolutions": [ + { + "resourceModuleName": "vHNPortalaaS_primary_1", + "serviceResourceId": "testResourceIdAR", + "entitlementPoolUUID": ["f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e"], + "licenseKeyGroupUUID": ["s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e"], + "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"] + }, + { + "resourceModuleName": "net", + "serviceResourceId": "testResourceIdNet2", + "entitlementPoolUUID": ["f1d563e8-e714-4393-8f99-cc480144a05n", + "j1d563e8-e714-4393-8f99-cc480144a05n"], + "licenseKeyGroupUUID": ["s1d563e8-e714-4393-8f99-cc480144a05n", + "b1d563e8-e714-4393-8f99-cc480144a05n"], + "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"] + }, + { + "resourceModuleName": "vHNPortalaaS_secondary_1", + "serviceResourceId": "testResourceIdVNF", + "entitlementPoolUUID": ["91d563e8-e714-4393-8f99-cc480144a05e", + "21d563e8-e714-4393-8f99-cc480144a05e"], + "licenseKeyGroupUUID": [ "31d563e8-e714-4393-8f99-cc480144a05e", + "71d563e8-e714-4393-8f99-cc480144a05e"], + "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", + "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"] + }, + ], + "placementSolutions": [ + { + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceResourceId": "testResourceIdAR", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["testSIID1"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "aic" }, + { "key": "vnfHostName", "value": "MDTNJ01" }, + { "key": "isRehome", "value": "False" }, + { "key": "cloudRegionId", "value": "dfwtx" } + ] + }, + { + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceResourceId": "testResourceIdAR2", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["testSIID2"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "aic" }, + { "key": "vnfHostName", "value": "testVnfHostname2" }, + { "key": "isRehome", "value": "False" }, + { "key": "cloudRegionId", "value": "testCloudRegionId2" } + ] + }, + { + "resourceModuleName": "NETWORK", + "serviceResourceId": "testResourceIdNet", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["testServiceInstanceIdNet"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "aic" }, + { "key": "vnfHostName", "value": "testVnfHostNameNet" }, + { "key": "isRehome", "value": "False" }, + { "key": "cloudRegionId", "value": "testCloudRegionIdNet" } + ] + }, + { + "resourceModuleName": "NETWORK", + "serviceResourceId": "testResourceIdNet2", + "solution": { + "identifierType": "cloudRegionId", + "cloudOwner": "aic", + "identifiers": ["testCloudRegionIdNet2"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "aic" }, + { "key": "cloudRegionId", "value": "testCloudRegionIdNet2" } + ] + }, + { + "resourceModuleName": "VNF", + "serviceResourceId": "testResourceIdVNF", + "solution": { + "identifierType": "cloudRegionId", + "cloudOwner": "aic", + "identifiers": ["testCloudRegionId3"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "aic" }, + { "key": "cloudRegionId", "value": "testCloudRegionId3" } + ] + } + ] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackInfraVnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackInfraVnf new file mode 100644 index 0000000000..b4e748c6e7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackInfraVnf @@ -0,0 +1,47 @@ +{ + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "requestStatus": "completed", + "statusMessage": "success", + "solutions": { + "placementSolutions": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "some_resource_id", + "solution": { + "identifierType": "serviceInstanceId", + "identifiers": ["gjhd-098-fhd-987"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "amazon" }, + { "key": "vnfHostName", "value": "ahr344gh" }, + { "key": "isRehome", "value": "False" }, + { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" } + ] + }, + { + "resourceModuleName": "vG", + "serviceResourceId": "some_resource_id", + "solution": { + "identifierType": "cloudRegionId", + "cloudOwner": "amazon", + "identifiers": ["gjhd-098-fhd-987"] + }, + "assignmentInfo": [ + { "key": "cloudOwner", "value": "amazon" }, + { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" } + ] + } + ], + "licenseSolutions": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "some_resource_id", + "entitlementPoolUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "licenseKeyGroupUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"], + "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"] + } + ] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound new file mode 100644 index 0000000000..8bb29f0c0a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound @@ -0,0 +1,10 @@ +{ + "solutions": { + "placementSolutions": [], + "licenseSolutions": [] + }, + "transactionId": "08e1b8cf-144a-4bac-b293-d5e2eedc97e8", + "requestId": "02c2e322-5839-4c97-9d46-0a5fa6bb642e", + "requestStatus": "completed", + "statusMessage": "No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8" +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackPolicyException b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackPolicyException new file mode 100644 index 0000000000..b82688428e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackPolicyException @@ -0,0 +1,9 @@ +{ + "requestError": { + "policyException": { + "requestId": "ae81d9a8-c949-493a-999c-f76c80503233", + "text": "Message content size exceeds the allowable limit", + "messageId": "SVC0001" + } + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackServiceException b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackServiceException new file mode 100644 index 0000000000..de43e82c9e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackServiceException @@ -0,0 +1,12 @@ +{ + "requestError": { + "serviceException": { + "variables": [ + "severity", 400 + ], + "requestId": "ae81d9a8-c949-493a-999c-f76c80503233", + "text": "OOF PlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8", + "messageId": "SVC0001" + } + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCatalogResp.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCatalogResp.json new file mode 100644 index 0000000000..09026d1d8c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCatalogResp.json @@ -0,0 +1,47 @@ +{ + "serviceResources": { + "serviceType": null, + "serviceAllottedResources": [], + "modelInfo": { + "modelInvariantUuid": "1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", + "modelName": "ADIOD vRouter vCE 011017 Service", + "modelVersion": "5.0", + "modelUuid": "2f7f309d-c842-4644-a2e4-34167be5eeb4" + }, + "serviceRole": null, + "serviceVnfs": [ + { + "toscaNodeType": "org.openecomp.resource.vf.AdiodVce", + "vfModules": [ + { + "initialCount": null, + "vfModuleLabel": null, + "modelInfo": { + "modelInvariantUuid": "7fb428e1-8000-4800-a71a-f21b946973c5", + "modelName": "AdiodVce..base_vCE..module-0", + "modelVersion": "2", + "modelCustomizationUuid": "1126e7e2-b377-4fd2-ad48-660a20caa829", + "modelUuid": "435d57e1-93a2-4d58-aa5d-f2df2d126276" + }, + "hasVolumeGroup": true, + "isBase": true + } + ], + "modelInfo": { + "modelInvariantUuid": "fc72435b-4366-4257-a2f7-c70a3a998a7b", + "modelName": "ADIoD vCE", + "modelVersion": "2.0", + "modelCustomizationUuid": "bdaeed40-c964-4966-bdb8-51320dcaf587", + "modelInstanceName": "ADIoD vCE 0", + "modelUuid": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1" + }, + "nfRole": "", + "nfType": "", + "nfFunction": "", + "nfNamingCode": "", + "multiStageDesign": "N" + } + ], + "serviceNetworks": [] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest new file mode 100644 index 0000000000..42b2a0f24a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest @@ -0,0 +1,99 @@ +{ + "requestInfo": { + "transactionId": "testRequestId-xxx-xxx", + "requestId": "testRequestId-yyy-yyy", + "callbackUrl": "http://localhost:28090/workflows/messages/message/oofResponse/testRequestId", + "sourceId": "so", + "requestType": "create", + "numSolutions": 1, + "optimizers": ["placement"], + "timeout": 600 + }, + "placementInfo": { + "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" }, + "placementDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "tenantId": "vGMuxInfra-tenant", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vGMuxInfra-customeModelName" + } + }, + { + "resourceModuleName": "vG", + "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e", + "tenantId": "vG-tenant", + "resourceModelInfo": { + "modelInvariantId": "vG-modelInvariantId", + "modelVersionId": "vG-versionId", + "modelName": "vG-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vG-customeModelName" + }, + "existingCandidates": [ + { + "identifierType": "service_instance_id", + "cloudOwner": "", + "identifiers": ["gjhd-098-fhd-987"] + } + ], + "excludedCandidates": [ + { + "identifierType": "service_instance_id", + "cloudOwner": "", + "identifiers": ["gjhd-098-fhd-987"] + }, + { + "identifierType": "vimId", + "cloudOwner": "vmware", + "identifiers": ["NYMDT67"] + } + ], + "requiredCandidates": [ + { + "identifierType": "vimId", + "cloudOwner": "amazon", + "identifiers": ["TXAUS219"] + } + ] + } + ] + }, + "serviceInfo": { + "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec", + "serviceName": "vCPE", + "modelInfo": { + "modelInvariantId": "vCPE-invariantId", + "modelVersionId": "vCPE-versionId", + "modelName": "vCPE-model", + "modelType": "service", + "modelVersion": "1.0", + "modelCustomizationName": "" + } + }, + "licenseDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "" + }, + "existingLicenses": { + "entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"], + "licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"] + } + } + ] +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest_infravnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest_infravnf new file mode 100644 index 0000000000..67c9fbedc9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofRequest_infravnf @@ -0,0 +1,56 @@ +{ + "requestInfo": { + "transactionId": "testRequestId", + "requestId": "testRequestId", + "callbackUrl": "http://localhost:28090/workflows/messages/message/oofResponse/testRequestId", + "sourceId": "so", + "requestType": "create", + "numSolutions": 1, + "optimizers": ["placement"], + "timeout": 600 }, + "placementInfo": { + "requestParameters": { + "customerLatitude": "32.89748", + "customerLongitude": "-97.040443", + "customerName": "xyz" }, + "subscriberInfo": { "globalSubscriberId": "SUB12_0322_DS_1201", + "subscriberName": "SUB_12_0322_DS_1201", + "subscriberCommonSiteId": "" }, + "placementDemands": [ + {"resourceModuleName": "VNF","serviceResourceId": "test-resource-id-000","tenantId": "null","resourceModelInfo": { + "modelInvariantId": "fc72435b-4366-4257-a2f7-c70a3a998a7b", + "modelVersionId": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1", + "modelName": "ADIoD vCE", + "modelType": "", + "modelVersion": "2.0", + "modelCustomizationName": "" }} + ] + }, + "serviceInfo": { + "serviceInstanceId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "serviceName": "null", + "modelInfo": { + "modelType": "", + "modelInvariantId": "1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", + "modelVersionId": "2f7f309d-c842-4644-a2e4-34167be5eeb4", + "modelName": "ADIOD vRouter vCE 011017 Service", + "modelVersion": "5.0", + "modelCustomizationName": "" + } + }, + "licenseInfo": { + "licenseDemands": [ + { +"resourceModuleName": "VNF", +"serviceResourceId": "test-resource-id-000", +"resourceInstanceType": "VNF", +"resourceModelInfo": { + "modelInvariantId": "fc72435b-4366-4257-a2f7-c70a3a998a7b", + "modelVersionId": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1", + "modelName": "ADIoD vCE", + "modelType": "", + "modelVersion": "2.0", + "modelCustomizationName": "" + } + }] + }} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties index 049fc7c551..539d365150 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -1,131 +1,137 @@ -# Default URN Mappings for unit tests - -mso.rollback=true - -canopi.auth=757A94191D685FD2092AC1490730A4FC -csi.aots.addincidentmanagement.endpoint=http://localhost:28090/AddIncidentManagementTicketRequest -csi.networkstatus.endpoint=http://localhost:28090/SendManagedNetworkStatusNotification -mso.csi.pwd=4EA237303511EFBBC37F17A351562131 -mso.csi.usrname=mso -mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 - -mso.healthcheck.log.debug=false - -mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess - -mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter -mso.adapters.openecomp.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter -mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC - -mso.adapters.network.endpoint=http://localhost:28090/networks/NetworkAdapter -mso.adapters.network.rest.endpoint=http://localhost:28090/networks/rest/v1/networks - -mso.adapters.po.auth=757A94191D685FD2092AC1490730A4FC -mso.adapters.po.password=3141634BF7E070AA289CF2892C986C0B -mso.po.timeout=PT60S -mso.default.adapter.namespace=http://org.openecomp.mso -mso.adapters.workflow.message.endpoint=http://localhost:28090/workflows/messages/message - -aai.auth=26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764 - -policy.endpoint=https://mtanjvsgcvm02.nvp.cip.att.com:8081/pdp/api/ -policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk -policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw== -policy.environment=TEST - -appc.topic.read=APPC-TEST-AMDOCS2 -appc.topic.write=APPC-TEST-AMDOCS1-DEV3 -appc.topic.read.timeout=120000 -appc.client.response.timeout=120000 -appc.service=ueb -appc.poolMembers=uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904 -appc.client.key=iaEMAfjsVsZnraBP -appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz - -mso.adapters.sdnc.endpoint=http://localhost:28090/SDNCAdapter -mso.adapters.sdnc.rest.endpoint=http://localhost:28090/SDNCAdapter/v1/sdnc -mso.adapters.sdnc.timeout=PT60S -mso.sdnc.firewall.yang.model=http://com/openecomp/svc/mis/firewall-lite-gui -mso.sdnc.firewall.yang.model.version=2015-05-15 -mso.sdnc.password=3141634BF7E070AA289CF2892C986C0B -mso.sdnc.timeout.firewall.minutes=20 -mso.callbackRetryAttempts=5 -mso.sdnc.timeout=PT10S -mso.sdnc.timeout.ucpe.async.hours=120 -mso.sdnc.timeout.ucpe.async.minutes=5 -mso.workflow.message.endpoint=http://localhost:28080/mso/WorkflowMesssage -mso.workflow.sdncadapter.callback=http://localhost:28080/mso/SDNCAdapterCallbackService - -mso.sniro.auth=test:testpwd -mso.sniro.timeout=PT30M -mso.sniro.policies.dhv.2vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 -mso.sniro.policies.dhv.4vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.VNFPolicy_vvigprimary2_v1,SNIRO.VNFPolicy_vvigsecondary2_v1,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 - -mso.service.agnostic.sniro.host=http://localhost:28090 -mso.service.agnostic.sniro.endpoint=/sniro/api/v2/placement - -mso.catalog.db.endpoint=http://localhost:28090/ - -ruby.create-ticket-request.dmaap.username=m04768@mso.ecomp.att.com -ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc -ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 - - -mso.adapters.tenant.endpoint=http://localhost:28090/tenantAdapterMock -mso.adapters.vnf-async.endpoint=http://localhost:28090/vnfs/VnfAdapterAsync -mso.adapters.vnf.endpoint=http://localhost:28090/vnfs/VnfAdapter -mso.adapters.vnf.rest.endpoint=http://localhost:28090/vnfs/rest/v1/vnfs -mso.workflow.vnfadapter.create.callback=http://localhost:28080/mso/vnfAdapterNotify -mso.workflow.vnfadapter.delete.callback=http://localhost:28080/mso/vnfAdapterNotify -mso.workflow.vnfadapter.query.callback=http://localhost:28080/mso/services/VNFAdapterQuerCallbackV1 -mso.workflow.vnfadapter.rollback.callback=http://localhost:28080/mso/vnfAdapterNotify -mso.workflow.createvce.delay.seconds=1 -mso.infra.customer.id=testCustIdInfra - -aai.endpoint=http://localhost:28090 - -# AAI version mappings - -# Example to override default version for a resource: -#mso.workflow.default.aai.vce.version=6 -#mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce -mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ -mso.workflow.global.default.aai.version=8 -mso.workflow.default.aai.cloud-region.version=9 -mso.workflow.default.aai.generic-vnf.version=9 - -mso.workflow.default.aai.v9.cloud-region.uri=/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic -mso.workflow.default.aai.v8.customer.uri=/aai/v8/business/customers/customer -mso.workflow.default.aai.v8.generic-query.uri=/aai/v8/search/generic-query -mso.workflow.default.aai.v9.generic-vnf.uri=/aai/v9/network/generic-vnfs/generic-vnf -mso.workflow.default.aai.v8.l3-network.uri=/aai/v8/network/l3-networks/l3-network -mso.workflow.default.aai.v8.network-policy.uri=/aai/v8/network/network-policies/network-policy -mso.workflow.default.aai.v8.nodes-query.uri=/aai/v8/search/nodes-query -mso.workflow.default.aai.v8.route-table-reference.uri=/aai/v8/network/route-table-references/route-table-reference -mso.workflow.default.aai.v8.tenant.uri=/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant -mso.workflow.default.aai.v8.vce.uri=/aai/v8/network/vces/vce -mso.workflow.default.aai.v8.vpn-binding.uri=/aai/v8/network/vpn-bindings/vpn-binding -mso.workflow.notification.name=GenericNotificationService -mso.bpmn.optimisticlockingexception.retrycount=3 - -log.debug.CompleteMsoProcess=true -log.debug.CreateNetworkInstanceInfra=true -log.debug.CreateServiceInstanceInfra=true -log.debug.DeleteNetworkInstanceInfra=true -log.debug.FalloutHandler=true -log.debug.GenericGetService=true -log.debug.sdncAdapter=true -log.debug.UpdateNetworkInstanceInfra=true -log.debug.VnfAdapterRestV1=true -log.debug.GenericGetNetwork=true -log.debug.GenericGetVnf=true -log.debug.GenericDeleteService=true -log.debug.GenericDeleteNetwork=true -log.debug.GenericDeleteVnf=true -log.debug.vnfAdapterCreateV1=true -log.debug.vnfAdapterRestV1=true - -sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com -sdno.health-check.dmaap.password=eHQ1cUJrOUc -sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 +# Default URN Mappings for unit tests + +mso.rollback=true + +canopi.auth=757A94191D685FD2092AC1490730A4FC +csi.aots.addincidentmanagement.endpoint=http://localhost:28090/AddIncidentManagementTicketRequest +csi.networkstatus.endpoint=http://localhost:28090/SendManagedNetworkStatusNotification +mso.csi.pwd=4EA237303511EFBBC37F17A351562131 +mso.csi.usrname=mso +mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 + +mso.healthcheck.log.debug=false + +mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess + +mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter +mso.adapters.openecomp.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter +mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC + +mso.adapters.network.endpoint=http://localhost:28090/networks/NetworkAdapter +mso.adapters.network.rest.endpoint=http://localhost:28090/networks/rest/v1/networks + +mso.adapters.po.auth=757A94191D685FD2092AC1490730A4FC +mso.adapters.po.password=3141634BF7E070AA289CF2892C986C0B +mso.po.timeout=PT60S +mso.default.adapter.namespace=http://org.openecomp.mso +mso.adapters.workflow.message.endpoint=http://localhost:28090/workflows/messages/message + +aai.auth=26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764 + +policy.endpoint=https://mtanjvsgcvm02.nvp.cip.att.com:8081/pdp/api/ +policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk +policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw== +policy.environment=TEST + +appc.topic.read=APPC-TEST-AMDOCS2 +appc.topic.write=APPC-TEST-AMDOCS1-DEV3 +appc.topic.read.timeout=120000 +appc.client.response.timeout=120000 +appc.service=ueb +appc.poolMembers=uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904 +appc.client.key=iaEMAfjsVsZnraBP +appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz + +mso.adapters.sdnc.endpoint=http://localhost:28090/SDNCAdapter +mso.adapters.sdnc.rest.endpoint=http://localhost:28090/SDNCAdapter/v1/sdnc +mso.adapters.sdnc.timeout=PT60S +mso.sdnc.firewall.yang.model=http://com/openecomp/svc/mis/firewall-lite-gui +mso.sdnc.firewall.yang.model.version=2015-05-15 +mso.sdnc.password=3141634BF7E070AA289CF2892C986C0B +mso.sdnc.timeout.firewall.minutes=20 +mso.callbackRetryAttempts=5 +mso.sdnc.timeout=PT10S +mso.sdnc.timeout.ucpe.async.hours=120 +mso.sdnc.timeout.ucpe.async.minutes=5 +mso.workflow.message.endpoint=http://localhost:28080/mso/WorkflowMesssage +mso.workflow.sdncadapter.callback=http://localhost:28080/mso/SDNCAdapterCallbackService + +mso.sniro.auth=test:testpwd +mso.sniro.timeout=PT30M +mso.sniro.policies.dhv.2vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 +mso.sniro.policies.dhv.4vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.VNFPolicy_vvigprimary2_v1,SNIRO.VNFPolicy_vvigsecondary2_v1,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 + +mso.service.agnostic.sniro.host=http://localhost:28090 +mso.service.agnostic.sniro.endpoint=/sniro/api/v2/placement + +mso.oof.auth=test:testpwd +mso.oof.endpoint=http://localhost:28090/api/oof/v1/placement +mso.oof.timeout=PT30M +mso.service.agnostic.oof.host=http://localhost:28090 +mso.service.agnostic.oof.endpoint=/api/oof/v1/placement + +mso.catalog.db.endpoint=http://localhost:28090/ + +ruby.create-ticket-request.dmaap.username=m04768@mso.ecomp.att.com +ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc +ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 + + +mso.adapters.tenant.endpoint=http://localhost:28090/tenantAdapterMock +mso.adapters.vnf-async.endpoint=http://localhost:28090/vnfs/VnfAdapterAsync +mso.adapters.vnf.endpoint=http://localhost:28090/vnfs/VnfAdapter +mso.adapters.vnf.rest.endpoint=http://localhost:28090/vnfs/rest/v1/vnfs +mso.workflow.vnfadapter.create.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.vnfadapter.delete.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.vnfadapter.query.callback=http://localhost:28080/mso/services/VNFAdapterQuerCallbackV1 +mso.workflow.vnfadapter.rollback.callback=http://localhost:28080/mso/vnfAdapterNotify +mso.workflow.createvce.delay.seconds=1 +mso.infra.customer.id=testCustIdInfra + +aai.endpoint=http://localhost:28090 + +# AAI version mappings + +# Example to override default version for a resource: +#mso.workflow.default.aai.vce.version=6 +#mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce +mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ +mso.workflow.global.default.aai.version=8 +mso.workflow.default.aai.cloud-region.version=9 +mso.workflow.default.aai.generic-vnf.version=9 + +mso.workflow.default.aai.v9.cloud-region.uri=/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic +mso.workflow.default.aai.v8.customer.uri=/aai/v8/business/customers/customer +mso.workflow.default.aai.v8.generic-query.uri=/aai/v8/search/generic-query +mso.workflow.default.aai.v9.generic-vnf.uri=/aai/v9/network/generic-vnfs/generic-vnf +mso.workflow.default.aai.v8.l3-network.uri=/aai/v8/network/l3-networks/l3-network +mso.workflow.default.aai.v8.network-policy.uri=/aai/v8/network/network-policies/network-policy +mso.workflow.default.aai.v8.nodes-query.uri=/aai/v8/search/nodes-query +mso.workflow.default.aai.v8.route-table-reference.uri=/aai/v8/network/route-table-references/route-table-reference +mso.workflow.default.aai.v8.tenant.uri=/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant +mso.workflow.default.aai.v8.vce.uri=/aai/v8/network/vces/vce +mso.workflow.default.aai.v8.vpn-binding.uri=/aai/v8/network/vpn-bindings/vpn-binding +mso.workflow.notification.name=GenericNotificationService +mso.bpmn.optimisticlockingexception.retrycount=3 + +log.debug.CompleteMsoProcess=true +log.debug.CreateNetworkInstanceInfra=true +log.debug.CreateServiceInstanceInfra=true +log.debug.DeleteNetworkInstanceInfra=true +log.debug.FalloutHandler=true +log.debug.GenericGetService=true +log.debug.sdncAdapter=true +log.debug.UpdateNetworkInstanceInfra=true +log.debug.VnfAdapterRestV1=true +log.debug.GenericGetNetwork=true +log.debug.GenericGetVnf=true +log.debug.GenericDeleteService=true +log.debug.GenericDeleteNetwork=true +log.debug.GenericDeleteVnf=true +log.debug.vnfAdapterCreateV1=true +log.debug.vnfAdapterRestV1=true + +sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com +sdno.health-check.dmaap.password=eHQ1cUJrOUc +sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 \ No newline at end of file -- cgit 1.2.3-korg