From 9b24e98bb37f90c85f27e515945c8ab86807a0fb Mon Sep 17 00:00:00 2001 From: "Leigh, Phillip (pl876u)" Date: Wed, 9 Jan 2019 11:58:46 -0500 Subject: Handle PNF in AaiCtxBuilder Issue-ID: LOG-764 Change-Id: I1af65f604751d7412cc12e7a42f2dc785d39a90c Signed-off-by: Leigh, Phillip (pl876u) --- .../pomba_aai_context_builder/RestUtilTest.java | 32 ++++++++ src/test/resources/junit/aai-service-instance.json | 43 ++++++++++ src/test/resources/junit/genericVnfInput.json | 96 ++++++++++++++++++++++ src/test/resources/junit/pnfSampleInput.json | 22 +++++ 4 files changed, 193 insertions(+) create mode 100644 src/test/resources/junit/aai-service-instance.json create mode 100644 src/test/resources/junit/genericVnfInput.json create mode 100644 src/test/resources/junit/pnfSampleInput.json (limited to 'src/test') diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java index ad8193a..3753ea6 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java @@ -42,6 +42,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.onap.pomba.common.datatypes.ModelContext; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) @@ -127,4 +128,35 @@ public class RestUtilTest { } return content.toString(); } + + + //// + @Test + public void testretrieveAAIModelDataFromAAI() throws Exception { + + String transactionId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + // 1. simulate the response to obtainResourceLink based on ServiceInstanceId + addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + // 2. simulate the response of AAI (1 vnf and 1 pnf) + addResponse( "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "junit/aai-service-instance.json", aaiEnricherRule); + + // 3. simulate the rsp of VNF + addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39?depth=2", + "junit/genericVnfInput.json", aaiEnricherRule); + + // 4. simulate the response of PNF based on the resourceLink in (2) + //note: match pnf_id in junit/aai-service-instance.json + addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName", + "junit/pnfSampleInput.json", aaiEnricherRule); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + assertEquals(modelCtx.getVnfs().size(), 1); + assertEquals(modelCtx.getPnfs().size(), 1); + + } + } diff --git a/src/test/resources/junit/aai-service-instance.json b/src/test/resources/junit/aai-service-instance.json new file mode 100644 index 0000000..b98c5f6 --- /dev/null +++ b/src/test/resources/junit/aai-service-instance.json @@ -0,0 +1,43 @@ +{ + "service-instance-id": "adc3cc2a-c73e-414f-8ddb-367de81300cb", + "service-instance-name": "Firewall1", + "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f", + "model-version-id": "d3d6cf83-d03a-43cc-99ff-206d40bb9a72", + "resource-version": "1527637758480", + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "Firewall-1" + } + ] + }, + { + "related-to": "pnf", + "related-link": "/aai/v13/network/pnfs/pnf/amdocsPnfName", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "amdocsPnfName" + } + ], + "related-to-property": [ + { + "property-key": "pnf.pnf-name", + "property-value": "Phillip" + } + ] + } + ] + } +} diff --git a/src/test/resources/junit/genericVnfInput.json b/src/test/resources/junit/genericVnfInput.json new file mode 100644 index 0000000..aac8bd6 --- /dev/null +++ b/src/test/resources/junit/genericVnfInput.json @@ -0,0 +1,96 @@ +{ + "vnf-id": "8a9ddb25-2e79-449c-a40d-5011bac0da39", + "vnf-name": "Firewall-1", + "vnf-type": "vFW-vSINK-service/vFWvSINK 0", + "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1527637940029", + "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820", + "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6", + "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc", + "nf-type": "", + "nf-function": "", + "nf-role": "", + "nf-naming-code": "", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFWCL" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "adc3cc2a-c73e-414f-8ddb-367de81300cb" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "Firewall1" + } + ] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870", + "relationship-data": [ + { + "relationship-key": "l3-network.network-id", + "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870" + } + ], + "related-to-property": [ + { + "property-key": "l3-network.network-name", + "property-value": "HNPORTALOAM.OAM" + } + ] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872", + "relationship-data": [ + { + "relationship-key": "l3-network.network-id", + "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951872" + } + ], + "related-to-property": [ + { + "property-key": "l3-network.network-name", + "property-value": "HNPORTAL_SRIOV_2" + } + ] + } + ] + }, + "vf-modules": { + "vf-module": [ + { + "vf-module-id": "1563b649-9e05-4288-b7d9-e3639a54ace6", + "vf-module-name": "vFW_SINC_Module-2", + "heat-stack-id": "vFW_SINC_Module-2/41c4533a-748d-4cf4-a8d3-eccdd0aeb0d4", + "orchestration-status": "active", + "is-base-vf-module": true, + "resource-version": "1527638439198", + "model-invariant-id": "74bc1518-282d-4148-860f-8892b6369456", + "model-version-id": "4e3d28cf-d654-41af-a47b-04b4bd0ac58e", + "model-customization-id": "cc51ab7d-9b03-4bd6-9104-09df0c7c7907", + "module-index": 0 + } + ] + } +} diff --git a/src/test/resources/junit/pnfSampleInput.json b/src/test/resources/junit/pnfSampleInput.json new file mode 100644 index 0000000..44f4a2d --- /dev/null +++ b/src/test/resources/junit/pnfSampleInput.json @@ -0,0 +1,22 @@ +{ + "pnf-name": "amdocsPnfName", + "pnf-name2": "amdocsPnfName2", + "pnf-name2-source": "pombaName2Source", + "pnf-id": "11112222pnf88889999", + "equip-type": "software", + "equip-vendor": "8df84f0a-737a-4628-be9c-c3c78454f9d9", + "equip-model": "123134236", + "management-option": "TBD", + "sw-version": "2", + "in-maint": "true", + "frame-id": "99888", + "serial-number": "c44b872f6830498b88c4989d67b2a6b7", + "status": "ACTIVE", + "nf-role": "22222", + "model-invariant-id": "12345", + "model-version-id": "2123", + "admin_state_up": true, + "tenant_id": "c44b872f6830498b88c4989d67b2a6b7", + "created_at": "2018-03-20T16:49:01Z", + "provider:network_type": "vlan" +} \ No newline at end of file -- cgit 1.2.3-korg