11/7: merge casablanca to master 36/72136/3
authorRob Daugherty <rd472p@att.com>
Wed, 7 Nov 2018 23:30:09 +0000 (18:30 -0500)
committerRob Daugherty <rd472p@att.com>
Thu, 8 Nov 2018 01:45:00 +0000 (20:45 -0500)
Commit: dbb53cabbff772880134699eb81dee775d7df8df
Subject: Send correct resourceModuleName
Issue: SO-1178

Commit: d3759e15184562647ea83b92cf02140fc705cb0d by ss835w
Subject: Update Regex Logic to take into account new scale out URI...
Issue: SO-117

Commit: 5dadc2c5790c961a74085d3d10b6f5aec6b7ba30
Subject: Fix msb url in homing cloudsite
Issue: SO-1180

Commit: 9a9b0fa23afe8d46171fe95f1090de5a7f701d3d
Subject: Updated Reference data for AutoScaleOut
Issue: SO-1174

Commit: 3178cad6c756140b18eb658277598e3e2d2d3dcf
Subject: ConfigurationParameter is empty for scaleout
Issue: SO-1083

Commit: 402bf528e9a796f6ce31ad36c16316c2b31acc48
Subject: Added Null check for gtConfigurationParameter
Issue: SO-1179

Commit: fb6ab40a64e74876ba1f08c4d3bdb6a040c21b94
Subject: Bug fixes November 5th
Issue: SO-1188

Commit: ce37ae979311ed4e55150426d477db262773beb0
Subject: Removed slashes and added catch block
Issue: SO-1183

Commit: 16aa0b6cc42c7287fc080c81451e301c0acc14cf
Subject: removed retry from rainy day table
Issue: SO-1185

Commit: 2073a3b4c20965252c7f3a0c1aea8e4407e876fa
Subject: Fixing scaleOut workflow looping issue
Issue: SO-1182

Commit: 5ca364a5e975877244ee51796602043a4b078a23
Subject: Make homingBB optinal and fix homing process
Issue: SO-1168

Commit: 1c554c3332ccf6be4e576e9159bbb0f901197379
Subject: bug fixing with reading dmaap message
Issue: SO-1191

Change-Id: Id747bc05b791787f304316396bc5fcd20d350b6f
Issue-ID: SO-1190
Signed-off-by: Rob Daugherty <rd472p@att.com>
16 files changed:
1  2 
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java
bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java

@@@ -131,35 -125,86 +131,35 @@@ class AllottedResourceUtils 
                String[] split = arLink.split("/service-instance/")
                String[] splitB =  split[1].split("/allotted-resources/")
                String siId = splitB[0]
--              msoLogger.trace(" Exit getARLinkbyId - parentServiceInstanceId:" + siId )
++              msoLogger.trace(" Exit getPSIFmARLink - parentServiceInstanceId:" + siId )
                return siId
        }
 -
 -      // get Allotted Resource Link by AllottedResourceId using Nodes Query
 -      // used on Delete - called from getARbyId
 -      public String getARLinkbyId (DelegateExecution execution, String allottedResourceId) {
 -              msoLogger.trace("getARLinkbyId ")
 -              String arLink = null
 -              try {
 -                      AAIResourcesClient client = new AAIResourcesClient()
 -                      AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
 -                      AaiUtil aaiUtil = new AaiUtil(taskProcessor)
 -                      arLink = aaiUtil.createAaiUri(uri)
 -              } catch (NotFoundException e) {
 -                      msoLogger.debug("GET AR received a Not Found (404) Response")
 -              } catch(Exception e){
 -                      msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage())
 -                      exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage())
 -              }
 -              msoLogger.debug(" ***** Exit GetARLinkbyId ***** Link:" + arLink)
 -              return arLink
 -      }
 -
 +      
        // get Allotted resource using Link
        // used on Create called from getARORchStatus
 -      // used on Delete called from getARbyId
 +      // used on Delete called from ifExistsAR
        // setsVariable aaiARPath - used for Patch in create
 -      public String getARbyLink (DelegateExecution execution, String link, String role) {
 +      
 +      public Optional<AllottedResource> getARbyLink (DelegateExecution execution, String link, String role) {
                msoLogger.trace("getARbyLink ")
 -              String ar = null
 -              String arUrl = null
 +              Optional<AllottedResource> allottedResource = Optional.empty()
                try {
 -                      AaiUtil aaiUriUtil = new AaiUtil(taskProcessor)
 -                      String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
 -                      String arEndpoint = ""
 -
 -                      if(!isBlank(link)) {
 -                              msoLogger.debug("Incoming AR Resource Link is: " + link)
 -                              String[] split = link.split("/aai/")
 -                              arEndpoint = "/aai/" + split[1]
 -                      }
 -
 -                      arUrl = "${aai_endpoint}" + arEndpoint
 -
 -                      msoLogger.debug("GET AR Aai Path is: \n" + arUrl)
 -
 -                      APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl)
 -                      int responseCode = response.getStatusCode()
 -                      msoLogger.debug("  GET AR response code is: " + responseCode)
 -
 -                      String aaiResponse = response.getResponseBodyAsString()
 -                      msoLogger.debug("GET AR:" + aaiResponse)
 -                      if(responseCode == 200 || responseCode == 202){
 -                              msoLogger.debug("GET AR Received a Good Response Code")
 -                              if(utils.nodeExists(aaiResponse, "allotted-resource")){
 -                                      if (!isBlank(role))
 -                                      {
 -                                              if (utils.nodeExists(aaiResponse, "role") && role.equals(utils.getNodeText(aaiResponse, "role"))) {
 -                                                      ar = aaiResponse
 -                                              }else{
 -                                                      msoLogger.debug("AAI AR does not match input role:" + role)
 -                                              }
 +                      msoLogger.debug("GET AR Aai Path is: \n" + link)
 +                      AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(link).build())
 +                      allottedResource = getAAIClient().get(AllottedResource.class,uri);
 +                      if(allottedResource.isPresent()) {
 +                              if (!isBlank(role)) {
 +                                      if (role == allottedResource.get().getRole()) {
 +                                              setExecutionVariables(execution,allottedResource.get(),uri)
 +                                      } else {
 +                                              msoLogger.debug("AAI AR does not match input role:" + role)
                                        }
 -                                      else
 -                                      {
 -                                              ar = aaiResponse
 -                                      }
 -                              }
 -                              else
 -                              {
 -                                      msoLogger.debug("GET AR Does NOT Contain Data" )
 +                              } else {
 +                                      setExecutionVariables(execution,allottedResource.get(),uri)
                                }
 -                      }else if(responseCode == 404){
 +                      }else{
                                msoLogger.debug("GET AR received a Not Found (404) Response")
                        }
 -                      else{
 -                              msoLogger.debug("  GET AR received a Bad Response: \n" + aaiResponse)
 -                              buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI")
 -                      }
                }catch(Exception e){
                        msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage())
                        exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage())
@@@ -35,6 -36,6 +35,7 @@@ public class AssignVnfBBTest extends Ba
        @Test
        public void sunnyDayAssignVnfBBTest() throws InterruptedException, IOException {
                variables.put("callHoming", true);
++              mockSubprocess("ReceiveWorkflowMessage", "Mocked ReceiveWorkflowMessage", "GenericStub");
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignVnfBB", variables);
                assertThat(pi).isNotNull();
                assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf", "Task_createPlatform", "Task_createLineOfBusiness", "Task_createInstanceGroups",
index 0000000,ea0fb95..a241ae5
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,44 +1,42 @@@
 -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
 -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.job;
 -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.execute;
 -import org.camunda.bpm.engine.runtime.Job;
+ /*-
+  * ============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.onap.so.bpmn.infrastructure.bpmn.subprocess;
 -import org.camunda.bpm.engine.task.Task;
++import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
++import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.job;
++import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.execute;
+ import org.camunda.bpm.engine.runtime.ProcessInstance;
+ import org.junit.Test;
+ import org.onap.so.bpmn.BaseBPMNTest;
+ public class BuildingBlockValidatorRunnerTest extends BaseBPMNTest{
+     @Test
+     public void sunnyDayActivateNetwork_Test() throws InterruptedException {
+       variables.put("flowToBeCalled","CreateVolumeGroupBB");
+         ProcessInstance pi = runtimeService.startProcessInstanceByKey("BuildingBlockValidatorRunnerTest", variables);
+         assertThat(pi).isNotNull();
+         
+         execute(job());
+         execute(job());
+         assertThat(pi).isStarted().hasPassedInOrder("ServiceTask_1","ServiceTask_2","ServiceTask_3");     
+         assertThat(pi).isEnded();
+     }
+ }
@@@ -53,6 -54,6 +53,7 @@@ public class CreateVolumeGroupBBTest ex
        
        @Test
        public void rainyDayCreateVolumeGroupUpdateHeatStackIdError_Test() throws Exception {
++              mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
                doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVolumeGroup(any(BuildingBlockExecution.class));
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVolumeGroupBB", variables);
                assertThat(pi).isNotNull();
@@@ -32,6 -33,6 +32,7 @@@ import org.onap.so.bpmn.common.Building
  public class DeleteVolumeGroupBBTest extends BaseBPMNTest {
        @Test
        public void sunnyDayDeleteVolumeGroup_Test() throws InterruptedException {
++              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");
@@@ -40,6 -41,6 +41,7 @@@
  
        @Test
        public void rainyDayDeleteVolumeGroup_Test() throws Exception {
++              mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
                doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusAssignedVolumeGroup(any(BuildingBlockExecution.class));
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVolumeGroupBB", variables);
                assertThat(pi).isNotNull();
@@@ -48,10 -52,21 +48,10 @@@ public class HomingBBTest extends BaseB
        @Test
        public void testHomingV2_error_bpmnError(){
                doThrow(new BpmnError("MSOWorkflowException")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class));
 -              ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables);
 -              assertThat(pi).isNotNull();
 -              assertThat(pi).isStarted()
 -                              .hasPassedInOrder("start", "catchBpmnError", "processBpmnError", "endBpmnError")
 -                              .hasNotPassed("callReceiveAsync");
 -              assertThat(pi).isEnded();
 -      }
 -
 -      @Test
 -      public void testHomingV2_error_javaException(){
 -              doThrow(new RuntimeException("Test")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class));
 -              ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables);
 +              ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingBB", variables);
                assertThat(pi).isNotNull();
                assertThat(pi).isStarted()
-                               .hasPassedInOrder("start", "sniroOofCheck", "startBpmnError", "bpmnErrorSubprocess", "processMsoWorkflowException", "endBpmnError")
 -                              .hasPassedInOrder("start", "catchJavaException", "processJavaException", "endJavaException")
++                              .hasPassedInOrder("start", "sniroOofCheck", "startBpmnError", "processMsoWorkflowException", "endBpmnError")
                                .hasNotPassed("callReceiveAsync");
                assertThat(pi).isEnded();
        }
@@@ -206,7 -205,8 +220,8 @@@ public class AAIUpdateTasksTest extend
        
        @Test
        public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
 -              doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
+               execution.setVariable("aLaCarte", true);
 +              doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
                
                expectedException.expect(BpmnError.class);
                
@@@ -135,5 -123,54 +135,56 @@@ public class ConfigurationScaleOutTest 
                configurationScaleOut.callAppcClient(execution);
                verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
        }
+       @Test
+       public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
+               ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+               controllerSelectionReference.setControllerName("testName");
+               controllerSelectionReference.setActionCategory("testAction");
+               controllerSelectionReference.setVnfType("testVnfType");
+               String sdncResponse =  new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
+               String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+                               + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+                               + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
+               execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+               
+               doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
+               
+               configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+               
+               assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+               assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+               assertEquals("ConfigScaleOut", execution.getVariable("action"));
+               assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+               assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+               assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+               assertEquals(expectedPayload, execution.getVariable("payload"));
+       }
  
 -              doThrow(Exception.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+       @Test
+       public void callAppcClientExceptionTest() throws Exception {
+               expectedException.expect(BpmnError.class);
+               Action action = Action.ConfigScaleOut;
+               String vnfId = genericVnf.getVnfId();
+               String controllerType = "testType";
+               String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+                               + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+                               + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+               HashMap<String, String> payloadInfo = new HashMap<String, String>();
+               payloadInfo.put("vnfName", "testVnfName");
+               payloadInfo.put("vfModuleId", "testVfModuleId");
+       
+               execution.setVariable("action", Action.ConfigScaleOut.toString());
+               execution.setVariable("msoRequestId", msoRequestId);
+               execution.setVariable("controllerType", controllerType);
+               execution.setVariable("vnfId", "testVnfId1");
+               execution.setVariable("vnfName", "testVnfName");
+               execution.setVariable("vfModuleId", "testVfModuleId");
+               execution.setVariable("payload", payload);
+               
++              
++              doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); 
++              doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+               configurationScaleOut.callAppcClient(execution);
+               verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+       }
  }
@@@ -109,6 -99,35 +109,36 @@@ public class GenericVnfHealthCheckTest 
                
                doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
                
 -              doThrow(Exception.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+               genericVnfHealthCheck.callAppcClient(execution);
+               verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+       }
+       
+       @Test
+       public void callAppcClientExceptionTest() throws Exception {
+               expectedException.expect(BpmnError.class);
+               Action action = Action.HealthCheck;
+               String vnfId = genericVnf.getVnfId();
+               String payload = "{\"testName\":\"testValue\",}";
+               String controllerType = "testType";
+               HashMap<String, String> payloadInfo = new HashMap<String, String>();
+               payloadInfo.put("vnfName", "testVnfName");
+               payloadInfo.put("vfModuleId", "testVfModuleId");
+               payloadInfo.put("oamIpAddress", "testOamIpAddress");
+               payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+               execution.setVariable("action", Action.HealthCheck.toString());
+               execution.setVariable("msoRequestId", msoRequestId);
+               execution.setVariable("controllerType", controllerType);
+               execution.setVariable("vnfId", "testVnfId1");
+               execution.setVariable("vnfName", "testVnfName");
+               execution.setVariable("vfModuleId", "testVfModuleId");
+               execution.setVariable("oamIpAddress", "testOamIpAddress");
+               execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+               execution.setVariable("payload", payload);
+               
++              doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); 
++              doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+               
+               
                genericVnfHealthCheck.callAppcClient(execution);
                verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
        }