From: Benjamin, Max (mb388a) Date: Fri, 4 Jan 2019 03:50:11 +0000 (-0500) Subject: Bugfixes for December 2018 X-Git-Tag: 1.4.1~382 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=f49313bb87e0dc2ee20f5621c6858d119e5f8f83;p=so.git Bugfixes for December 2018 Changed the way that the cidr is constructed in network utils. added in the if statement to check if selflink already exists removed execution line that was not needed in pull added service instance id to workflowResourceIds for virtualLinkKey network flows wrote test for updating request to complete in db workflow action directly updates db instead of using mso complete process Increase max timeout for SDNO Health Checks dmaap. Added execution variable and corrected type and way data is retrieved to fix defect fixed retry status message in request db for #/5 updated workflowActionBBTasks for flow status message updated flow status to failed on a workflowaction fail Removed slashes and fixed rollbackStatusMessage Updated requestStatus logic for adding status messages Added junit test to validate casue of a defect and cleaned up code and logging added end timestamp to request db on complete request fixed l3Network update of orchestation status in DoUpdateNetworkInstance groovy as well fixed update of l3network orchestration status Add explicit resetting of heatStackId in A&AI to DeleteVfModule and DeleteVolumeGroup BBs. Preserve heatStackId setting in the copiedVfModule when updating the VF Module in A&AI. added functionality to skip rollback based on flag Update snapshot version for logging, add headers fixed optional of error in retrieveErrorMessage method Set heatStackId to null if we want to remove it in A&AI. added in a warn logger statement to keep track of field map network technology from l3network instead of model info for network adapter object mapper Force heatStackId value to empty on an attempt to set it to null on update updated common pom to use aai schema version 1.4.1 removed handle sync error from SDNCHandler bpmn flow Change-Id: I1bd7aa55b06d4e439000b216165c9daafeacc9a4 Issue-ID: SO-1361 Signed-off-by: Benjamin, Max (mb388a) --- diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index aaf6cc7d70..e427423763 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -33,6 +33,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.logger.MessageEnum; @@ -40,6 +41,7 @@ import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.onap.so.utils.CryptoUtils; +import org.slf4j.MDC; import org.springframework.core.env.Environment; /** @@ -123,6 +125,9 @@ public class BPRestCallback { env.getProperty(Constants.ENCRYPTION_KEY_PROP)); String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); method.setHeader("Authorization", authorization); + method.setHeader(ONAPLogConstants.Headers.REQUEST_ID,MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + method.setHeader(ONAPLogConstants.Headers.INVOCATION_ID,MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + method.setHeader(ONAPLogConstants.Headers.PARTNER_NAME,"SO-SDNCAdapter"); } catch (Exception e) { LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, "Unable to set authorization in callback request", e); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index c1199aefd7..23231df6be 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -477,7 +477,7 @@ class NetworkUtils { networkStartAddress = subnet.getNetworkStartAddress() } if (element == "cidr-mask") { - xmlBuild += ""+networkStartAddress+"/"+var+"" + xmlBuild += ""+networkStartAddress+"/"+ subnet.getCidrMask() +"" } } if (element == "dhcp-enabled") { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 8aff0f715d..78af8768f9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -365,16 +365,15 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead. execution.setVariable("WorkflowResponse", callback) + callback = utils.removeXmlPreamble(callback) + Node root = new XmlParser().parseText(callback) if (root.name().endsWith('Exception')) { vnfAdapterWorkflowException(execution, callback) } } catch (Exception e) { - e.printStackTrace() - callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback - String msg = "Received error from VnfAdapter: " + callback - msoLogger.debug(getProcessKey(execution) + ': ' + msg) - exceptionUtil.buildWorkflowException(execution, 7020, msg) + msoLogger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e) + exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method") } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index ba9426d88a..6c2df13c61 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -76,43 +76,54 @@ public class ExecuteBuildingBlockRainyDay { Map lookupKeyMap = (Map) execution.getVariable("lookupKeyMap"); String serviceType = ASTERISK; boolean aLaCarte = (boolean) execution.getVariable("aLaCarte"); - try { - serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType(); - } catch (Exception ex) { - // keep default serviceType value - } - String vnfType = ASTERISK; - try { - for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) { - if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { - vnfType = vnf.getVnfType(); + boolean suppressRollback = (boolean) execution.getVariable("suppressRollback"); + String handlingCode = ""; + if(suppressRollback){ + handlingCode = "Abort"; + }else{ + try { + serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType(); + } catch (Exception ex) { + // keep default serviceType value + } + String vnfType = ASTERISK; + try { + for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) { + if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnfType = vnf.getVnfType(); + } } + } catch (Exception ex) { + // keep default vnfType value } - } catch (Exception ex) { - // keep default vnfType value - } - WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); - String errorCode = ASTERISK; - try { - errorCode = "" + workflowException.getErrorCode(); - } catch (Exception ex) { - // keep default errorCode value - } - String workStep = ASTERISK; - try { - workStep = workflowException.getWorkStep(); - } catch (Exception ex) { - // keep default workStep value - } - //Extract error data to be returned to WorkflowAction - execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); - RainyDayHandlerStatus rainyDayHandlerStatus; - String handlingCode = ""; - rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep); - if(rainyDayHandlerStatus==null){ - rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK); + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + String errorCode = ASTERISK; + try { + errorCode = "" + workflowException.getErrorCode(); + } catch (Exception ex) { + // keep default errorCode value + } + String workStep = ASTERISK; + try { + workStep = workflowException.getWorkStep(); + } catch (Exception ex) { + // keep default workStep value + } + //Extract error data to be returned to WorkflowAction + execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); + RainyDayHandlerStatus rainyDayHandlerStatus; + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep); if(rainyDayHandlerStatus==null){ - handlingCode = "Abort"; + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK); + if(rainyDayHandlerStatus==null){ + handlingCode = "Abort"; + }else{ + if(primaryPolicy){ + handlingCode = rainyDayHandlerStatus.getPolicy(); + }else{ + handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); + } + } }else{ if(primaryPolicy){ handlingCode = rainyDayHandlerStatus.getPolicy(); @@ -120,26 +131,20 @@ public class ExecuteBuildingBlockRainyDay { handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); } } - }else{ - if(primaryPolicy){ - handlingCode = rainyDayHandlerStatus.getPolicy(); - }else{ - handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); + if(!primaryPolicy){ + try{ + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + request.setRetryStatusMessage("Retries have been exhausted."); + requestDbclient.updateInfraActiveRequests(request); + } catch(Exception ex){ + msoLogger.debug(ex.toString()); + msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status"); + } } - } - if(!primaryPolicy){ - try{ - InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - request.setRetryStatusMessage("Retries have been exhausted."); - requestDbclient.updateInfraActiveRequests(request); - } catch(Exception ex){ - msoLogger.debug(ex.toString()); - msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status"); + if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){ + handlingCode = "Rollback"; } } - if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){ - handlingCode = "Rollback"; - } msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); } catch (Exception e) { diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy index 77edd2dc6d..72cde00877 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy @@ -7,9 +7,9 @@ * 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. @@ -34,14 +34,14 @@ import static org.junit.Assert.*; @RunWith(MockitoJUnitRunner.class) public class VnfAdapterRestV1Test { - + @Before public void init() { MockitoAnnotations.initMocks(this) } - + @Test public void testPreProcessRequest() { @@ -59,11 +59,11 @@ public class VnfAdapterRestV1Test { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey") - + VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1() vnfAdapterRestV1.preProcessRequest(mockExecution) - + MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() //debugger.printInvocations(mockExecution) @@ -78,7 +78,7 @@ public class VnfAdapterRestV1Test { verify(mockExecution).setVariable("VNFREST_vnfAdapterUrl","http://localhost:18080/vnfs/rest/v1/vnfs/6d2e2469-8708-47c3-a0d4-73fa28a8a50b/vf-modules") } - + def rollbackReq = """ @@ -97,7 +97,7 @@ public class VnfAdapterRestV1Test { http://localhost:8080/mso/WorkflowMessage/VNFAResponse/683ca1ac-2145-4a00-9484-20d48bd701aa """ - + @Test public void testGetVolumeGroupId() { Node root = new XmlParser().parseText(rollbackReq) @@ -106,13 +106,29 @@ public class VnfAdapterRestV1Test { assertEquals('8a07b246-155e-4b08-b56e-76e98a3c2d66', volGrpId) } - + @Test public void testGetMessageId() { Node root = new XmlParser().parseText(rollbackReq) - + VnfAdapterRestV1 p = new VnfAdapterRestV1() def messageId = p.getMessageIdForVolumeGroupRollback(root) assertEquals('683ca1ac-2145-4a00-9484-20d48bd701aa', messageId) } + + @Test + public void testProcessCallback() { + + String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfAdapterCallback.xml"); + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("VNFAResponse_MESSAGE")).thenReturn(sdncAdapterWorkflowRequest) + when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey") + + VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1() + vnfAdapterRestV1.processCallback(mockExecution) + + verify(mockExecution).setVariable("testProcessKeyResponse" ,sdncAdapterWorkflowRequest) + + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index fc2de4307b..9af9b2f2c9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -91,7 +91,9 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -113,6 +115,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode(ASTERISK); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -136,7 +140,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); - + delegateExecution.setVariable("suppressRollback", false); + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); assertEquals("Abort", delegateExecution.getVariable("handlingCode")); @@ -147,6 +152,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + delegateExecution.setVariable("suppressRollback", false); assertEquals("Abort", delegateExecution.getVariable("handlingCode")); } @@ -157,6 +163,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); @@ -180,6 +187,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", false); + delegateExecution.setVariable("suppressRollback", false); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); @@ -203,6 +211,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); @@ -220,4 +229,12 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode")); } + @Test + public void suppressRollbackTest() throws Exception { + delegateExecution.setVariable("suppressRollback", true); + delegateExecution.setVariable("aLaCarte", true); + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + assertEquals("Abort", delegateExecution.getVariable("handlingCode")); + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml new file mode 100644 index 0000000000..d63a5ecbaf --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml @@ -0,0 +1,21 @@ + + + + + 255ca199-7f53-4800-8ab0-c55954b3ff0f + + mtwnj1a + 255ca199-7f53-4800-8ab0-c55954b3ff0f + + c2141e3fcae940fcb4797ec9115e5a7a + true + b70a3ba5-d172-4e9e-98f6-39516446b25b + USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565 + USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565 + + true + b70a3ba5-d172-4e9e-98f6-39516446b25b + + USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565 + e64e62e1-7c02-4148-ad9c-e51406da508a + \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index bb7abf7d7d..5cf41b655b 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -10,14 +10,13 @@ - SequenceFlow_02lpx87 - SequenceFlow_1mxrfqv + SequenceFlow_01vfwtp + SequenceFlow_09l7pcg - SequenceFlow_1mxrfqv + SequenceFlow_09l7pcg - @@ -29,7 +28,7 @@ SequenceFlow_08tvhtf SequenceFlow_02lpx87 - + SequenceFlow_0h607z0 @@ -41,6 +40,12 @@ + + SequenceFlow_02lpx87 + SequenceFlow_01vfwtp + + + @@ -61,7 +66,7 @@ - + @@ -71,26 +76,19 @@ - + - + - - - - - - - - + - + @@ -115,6 +113,23 @@ + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVolumeGroupBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVolumeGroupBB.bpmn index f2bd2246e4..746d1f2c5f 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVolumeGroupBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVolumeGroupBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1wz1rfg @@ -9,7 +9,7 @@ SequenceFlow_0mh0v9h - SequenceFlow_0fkan8t + SequenceFlow_0hml0t6 SequenceFlow_0mh0v9h @@ -18,7 +18,7 @@ SequenceFlow_1wz1rfg SequenceFlow_13ngwev - + @@ -43,6 +43,11 @@ + + + SequenceFlow_0fkan8t + SequenceFlow_0hml0t6 + @@ -62,19 +67,19 @@ - + - + - + - - + + - + @@ -89,9 +94,9 @@ - + - + @@ -121,6 +126,16 @@ + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn index d123153932..0be7c55596 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1n0j3hz @@ -12,11 +12,6 @@ SequenceFlow_0flbj8a SequenceFlow_07vnhri - - SequenceFlow_0valp88 - - - SequenceFlow_0rh24pq SequenceFlow_0yve6l6 @@ -76,9 +71,6 @@ SequenceFlow_1yifu46 - - SequenceFlow_0valp88 - @@ -98,21 +90,6 @@ - - - - - - - - - - - - - - - @@ -251,9 +228,6 @@ - - - diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 2ca9437e9b..bbb2a8a23d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -5,8 +5,8 @@ SequenceFlow_15s0okp - SequenceFlow_1rscv7d SequenceFlow_0x4urgp + SequenceFlow_1pz6edz @@ -21,6 +21,7 @@ + SequenceFlow_0mew9im SequenceFlow_07h9d4y @@ -53,24 +54,11 @@ SequenceFlow_0sckerv SequenceFlow_1wb59ic - + SequenceFlow_0kf5sen SequenceFlow_1pz6edz - - - - - - - - - - SequenceFlow_1pz6edz - SequenceFlow_1rscv7d - - - + SequenceFlow_1edjl5x @@ -193,7 +181,7 @@ SequenceFlow_0mew9im - + @@ -205,9 +193,9 @@ - + - + @@ -257,26 +245,15 @@ - - - - - + + - - - - - - - - - - - + + + - + @@ -424,9 +401,11 @@ - + + + - + @@ -558,10 +537,10 @@ - - + + - + diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java index 45dafbe606..3ab1c76ee6 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java @@ -46,11 +46,10 @@ public class WorkflowActionBBTest extends BaseBPMNTest { Map map = new HashMap<>(); map.put("handlingCode", "Success"); mockSubprocess("ExecuteBuildingBlock", "Mocked ExecuteBuildingBlock", "GenericStub", map); - mockSubprocess("CompleteMsoProcess", "Mocked CompleteMsoProcess", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("WorkflowActionBB", variables); assertThat(pi).isNotNull().isStarted().hasPassedInOrder("Start_WorkflowActionBB", "Task_RetrieveBBExectuionList", "ExclusiveGateway_isTopLevelFlow", "Task_SendSync", - "Task_SelectBB", "Call_ExecuteBB", "ExclusiveGateway_Finished", "ExclusiveGateway_isTopLevelFlowCompleted", "Task_SetupCompleteMsoProcess", "Call_CompleteMsoProcess", + "Task_SelectBB", "Call_ExecuteBB", "ExclusiveGateway_Finished", "ExclusiveGateway_isTopLevelFlowCompleted", "Task_UpdateRequestComplete", "End_WorkflowActionBB"); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java index e7e8ac0631..d9190b5e12 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java @@ -38,7 +38,7 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted().hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter", "VnfAdapter", - "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); + "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -49,7 +49,7 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter") - .hasNotPassed("VnfAdapter", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java index cd6c266ba4..2336bb54ca 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java @@ -35,7 +35,7 @@ public class DeleteVolumeGroupBBTest extends BaseBPMNTest { mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVolumeGroupBB", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("DeleteVolumeGroupBB_Start", "DeleteVolumeGroupVnfAdapter", "VnfAdapter", "UpdateVolumeGroupAAI", "DeleteVolumeGroupBB_End"); + assertThat(pi).isStarted().hasPassedInOrder("DeleteVolumeGroupBB_Start", "DeleteVolumeGroupVnfAdapter", "VnfAdapter", "UpdateVolumeGroupHeatStackId", "UpdateVolumeGroupAAI", "DeleteVolumeGroupBB_End"); assertThat(pi).isEnded(); } @@ -46,7 +46,7 @@ public class DeleteVolumeGroupBBTest extends BaseBPMNTest { ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVolumeGroupBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("DeleteVolumeGroupBB_Start", "DeleteVolumeGroupVnfAdapter", "VnfAdapter", "UpdateVolumeGroupAAI") + .hasPassedInOrder("DeleteVolumeGroupBB_Start", "DeleteVolumeGroupVnfAdapter", "VnfAdapter", "UpdateVolumeGroupHeatStackId", "UpdateVolumeGroupAAI") .hasNotPassed("DeleteVolumeGroupBB_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 91b6c2af06..1b64671163 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -527,6 +527,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + execution.setVariable(Prefix + "requeryIdAAIResponse", network) String netName = network.getNetworkName() String networkOutputs = @@ -764,29 +765,26 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable("prefix",Prefix) - msoLogger.debug(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " ) + msoLogger.trace(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " ) try { // get variables String networkId = execution.getVariable(Prefix + "networkId") - String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + L3Network requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") L3Network l3Network = new L3Network() - if (utils.nodeExists(requeryIdAAIResponse, 'heat-stack-id')) { - } else { + if (StringUtils.isBlank(requeryIdAAIResponse.getHeatStackId())) { if (utils.nodeExists(createNetworkResponse, 'networkStackId')) { l3Network.setHeatStackId(utils.getNodeText(createNetworkResponse, 'networkStackId')) } } - if (utils.nodeExists(requeryIdAAIResponse, 'neutron-network-id')) { - } else { + if (StringUtils.isBlank(requeryIdAAIResponse.getNeutronNetworkId())) { if (utils.nodeExists(createNetworkResponse, 'neutronNetworkId')) { l3Network.setNeutronNetworkId(utils.getNodeText(createNetworkResponse, 'neutronNetworkId')) } } - if (utils.nodeExists(requeryIdAAIResponse, 'contrail-network-fqdn')) { - } else { + if (StringUtils.isBlank(requeryIdAAIResponse.getContrailNetworkFqdn())) { if (utils.nodeExists(createNetworkResponse, 'networkFqdn')) { l3Network.setContrailNetworkFqdn(utils.getNodeText(createNetworkResponse, 'networkFqdn')) } @@ -794,39 +792,33 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String status = utils.getNodeText(createNetworkResponse, 'orchestration-status') if(status.equals("pending-create") || status.equals("PendingCreate")){ - l3Network.setOperationalStatus("Created") + l3Network.setOrchestrationStatus("Created") }else{ - l3Network.setOperationalStatus("Active") + l3Network.setOrchestrationStatus("Active") } + msoLogger.debug("Updating l3-network in AAI" ) + AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) client.update(uri, l3Network) - String subnetsXml = utils.getNodeXml(requeryIdAAIResponse, "subnets") - InputSource source = new InputSource(new StringReader(subnetsXml)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document xml = docBuilder.parse(source) - NodeList nodeList = xml.getElementsByTagNameNS("*", "subnet") - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String subnetOrchStatus = eElement.getElementsByTagNameNS("*", "orchestration-status").item(0).getTextContent() - String subnetId = eElement.getElementsByTagNameNS("*", "subnet-id").item(0).getTextContent() + if(requeryIdAAIResponse.getSubnets() != null){ + for(Subnet s:requeryIdAAIResponse.getSubnets().getSubnet()){ + String subnetOrchStatus = s.getOrchestrationStatus() + String subnetId = s.getSubnetId() Subnet subnet = new Subnet() - String neutronSubnetId = networkUtils.extractNeutSubId(createNetworkResponse, subnetId) - subnet.setNeutronSubnetId(neutronSubnetId) + subnet.setNeutronSubnetId(networkUtils.extractNeutSubId(createNetworkResponse, subnetId)) if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){ subnet.setOrchestrationStatus("Created") }else{ subnet.setOrchestrationStatus("Active") } + msoLogger.debug("Updating subnet in AAI" ) AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) client.update(subUri, subnet) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index cc301db4cd..6dd8085bae 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -721,9 +721,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String status = utils.getNodeText(updateNetworkResponse, 'orchestration-status') if(status.equals("pending-create") || status.equals("PendingCreate")){ - l3Network.setOperationalStatus("Created") + l3Network.setOrchestrationStatus("Created") }else{ - l3Network.setOperationalStatus("Active") + l3Network.setOrchestrationStatus("Active") } AAIResourcesClient client = new AAIResourcesClient() diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy index 11dbf7d2ee..7523427c84 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -43,9 +43,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.MockitoAnnotations import org.mockito.runners.MockitoJUnitRunner +import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException - +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.junit.WireMockRule import org.apache.commons.lang3.* @@ -480,7 +482,7 @@ class DoCreateNetworkInstanceTest { string 192.10.16.0/24 192.10.16.100/24 - ip-address + ip-address 1505857301954 @@ -508,7 +510,7 @@ class DoCreateNetworkInstanceTest { string 192.10.16.0/24 192.10.16.100/24 - ip-address + ip-address 1505857301954 @@ -1669,7 +1671,7 @@ String createNetworkRequest_Ipv4 = """ -String createNetworkRequestAlaCarte = +String createNetworkRequestAlaCarte = """ RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 @@ -1874,8 +1876,8 @@ String createNetworkRequest_SRIOV = -""" - +""" + String createNetworkResponse = """ @@ -3053,7 +3055,7 @@ String sdncAdapterWorkflowAssignResponse = when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) // JSON format when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") // 1610 default when(mockExecution.getVariable("disableRollback")).thenReturn(true) - + when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") @@ -3182,8 +3184,8 @@ String sdncAdapterWorkflowAssignResponse = verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest) } - - + + @Test //@Ignore public void prepareCreateNetworkRequest_Ipv4() { @@ -3220,7 +3222,7 @@ String sdncAdapterWorkflowAssignResponse = verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest_Ipv4) } - + @Test //@Ignore public void prepareCreateNetworkRequest_AlaCarte() { @@ -3712,7 +3714,7 @@ String sdncAdapterWorkflowAssignResponse = //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() //preDebugger.printInvocations(mockExecution) - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") @@ -3791,7 +3793,7 @@ String sdncAdapterWorkflowAssignResponse = verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") } - + @Test //@Ignore public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { @@ -4025,26 +4027,25 @@ String sdncAdapterWorkflowAssignResponse = @Test //@Ignore public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - + AAIResourcesClient mockClient = mock(AAIResourcesClient.class) WireMock.reset(); - MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "all"); + L3Network network = new L3Network() + //TODO need to inject mock ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(network) when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("false") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + doNothing().when(mockClient).update(isA(AAIResourceUri.class), isA(L3Network.class)) // preProcessRequest(DelegateExecution execution) DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() DoCreateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) @@ -4102,7 +4103,7 @@ String sdncAdapterWorkflowAssignResponse = } - + @Test //@Ignore diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 38261c0f1a..ed6379a6a4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -156,7 +156,9 @@ public class AAIUpdateTasks { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); String heatStackId = execution.getVariable("heatStackId"); - + if (heatStackId == null) { + heatStackId = ""; + } VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); volumeGroup.setHeatStackId(heatStackId); @@ -320,6 +322,9 @@ public class AAIUpdateTasks { public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { try { String heatStackId = execution.getVariable("heatStackId"); + if (heatStackId == null) { + heatStackId = ""; + } VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); vfModule.setHeatStackId(heatStackId); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java index 4506699ce8..81ebfb1f41 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java @@ -75,7 +75,9 @@ public class SDNCQueryTasks { + genericVnf.getVnfId() + "/vnf-data/vf-modules/vf-module/" + vfModule.getVfModuleId() + "/vf-module-data/vf-module-topology/"; try { - vfModule.setSelflink(selfLink); + if(vfModule.getSelflink() == null || (vfModule.getSelflink() != null && vfModule.getSelflink().isEmpty())) { + vfModule.setSelflink(selfLink); + } if(vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) { String response = sdncVfModuleResources.queryVfModule(vfModule); execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index 58c6db109c..173d5f7e73 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; @@ -90,11 +91,6 @@ public class SDNCRequestTasks { public void handleTimeOutException (DelegateExecution execution) { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on SDNC Async-Response"); } - - public void handleSyncError (DelegateExecution execution) { - String msg = (String) execution.getVariable("SDNCSyncError"); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); - } protected boolean convertIndicatorToBoolean(String finalMessageIndicator) { return "Y".equals(finalMessageIndicator); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index e04043a352..10ee13ebed 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -166,6 +166,13 @@ public class WorkflowAction { } catch (Exception ex) { cloudOwner = environment.getProperty(defaultCloudOwner); } + boolean suppressRollback = false; + try{ + suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); + } catch (Exception ex) { + suppressRollback = false; + } + execution.setVariable("suppressRollback", suppressRollback); Resource resource = extractResourceIdAndTypeFromUri(uri); WorkflowType resourceType = resource.getResourceType(); execution.setVariable("resourceName", resourceType.toString()); @@ -401,6 +408,7 @@ public class WorkflowAction { if(virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink() && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId(serviceInstanceId); workflowResourceIds.setNetworkId(resourceId); ebb.setWorkflowResourceIds(workflowResourceIds); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java index 7e6eb2a23d..ac06818e66 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java @@ -100,7 +100,7 @@ public class WorkflowActionBBFailure { } catch (Exception ex) { logger.error("Failed to extract workflow exception from execution.",ex); } - return Optional.of(errorMsg); + return Optional.empty(); } public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index d9125e4104..917039b17b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -20,7 +20,9 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Optional; @@ -181,27 +183,30 @@ public class WorkflowActionBBTasks { } } - public void setupCompleteMsoProcess(DelegateExecution execution) { - final String requestId = (String) execution.getVariable(G_REQUEST_ID); - final String action = (String) execution.getVariable(G_ACTION); - final String resourceId = (String) execution.getVariable("resourceId"); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - final String resourceName = (String) execution.getVariable("resourceName"); - final String source = (String) execution.getVariable("source"); - String macroAction = ""; - if (aLaCarte) { - macroAction = "ALaCarte-" + resourceName + "-" + action; - } else { - macroAction = "Macro-" + resourceName + "-" + action; + public void updateRequestStatusToComplete(DelegateExecution execution) { + try{ + final String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + final String action = (String) execution.getVariable(G_ACTION); + final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); + final String resourceName = (String) execution.getVariable("resourceName"); + String macroAction = ""; + if (aLaCarte) { + macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly."; + } else { + macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly."; + } + execution.setVariable("finalStatusMessage", macroAction); + Timestamp endTime = new Timestamp(System.currentTimeMillis()); + request.setEndTime(endTime); + request.setStatusMessage(macroAction); + request.setProgress(Long.valueOf(100)); + request.setRequestStatus("COMPLETE"); + request.setLastModifiedBy("CamundaBPMN"); + requestDbclient.updateInfraActiveRequests(request); + }catch (Exception ex) { + workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex); } - String msoCompletionRequest = "" - + requestId + "" + action + "" + source - + "" + macroAction - + " request was executed correctly." + resourceId - + "WorkflowActionBB"; - execution.setVariable("CompleteMsoProcessRequest", msoCompletionRequest); - execution.setVariable("mso-request-id", requestId); - execution.setVariable("mso-service-instance-id", resourceId); } public void checkRetryStatus(DelegateExecution execution) { @@ -209,11 +214,12 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); String retryDuration = (String) execution.getVariable("RetryDuration"); int retryCount = (int) execution.getVariable(RETRY_COUNT); + int nextCount = retryCount +1; if (handlingCode.equals("Retry")){ workflowActionBBFailure.updateRequestErrorStatusMessage(execution); try{ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - request.setRetryStatusMessage("Retry " + retryCount+1 + "/5 will be started in " + retryDuration); + request.setRetryStatusMessage("Retry " + nextCount + "/5 will be started in " + retryDuration); requestDbclient.updateInfraActiveRequests(request); } catch(Exception ex){ logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex); @@ -221,7 +227,7 @@ public class WorkflowActionBBTasks { if(retryCount<5){ int currSequence = (int) execution.getVariable("gCurrentSequence"); execution.setVariable("gCurrentSequence", currSequence-1); - execution.setVariable(RETRY_COUNT, retryCount + 1); + execution.setVariable(RETRY_COUNT, nextCount); }else{ workflowAction.buildAndThrowException(execution, "Exceeded maximum retries. Ending flow with status Abort"); } @@ -285,4 +291,100 @@ public class WorkflowActionBBTasks { workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state."); } } + + protected void updateRequestErrorStatusMessage(DelegateExecution execution) { + try { + String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + String errorMsg = retrieveErrorMessage(execution); + if(errorMsg == null || errorMsg.equals("")){ + errorMsg = "Failed to determine error message"; + } + request.setStatusMessage(errorMsg); + logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e); + } + } + + public void abortCallErrorHandling(DelegateExecution execution) { + String msg = "Flow has failed. Rainy day handler has decided to abort the process."; + logger.error(msg); + throw new BpmnError(msg); + } + + public void updateRequestStatusToFailed(DelegateExecution execution) { + try { + String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + String errorMsg = null; + String rollbackErrorMsg = null; + boolean rollbackCompleted = (boolean) execution.getVariable("isRollbackComplete"); + boolean isRollbackFailure = (boolean) execution.getVariable("isRollback"); + ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); + + if(rollbackCompleted){ + rollbackErrorMsg = "Rollback has been completed successfully."; + request.setRollbackStatusMessage(rollbackErrorMsg); + logger.debug("Updating RequestDB to failed: Rollback has been completed successfully"); + }else{ + if(isRollbackFailure){ + rollbackErrorMsg = retrieveErrorMessage(execution); + if(rollbackErrorMsg == null || rollbackErrorMsg.equals("")){ + rollbackErrorMsg = "Failed to determine rollback error message."; + } + request.setRollbackStatusMessage(rollbackErrorMsg); + logger.debug("Updating RequestDB to failed: rollbackErrorMsg = " + rollbackErrorMsg); + }else{ + errorMsg = retrieveErrorMessage(execution); + if(errorMsg == null || errorMsg.equals("")){ + errorMsg = "Failed to determine error message"; + } + request.setStatusMessage(errorMsg); + logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); + } + } + if(ebb!=null && ebb.getBuildingBlock()!=null){ + String flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed."; + request.setFlowStatus(flowStatus); + execution.setVariable("flowStatus", flowStatus); + } + + request.setProgress(Long.valueOf(100)); + request.setRequestStatus("FAILED"); + request.setLastModifiedBy("CamundaBPMN"); + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e); + } + } + + private String retrieveErrorMessage (DelegateExecution execution){ + String errorMsg = ""; + try { + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){ + errorMsg = exception.getErrorMessage(); + } + } catch (Exception ex) { + //log error and attempt to extact WorkflowExceptionMessage + logger.error("Failed to extract workflow exception from execution.",ex); + } + + if (errorMsg == null || errorMsg.equals("")){ + try { + errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage"); + } catch (Exception ex) { + logger.error("Failed to extract workflow exception message from WorkflowException",ex); + errorMsg = "Unexpected Error in BPMN."; + } + } + return errorMsg; + } + + public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) { + execution.setVariable("isRollbackComplete", true); + updateRequestStatusToFailed(execution); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 57c760b01f..4abb0a1b2c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -49,9 +49,12 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.entity.MsoRequest; +import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.beans.Subnet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.util.UriUtils; @@ -59,6 +62,7 @@ import org.springframework.web.util.UriUtils; public class NetworkAdapterObjectMapper { private static final ModelMapper modelMapper = new ModelMapper(); private static String FORWARD_SLASH = "/"; + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterObjectMapper.class); public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map userInput, String cloudRegionPo, Customer customer) throws UnsupportedEncodingException { CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); @@ -82,8 +86,12 @@ public class NetworkAdapterObjectMapper { //build and set provider Vlan Network ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network); createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork); - - createNetworkRequest.setNetworkTechnology(setNetworkTechnology(l3Network.getModelInfoNetwork().getNetworkTechnology())); + String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology(); + if(networkTechnology == null) { + networkTechnology = l3Network.getNetworkTechnology(); + logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology); + } + createNetworkRequest.setNetworkTechnology(setNetworkTechnology(networkTechnology)); //build and set Contrail Network ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 6c20938780..f97b137fb3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -291,6 +292,17 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ assertEquals("newHeatStackId", vfModule.getHeatStackId()); } + @Test + public void updateHeatStackIdVfModuleToNullTest() throws Exception { + execution.setVariable("heatStackId", null); + doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); + + aaiUpdateTasks.updateHeatStackIdVfModule(execution); + + verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); + assertEquals(vfModule.getHeatStackId(), ""); + } + @Test public void updateHeatStackIdVfModuleExceptionTest() throws Exception { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); @@ -358,6 +370,16 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); assertEquals("newHeatStackId", volumeGroup.getHeatStackId()); } + @Test + public void updateHeatStackIdVolumeGroupToNullTest() throws Exception { + execution.setVariable("heatStackId", null); + doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + + aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); + + verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + assertEquals(volumeGroup.getHeatStackId(), ""); + } @Test public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java index a6efbd5989..f1779cf119 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java @@ -129,15 +129,6 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{ sndcRequestTasks.handleTimeOutException(delegateExecution); } - - @Test - public void HandleSyncError_Test() throws MapperException, BadResponseException{ - delegateExecution.setVariable("SDNCSyncError", "Error in SDNC Request"); - doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution); - expectedException.expect(BpmnError.class); - sndcRequestTasks.handleSyncError(delegateExecution); - } - @Test public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json"))); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 189ecb96c7..5c1485979e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -114,16 +114,37 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void msoCompleteProcessTest() throws Exception{ - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + public void updateRequestStatusToCompleteTest() throws Exception{ + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); execution.setVariable("requestAction", "createInstance"); - execution.setVariable("resourceId", "123"); - execution.setVariable("source","MSO"); execution.setVariable("resourceName", "Service"); execution.setVariable("aLaCarte", true); - workflowActionBBTasks.setupCompleteMsoProcess(execution); - String response = (String) execution.getVariable("CompleteMsoProcessRequest"); - assertEquals(response,"00f704ca-c5e5-4f95-a72c-6889db7b0688createInstanceMSOALaCarte-Service-createInstance request was executed correctly.123WorkflowActionBB"); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBTasks.updateRequestStatusToComplete(execution); + assertEquals("ALaCarte-Service-createInstance request was executed correctly.",execution.getVariable("finalStatusMessage")); + } + + @Test + public void updateRequestStatusToFailedFlowStatusTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + execution.setVariable("isRollbackComplete", false); + execution.setVariable("isRollback", false); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); + BuildingBlock buildingBlock = new BuildingBlock(); + buildingBlock.setBpmnFlowName("CreateNetworkBB"); + ebb.setBuildingBlock(buildingBlock); + execution.setVariable("buildingBlock", ebb); + WorkflowException wfe = new WorkflowException("failure", 1, "failure"); + execution.setVariable("WorkflowException", wfe); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBTasks.updateRequestStatusToFailed(execution); + assertEquals("CreateNetworkBB has failed.",execution.getVariable("flowStatus")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index 8f0d00ff86..6f353fa622 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -144,7 +144,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ List subnetList = new ArrayList(); subnetList.add(openstackSubnet); l3Network.getSubnets().add(openstackSubnet); - l3Network.getModelInfoNetwork().setNetworkTechnology("Contrail"); + l3Network.setNetworkTechnology("Contrail"); CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); diff --git a/common/pom.xml b/common/pom.xml index 3ba08a7996..7d468fae3f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -49,7 +49,7 @@ org.onap.aai.aai-common aai-schema - 1.4.0 + 1.4.1-SNAPSHOT org.modelmapper diff --git a/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java index 6f415af8b0..8154b9137d 100644 --- a/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java +++ b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java @@ -154,6 +154,6 @@ public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer { @Override public int getMaximumElapsedTime() { - return 300000; + return 600000; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index a7c25fab68..7ee8654013 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -340,21 +340,24 @@ public class OrchestrationRequests { } if(flowStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; + }else{ + statusMessages = "FLOW STATUS: " + flowStatusMessage; } - statusMessages = statusMessages + "FLOW STATUS: " + flowStatusMessage; } if(retryStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; + }else{ + statusMessages = "RETRY STATUS: " + retryStatusMessage; } - statusMessages = statusMessages + "RETRY STATUS: " + retryStatusMessage; } if(rollbackStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; + }else{ + statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; } - statusMessages = statusMessages + "ROLLBACK STATUS: " + rollbackStatusMessage; } if(statusMessages != null){ status.setStatusMessage(statusMessages); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json index a092650664..50654524f1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json @@ -62,7 +62,7 @@ }, "requestStatus": { "requestState": "COMPLETE", - "statusMessage": "STATUS: Vf Module has been deleted successfully./FLOW STATUS: Building blocks 1 of 3 completed./ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress": 100, "finishTime": "Thu, 22 Dec 2016 08:30:28 GMT", "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json index 12e2417357..ecbf7a92a4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json @@ -58,7 +58,7 @@ }, "requestStatus":{ "requestState":"PENDING", - "statusMessage":"STATUS: Vf Module deletion pending./FLOW STATUS: Building blocks 1 of 3 completed./RETRY STATUS: Retry 2/5 will be started in 8 min./ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" } @@ -321,11 +321,11 @@ }, "requestStatus":{ "requestState":"PENDING", - "statusMessage":"STATUS: Adding members./FLOW STATUS: Building blocks 1 of 3 completed./RETRY STATUS: Retry 2/5 will be started in 8 min./ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } } ] -} \ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json index 97132fa037..8953dfdfe0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json @@ -2,7 +2,7 @@ "clientRequestId": "00032ab7-fake-42e5-965d-8ea592502018", "action": "deleteInstance", "requestStatus": "PENDING", - "statusMessage": "Vf Module deletion pending.", + "statusMessage": null, "progress": 0, "startTime": "2016-12-22T13:29:54.000+0000", "endTime": "2016-12-22T13:30:28.000+0000", diff --git a/pom.xml b/pom.xml index 1be848aeef..776515613a 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ 0.7.5.201505241946 - 1.3.0 + 1.4.0-SNAPSHOT yyyyMMdd'T'HHmm original true