summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java63
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java132
-rw-r--r--asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csarbin35636 -> 0 bytes
-rw-r--r--asdc-controller/src/test/resources/download/service-Testservice140-csar.csarbin35457 -> 0 bytes
4 files changed, 36 insertions, 159 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 8b3bccf892..00ca74b5f4 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
@@ -1068,10 +1068,11 @@ public class ToscaResourceInstaller {
EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"),
TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
+ Set<VnfcCustomization> existingVnfcGroupSet = new HashSet<>();
for (IEntityDetails groupEntity : vfcEntityList) {
- VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
- createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct);
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity,
+ nodeTemplate, vnfResource, toscaResourceStruct, existingVnfcGroupSet);
vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
}
@@ -1888,7 +1889,7 @@ public class ToscaResourceInstaller {
protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(IEntityDetails vfcInstanceEntity,
NodeTemplate vnfcNodeTemplate, VnfResourceCustomization vnfResourceCustomization,
- ToscaResourceStructure toscaResourceStructure) {
+ ToscaResourceStructure toscaResourceStructure, Set<VnfcCustomization> existingVnfcGroupSet) {
Metadata instanceMetadata = vfcInstanceEntity.getMetadata();
@@ -1958,39 +1959,47 @@ public class ToscaResourceInstaller {
vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
ArrayList<Input> inputs = vnfcNodeTemplate.getSubMappingToscaTemplate().getInputs();
- createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs);
+ createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs, existingVnfcGroupSet);
return vfcInstanceGroupCustom;
}
private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom,
- IEntityDetails vfcModuleEntity, List<Input> inputList) {
+ IEntityDetails vfcModuleEntity, List<Input> inputList, Set<VnfcCustomization> existingVnfcGroupSet) {
List<IEntityDetails> members = vfcModuleEntity.getMemberNodes();
if (!CollectionUtils.isEmpty(members)) {
for (IEntityDetails vfcEntity : members) {
- VnfcCustomization vnfcCustomization = new VnfcCustomization();
-
- Metadata metadata = vfcEntity.getMetadata();
- vnfcCustomization
- .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vnfcCustomization.setModelInstanceName(vfcEntity.getName());
- vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vnfcCustomization
- .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType()));
- vnfcCustomization
- .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList));
- vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom);
- List<VnfcCustomization> vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations();
-
- if (vnfcCustomizations == null) {
- vnfcCustomizations = new ArrayList<>();
- vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations);
+
+ VnfcCustomization existingVfcGroup = findExistingVfc(existingVnfcGroupSet,
+ vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (existingVfcGroup == null) {
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+
+ Metadata metadata = vfcEntity.getMetadata();
+ vnfcCustomization.setModelCustomizationUUID(
+ metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcEntity.getName());
+ vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vnfcCustomization
+ .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType()));
+ vnfcCustomization
+ .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList));
+ vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom);
+ List<VnfcCustomization> vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations();
+
+ if (vnfcCustomizations == null) {
+ vnfcCustomizations = new ArrayList<>();
+ vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations);
+ }
+ vnfcCustomizations.add(vnfcCustomization);
+
+ existingVnfcGroupSet.add(vnfcCustomization);
}
- vnfcCustomizations.add(vnfcCustomization);
}
}
}
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 055968cc95..0c7f97759b 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
@@ -148,138 +148,6 @@ public class ASDCControllerITTest extends BaseTest {
}
/**
- * Test with service-Testservice140-csar.csar.
- */
- @Test
- public void treatNotification_ValidPnfResource_ExpectedOutput() {
-
- /**
- * service UUID/invariantUUID from global metadata in service-Testservice140-template.yml.
- */
- String serviceUuid = "efaea486-561f-4159-9191-a8d3cb346728";
- String serviceInvariantUuid = "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23";
-
- initMockAaiServer(serviceUuid, serviceInvariantUuid);
-
- NotificationDataImpl notificationData = new NotificationDataImpl();
- notificationData.setServiceUUID(serviceUuid);
- notificationData.setDistributionID(distributionId);
- notificationData.setServiceInvariantUUID(serviceInvariantUuid);
- notificationData.setServiceVersion("1.0");
-
- ResourceInfoImpl resourceInfo = constructPnfResourceInfo();
- List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
- resourceInfoList.add(resourceInfo);
- notificationData.setResources(resourceInfoList);
-
- ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact();
- 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-Testservice140-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-Testservice140-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"));
- assertEquals("model UUID", "efaea486-561f-4159-9191-a8d3cb346728", service.getModelUUID());
- assertEquals("model name", "TestService140", service.getModelName());
- assertEquals("model invariantUUID", "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23",
- service.getModelInvariantUUID());
- assertEquals("model version", "1.0", service.getModelVersion());
- assertEquals("description", "Test Service for extended attributes of PNF resource",
- service.getDescription().trim());
- assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
- assertEquals("service type", "Network", service.getServiceType());
- assertEquals("service role", "nfv", service.getServiceRole());
- assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
- assertEquals("service category", "Network Service", service.getCategory());
- assertNull("workload context", service.getWorkloadContext());
- assertEquals("resource order", "Test140PNF", service.getResourceOrder());
-
- /**
- * Check PNF resource, it should be the same as metadata in the topology template in
- * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
- */
- String pnfResourceKey = "9c54e269-122b-4e8a-8b2a-6eac849b441a";
- PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey)
- .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
- assertNull("orchestration mode", pnfResource.getOrchestrationMode());
- assertEquals("Description", "Oracle", pnfResource.getDescription().trim());
- assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
- assertEquals("model invariant UUID", "d832a027-75f3-455d-9de4-f02fcdee7e7e",
- pnfResource.getModelInvariantUUID());
- assertEquals("model version", "1.0", pnfResource.getModelVersion());
- assertEquals("model name", "Test140PNF", pnfResource.getModelName());
- assertEquals("tosca node type", "org.openecomp.resource.pnf.Test140pnf", pnfResource.getToscaNodeType());
- assertEquals("resource category", "Application L4+", pnfResource.getCategory());
- assertEquals("resource sub category", "Call Control", pnfResource.getSubCategory());
-
- /**
- * Check PNF resource customization, it should be the same as metadata in the topology template in
- * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
- */
- String pnfCustomizationKey = "428a3d73-f962-4cc2-ba62-2483c45d6b12";
- PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey)
- .orElseThrow(() -> new EntityNotFoundException(
- "PNF resource customization: " + pnfCustomizationKey + " not found"));
- assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
- assertEquals("model instance name", "Test140PNF 0", pnfCustomization.getModelInstanceName());
- assertEquals("NF type", "", pnfCustomization.getNfType());
- assertEquals("NF Role", "nf", pnfCustomization.getNfRole());
- assertEquals("NF function", "nf", 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)", pnfCustomization.getBlueprintName(),
- pnfCustomization.getBlueprintName());
- assertEquals("cds blueprint version(sdnc_model_version property)", pnfCustomization.getBlueprintVersion(),
- pnfCustomization.getBlueprintVersion());
-
- /**
- * 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());
- }
- }
-
- /**
* Test to check RequestId is being set using the DistributionID.
*/
@Test
diff --git a/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar b/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar
deleted file mode 100644
index 0de1b0b0a0..0000000000
--- a/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar
+++ /dev/null
Binary files differ
diff --git a/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar b/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar
deleted file mode 100644
index bd9a1dc775..0000000000
--- a/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar
+++ /dev/null
Binary files differ