From 30106b39d2ac1bc206134cfcb8fc73eb1f29b923 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Tue, 12 Jan 2021 09:12:23 -0500 Subject: Add new endpoint and macro for service upgrade This enables upgrading an existing service instance by updating its model UUID's in AAI and md-sal. Issue-ID: SO-3636 Signed-off-by: Jozsef Csongvai Change-Id: Ic5f067a1267053a61f46e2d9563ca4e4ac869bdf --- .../servicedecomposition/tasks/BBInputSetup.java | 11 ++++++-- .../tasks/BBInputSetupTest.java | 26 ++++++++++++++++++ .../RequestDetailsInput_serviceUpgrade.json | 31 ++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json (limited to 'bpmn/MSOCommonBPMN') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 569f6b1c77..d39da5ee37 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -1249,7 +1249,8 @@ public class BBInputSetup implements JavaDelegate { || requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") - || requestAction.equalsIgnoreCase("replaceInstance")) { + || requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("upgradeInstance")) { return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration()); } @@ -1429,7 +1430,13 @@ public class BBInputSetup implements JavaDelegate { if (serviceInstanceId != null) { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); if (aaiServiceInstance != null) { - service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + String modelVersionId = aaiServiceInstance.getModelVersionId(); + if ("upgradeInstance".equalsIgnoreCase(requestAction)) { + modelVersionId = requestDetails.getModelInfo().getModelVersionId(); + } + + service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId); + if (service == null) { String message = String.format( "Related service instance model not found in MSO CatalogDB: model-version-id=%s", diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 8961c996a8..b561055468 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -46,6 +46,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Assert; import org.junit.Rule; @@ -2983,6 +2984,31 @@ public class BBInputSetupTest { any(Service.class), isA(ConfigurationResourceKeys.class)); } + @Test + public void testGetGBBMacroExistingServiceUpgrade() throws Exception { + String requestAction = "upgradeInstance"; + GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper + .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceUpgrade.json"), RequestDetails.class); + Map lookupKeyMap = prepareLookupKeyMap(); + executeBB.setRequestDetails(requestDetails); + + doReturn(new Service()).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(SPY_bbInputSetupUtils) + .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID)); + doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class)); + + SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, + executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null); + + verify(SPY_bbInputSetupUtils, times(1)) + .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + } + @Test public void testGetGBBMacroExistingServiceServiceinstancenotFoundInAai() throws Exception { ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json new file mode 100644 index 0000000000..2a721ddd96 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceUpgrade.json @@ -0,0 +1,31 @@ +{ + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "Sample Service Upgrade", + "modelVersion": "10.0" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "TEST" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "subscriberId" + }, + "requestInfo": { + "instanceName": "test_Service", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "test", + "aLaCarte": false, + "userParams": [] + } +} -- cgit 1.2.3-korg