summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-02-22 17:27:00 +0000
committertragait <rahul.tyagi@est.tech>2021-02-22 17:34:50 +0000
commit09aed6c2207d166b365d0f033b9e19762e3887fd (patch)
tree9be4a7e88ca5122dc9d74608df8b3bd9195bb1e7 /asdc-controller
parent01ac4cc7d7b2fc4d527ccae82fb2fd43a8446f76 (diff)
fix default software version source
This commit fixes default software version source input for pnfcustomization table. If pnfcustomization has a value in default software version field that will be picked. Else first entry of software versions will be picked. Issue-ID: SO-3543 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I10261c2d4c8e816fdaa2ef54d20c7e83b9f41701
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java21
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java171
-rw-r--r--asdc-controller/src/test/resources/download/service-Ericservice-csar.csarbin0 -> 88698 bytes
3 files changed, 167 insertions, 25 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 56ec77cdee..da7aad4319 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -986,11 +986,30 @@ 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.setDefaultSoftwareVersion(extractDefaultSoftwareVersionFromSwVersions(properties));
pnfResourceCustomization.setPnfResources(pnfResource);
return pnfResourceCustomization;
}
+ private String extractDefaultSoftwareVersionFromSwVersions(Map<String, Property> properties) {
+ final String SOFTWARE_VERSIONS = "software_versions";
+ final String EMPTY_STRING = "";
+ String defaultSoftwareVersionValue = getStringValue(properties.get(DEFAULT_SOFTWARE_VERSION));
+ if (defaultSoftwareVersionValue != null && !defaultSoftwareVersionValue.isEmpty()) {
+ return defaultSoftwareVersionValue;
+ }
+ if (properties.containsKey(SOFTWARE_VERSIONS) && properties.get(SOFTWARE_VERSIONS).getValue() != null) {
+ if (properties.get(SOFTWARE_VERSIONS).getValue() instanceof List) {
+ List<String> propertyValueList = (List) properties.get(SOFTWARE_VERSIONS).getValue();
+ return propertyValueList.get(0);
+ } else if (properties.get(SOFTWARE_VERSIONS).getValue() instanceof String) {
+ return getStringValue(properties.get(SOFTWARE_VERSIONS));
+ }
+ }
+
+ return EMPTY_STRING;
+ }
+
/**
* Get value from {@link Property} and cast to boolean value. Return true if property is null.
*/
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
index eafb42a3d9..bf2b8ad7bc 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -19,9 +19,7 @@
package org.onap.so.asdc.client;
-import static com.github.tomakehurst.wiremock.client.WireMock.ok;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -38,6 +36,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
+import org.onap.aaiclient.client.aai.AAIVersion;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.asdc.BaseTest;
import org.onap.so.asdc.client.exceptions.ASDCControllerException;
@@ -149,8 +148,8 @@ public class ASDCControllerITTest extends BaseTest {
* Mock the AAI using wireshark.
*/
private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) {
- String modelEndpoint = "/aai/v17/service-design-and-creation/models/model/" + serviceInvariantUuid
- + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
+ String modelEndpoint = "/aai/" + AAIVersion.LATEST + "/service-design-and-creation/models/model/"
+ + serviceInvariantUuid + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
}
@@ -453,16 +452,16 @@ public class ASDCControllerITTest extends BaseTest {
}
/**
- * Test with service-pnfservice.csar.
+ * Test with service-Ericservice-csar.csar to test default_software_version field.
*/
@Test
- public void treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput() {
+ public void treatNotification_ValidPnfResource_With_Default_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";
+ String serviceUuid = "8e7b2bd7-6901-4cc2-b3fb-3b6a1d5631e3";// "77cf276e-905c-43f6-8d54-dda474be2f2e";
+ String serviceInvariantUuid = "9a5f99c8-0492-4691-b29a-7360d9c3aae3";// "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
initMockAaiServer(serviceUuid, serviceInvariantUuid);
@@ -493,11 +492,11 @@ public class ASDCControllerITTest extends BaseTest {
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 name", "service-Ericservice-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());
+ assertEquals("toscar csar URL", "/download/service-Ericservice-csar.csar", toscaCsar.getUrl());
/**
* Check the service entity, it should be the same as global metadata information in
@@ -510,18 +509,18 @@ public class ASDCControllerITTest extends BaseTest {
* 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";
+ String pnfResourceKey = "7a90f80b-a6f6-4597-8c48-80bda26b4823";
/**
* 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";
+ String pnfCustomizationKey = "c850a53b-b63e-4043-ab10-53aabda78d37";// "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("model instance name", "demo-PNF 1", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
assertEquals("NF Role", "", pnfCustomization.getNfRole());
assertEquals("NF function", "", pnfCustomization.getNfFunction());
@@ -562,6 +561,115 @@ public class ASDCControllerITTest extends BaseTest {
}
}
+ /**
+ * Test with service-Ericservice-csar.csar to test software_vesrions field.
+ */
+ @Test
+ public void treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput() {
+
+ /**
+ * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
+ */
+ String serviceUuid = "8e7b2bd7-6901-4cc2-b3fb-3b6a1d5631e3";// "77cf276e-905c-43f6-8d54-dda474be2f2e";
+ String serviceInvariantUuid = "9a5f99c8-0492-4691-b29a-7360d9c3aae3";// "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 = constructPnfResourceInfoWithSWV1();
+ 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-Ericservice-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-Ericservice-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 = "7a90f80b-a6f6-4597-8c48-80bda26b4823";
+
+ /**
+ * 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 = "05660370-41ed-4720-a42b-d6def010c326";// "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", "demo-PNF 0", 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", "foo-123", 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();
@@ -620,26 +728,41 @@ public class ASDCControllerITTest extends BaseTest {
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.setArtifactURL("/download/service-Ericservice-csar.csar");// service-pnfservice.csar");
+ artifactInfo.setArtifactName("service-Ericservice-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.
+ * Construct the PnfResourceInfo based on the resource-DemoPnf-template.yml from service-Ericservice-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.setResourceInstanceName("demo-PNF");
+ resourceInfo.setResourceInvariantUUID("e688fe35-21c2-41be-9fd2-c5ae830a5031");
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.setCategory("Network L4+");
+ resourceInfo.setSubcategory("Common Network Resources");
+ resourceInfo.setResourceUUID("7a90f80b-a6f6-4597-8c48-80bda26b4823");
+ resourceInfo.setResourceCustomizationUUID("c850a53b-b63e-4043-ab10-53aabda78d37");// "9f01263a-eaf7-4d98-a37b-3785f751903e");
+ resourceInfo.setResourceVersion("1.0");
+ return resourceInfo;
+ }
+
+ /**
+ * Construct the PnfResourceInfo based on the resource-DemoPnf-template.yml from service-Ericservice-csar.csar.
+ */
+ private ResourceInfoImpl constructPnfResourceInfoWithSWV1() {
+ ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+ resourceInfo.setResourceInstanceName("demo-PNF");
+ resourceInfo.setResourceInvariantUUID("e688fe35-21c2-41be-9fd2-c5ae830a5031");
+ resourceInfo.setResoucreType("PNF");
+ resourceInfo.setCategory("Network L4+");
+ resourceInfo.setSubcategory("Common Network Resources");
+ resourceInfo.setResourceUUID("7a90f80b-a6f6-4597-8c48-80bda26b4823");
+ resourceInfo.setResourceCustomizationUUID("05660370-41ed-4720-a42b-d6def010c326");// "9f01263a-eaf7-4d98-a37b-3785f751903e");
resourceInfo.setResourceVersion("1.0");
return resourceInfo;
}
diff --git a/asdc-controller/src/test/resources/download/service-Ericservice-csar.csar b/asdc-controller/src/test/resources/download/service-Ericservice-csar.csar
new file mode 100644
index 0000000000..de8691eb76
--- /dev/null
+++ b/asdc-controller/src/test/resources/download/service-Ericservice-csar.csar
Binary files differ