software-version fix 85/113485/4
authortragait <rahul.tyagi@est.tech>
Wed, 16 Sep 2020 11:51:21 +0000 (12:51 +0100)
committerRahul Tyagi <rahul.tyagi@est.tech>
Tue, 8 Dec 2020 15:38:05 +0000 (15:38 +0000)
In this commit software_versions added to
the pnf customization table. A test case is
also written to verify if the software_versions
of type string is added to the pnfcustomization.

Signed-off-by: tragait <rahul.tyagi@est.tech>
Change-Id: Id07fe79e67ac96e71e6fe3775cce801edd81a42a
Signed-off-by: tragait <rahul.tyagi@est.tech>
Issue-ID: SO-3119
Signed-off-by: tragait <rahul.tyagi@est.tech>
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql [new file with mode: 0644]
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar [new file with mode: 0644]
asdc-controller/src/test/resources/schema.sql
bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java
mso-catalog-db/src/test/resources/schema.sql

diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql
new file mode 100644 (file)
index 0000000..5578d3e
--- /dev/null
@@ -0,0 +1,6 @@
+use catalogdb;
+
+ALTER TABLE pnf_resource_customization
+ADD DEFAULT_SOFTWARE_VERSION varchar(4000) null;
+
+
index 7efc397..73b825d 100644 (file)
@@ -46,6 +46,7 @@ import org.onap.sdc.api.notification.IResourceInstance;
 import org.onap.sdc.api.notification.IStatusData;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.EntityDetails;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder;
 import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
@@ -133,6 +134,8 @@ public class ToscaResourceInstaller {
 
     private static final String CDS_MODEL_VERSION = "cds_model_version";
 
+    private static final String DEFAULT_SOFTWARE_VERSION = "default_software_version";
+
     @Autowired
     protected ServiceRepository serviceRepo;
 
@@ -932,6 +935,7 @@ public class ToscaResourceInstaller {
         pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
         pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
         pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR)));
+        pnfResourceCustomization.setDefaultSoftwareVersion(getStringValue(properties.get(DEFAULT_SOFTWARE_VERSION)));
         pnfResourceCustomization.setPnfResources(pnfResource);
         return pnfResourceCustomization;
     }
index 3db017c..eafb42a 100644 (file)
@@ -320,33 +320,6 @@ public class ASDCControllerITTest extends BaseTest {
         }
     }
 
-    private ArtifactInfoImpl constructPnfServiceArtifact() {
-        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
-        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
-        artifactInfo.setArtifactURL("/download/service-pnfservice.csar");
-        artifactInfo.setArtifactName("service-pnfservice.csar");
-        artifactInfo.setArtifactVersion("1.0");
-        artifactInfo.setArtifactUUID(artifactUuid);
-        return artifactInfo;
-    }
-
-    /**
-     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
-     * service-Testservice140-csar.csar.
-     */
-    private ResourceInfoImpl constructPnfResourceInfo() {
-        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
-        resourceInfo.setResourceInstanceName("PNF CDS Test");
-        resourceInfo.setResourceInvariantUUID("17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
-        resourceInfo.setResoucreType("PNF");
-        resourceInfo.setCategory("Application L4+");
-        resourceInfo.setSubcategory("Firewall");
-        resourceInfo.setResourceUUID("aa5d0562-80e7-43e9-af74-3085e57ab09f");
-        resourceInfo.setResourceCustomizationUUID("9f01263a-eaf7-4d98-a37b-3785f751903e");
-        resourceInfo.setResourceVersion("1.0");
-        return resourceInfo;
-    }
-
     /**
      * Testing with the service-Svc140-VF-csar.csar.
      */
@@ -479,6 +452,144 @@ public class ASDCControllerITTest extends BaseTest {
         }
     }
 
+    /**
+     * Test with service-pnfservice.csar.
+     */
+    @Test
+    public void treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput() {
+
+        /**
+         * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
+         */
+        String serviceUuid = "888d93bd-ef31-4ab8-9d9e-3935e9a71845";// "77cf276e-905c-43f6-8d54-dda474be2f2e";
+        String serviceInvariantUuid = "e5c5fd11-392f-4aa7-aeeb-b340c596d4bd";// "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
+
+        initMockAaiServer(serviceUuid, serviceInvariantUuid);
+
+        NotificationDataImpl notificationData = new NotificationDataImpl();
+        notificationData.setServiceUUID(serviceUuid);
+        notificationData.setDistributionID(distributionId);
+        notificationData.setServiceInvariantUUID(serviceInvariantUuid);
+        notificationData.setServiceVersion("1.0");
+
+        ResourceInfoImpl resourceInfo = constructPnfResourceInfoWithSWV();
+        List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
+        resourceInfoList.add(resourceInfo);
+        notificationData.setResources(resourceInfoList);
+
+        ArtifactInfoImpl artifactInfo = constructPnfServiceArtifactWithSWV();
+        List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
+        artifactInfoList.add(artifactInfo);
+        notificationData.setServiceArtifacts(artifactInfoList);
+
+        try {
+            asdcController.treatNotification(notificationData);
+
+            logger.info("Checking the database for PNF ingestion");
+
+            /**
+             * Check the tosca csar entity, it should be the same as provided from NotficationData.
+             */
+            ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
+                    .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+            assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
+            assertEquals("tosca csar name", "service-Testserviceforpnf-csar.csar", toscaCsar.getName());
+            assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
+            assertNull("tosca csar descrption", toscaCsar.getDescription());
+            assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
+            assertEquals("toscar csar URL", "/download/service-Testserviceforpnf-csar.csar", toscaCsar.getUrl());
+
+            /**
+             * Check the service entity, it should be the same as global metadata information in
+             * service-Testservice140-template.yml inside csar.
+             */
+            Service service = serviceRepository.findById(serviceUuid)
+                    .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+
+            /**
+             * Check PNF resource, it should be the same as metadata in the topology template in
+             * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
+             */
+            String pnfResourceKey = "72a2c44c-bb8a-4086-824b-0662d40bcd68";
+
+            /**
+             * Check PNF resource customization, it should be the same as metadata in the topology template in
+             * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
+             */
+            String pnfCustomizationKey = "96642e60-17cd-48c1-875d-b00b08fdb37b";// "9f01263a-eaf7-4d98-a37b-3785f751903e";
+            PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey)
+                    .orElseThrow(() -> new EntityNotFoundException(
+                            "PNF resource customization: " + pnfCustomizationKey + " not found"));
+            assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
+            assertEquals("model instance name", "VSP_WithPNFD 1", pnfCustomization.getModelInstanceName());
+            assertEquals("NF type", "", pnfCustomization.getNfType());
+            assertEquals("NF Role", "", pnfCustomization.getNfRole());
+            assertEquals("NF function", "", pnfCustomization.getNfFunction());
+            assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
+            assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
+            assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
+            assertNull("resource input", pnfCustomization.getResourceInput());
+            assertEquals("cds blueprint name(sdnc_model_name property)", "pm_control",
+                    pnfCustomization.getBlueprintName());
+            assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0",
+                    pnfCustomization.getBlueprintVersion());
+            assertEquals("default software version", "4.0.0", pnfCustomization.getDefaultSoftwareVersion());
+            assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf());
+            assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
+
+            /**
+             * Check the pnf resource customization with service mapping
+             */
+            List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
+            assertEquals("PNF resource customization entity", 1, pnfCustList.size());
+            assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
+
+            /**
+             * Check the watchdog for component distribution status
+             */
+            List<WatchdogComponentDistributionStatus> distributionList =
+                    watchdogCDStatusRepository.findByDistributionId(this.distributionId);
+            assertNotNull(distributionList);
+            assertEquals(1, distributionList.size());
+            WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
+            assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
+            assertEquals("SO", distributionStatus.getComponentName());
+
+
+        } catch (Exception e) {
+            logger.info(e.getMessage(), e);
+            fail(e.getMessage());
+        }
+    }
+
+
+    private ArtifactInfoImpl constructPnfServiceArtifact() {
+        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+        artifactInfo.setArtifactURL("/download/service-pnfservice.csar");
+        artifactInfo.setArtifactName("service-pnfservice.csar");
+        artifactInfo.setArtifactVersion("1.0");
+        artifactInfo.setArtifactUUID(artifactUuid);
+        return artifactInfo;
+    }
+
+    /**
+     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
+     * service-Testservice140-csar.csar.
+     */
+    private ResourceInfoImpl constructPnfResourceInfo() {
+        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+        resourceInfo.setResourceInstanceName("PNF CDS Test");
+        resourceInfo.setResourceInvariantUUID("17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
+        resourceInfo.setResoucreType("PNF");
+        resourceInfo.setCategory("Application L4+");
+        resourceInfo.setSubcategory("Firewall");
+        resourceInfo.setResourceUUID("aa5d0562-80e7-43e9-af74-3085e57ab09f");
+        resourceInfo.setResourceCustomizationUUID("9f01263a-eaf7-4d98-a37b-3785f751903e");
+        resourceInfo.setResourceVersion("1.0");
+        return resourceInfo;
+    }
+
     private ArtifactInfoImpl constructVnfServiceArtifact() {
         ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
         artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
@@ -505,4 +616,31 @@ public class ASDCControllerITTest extends BaseTest {
         resourceInfo.setArtifacts(Collections.EMPTY_LIST);
         return resourceInfo;
     }
+
+    private ArtifactInfoImpl constructPnfServiceArtifactWithSWV() {
+        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+        artifactInfo.setArtifactURL("/download/service-Testserviceforpnf-csar.csar");// service-pnfservice.csar");
+        artifactInfo.setArtifactName("service-Testserviceforpnf-csar.csar");// "service-pnfservice.csar");
+        artifactInfo.setArtifactVersion("1.0");
+        artifactInfo.setArtifactUUID(artifactUuid);
+        return artifactInfo;
+    }
+
+    /**
+     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
+     * service-Testservice140-csar.csar.
+     */
+    private ResourceInfoImpl constructPnfResourceInfoWithSWV() {
+        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+        resourceInfo.setResourceInstanceName("PNF CDS Test");
+        resourceInfo.setResourceInvariantUUID("bf150ca9-b8d3-4450-b50a-d80382a12462");// "17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
+        resourceInfo.setResoucreType("PNF");
+        resourceInfo.setCategory("Application L4+");
+        resourceInfo.setSubcategory("Firewall");
+        resourceInfo.setResourceUUID("72a2c44c-bb8a-4086-824b-0662d40bcd68");// "aa5d0562-80e7-43e9-af74-3085e57ab09f");
+        resourceInfo.setResourceCustomizationUUID("96642e60-17cd-48c1-875d-b00b08fdb37b");// "9f01263a-eaf7-4d98-a37b-3785f751903e");
+        resourceInfo.setResourceVersion("1.0");
+        return resourceInfo;
+    }
 }
diff --git a/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar b/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar
new file mode 100644 (file)
index 0000000..d061012
Binary files /dev/null and b/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar differ
index f94f74d..1260461 100644 (file)
@@ -1205,6 +1205,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
index 8ff1a1e..a12d8fe 100644 (file)
@@ -415,4 +415,4 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script>
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
-</bpmn:definitions>
+</bpmn:definitions>
\ No newline at end of file
index fd8c273..11f2d4b 100644 (file)
@@ -1200,6 +1200,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL,
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
index 2e4623d..122a20f 100644 (file)
@@ -88,6 +88,9 @@ public class PnfResourceCustomization implements Serializable {
     @Column(name = "CONTROLLER_ACTOR")
     private String controllerActor;
 
+    @Column(name = "DEFAULT_SOFTWARE_VERSION")
+    private String defaultSoftwareVersion;
+
     @Override
     public String toString() {
         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
@@ -95,7 +98,8 @@ public class PnfResourceCustomization implements Serializable {
                 .append("nfFunction", nfFunction).append("nfType", nfType).append("nfRole", nfRole)
                 .append("nfNamingCode", nfNamingCode).append("multiStageDesign", multiStageDesign)
                 .append("pnfResources", pnfResources).append("blueprintName", blueprintName)
-                .append("blueprintVersion", blueprintVersion).append("controllerActor", controllerActor).toString();
+                .append("blueprintVersion", blueprintVersion).append("controllerActor", controllerActor)
+                .append("defaultSoftwareVersion", defaultSoftwareVersion).toString();
     }
 
     @Override
@@ -234,4 +238,12 @@ public class PnfResourceCustomization implements Serializable {
     public void setControllerActor(String controllerActor) {
         this.controllerActor = controllerActor;
     }
+
+    public String getDefaultSoftwareVersion() {
+        return defaultSoftwareVersion;
+    }
+
+    public void setDefaultSoftwareVersion(String defaultSoftwareVersion) {
+        this.defaultSoftwareVersion = defaultSoftwareVersion;
+    }
 }
index 68f272c..335c49e 100644 (file)
@@ -1204,6 +1204,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE