From 0b855c08fd98fb8fa0f4bc40d8df430c897b4bad Mon Sep 17 00:00:00 2001 From: Ankitkumar Patel Date: Sun, 11 Feb 2018 17:51:13 -0500 Subject: Re-org folders, onboard test folder, test config Reorganized the folder structure. Onboarded testcases. Added test config. Issue-ID: OPTFRA-74 Change-Id: I97882a162a405a18ffd287495039e15ae9d0ad7b Signed-off-by: Ankitkumar Patel --- test/bad_test_Utils.py | 21 +++ test/dummy_test_dummy.py | 14 ++ test/placement-tests/request.json | 87 +++++++++ test/placement-tests/request_mso.json | 63 +++++++ .../request_mso_subs_name_blank.json | 63 +++++++ .../request_mso_subs_name_default.json | 63 +++++++ .../request_mso_subs_name_none.json | 62 +++++++ .../request_mso_subs_name_null.json | 63 +++++++ test/placement-tests/request_vCPE.json | 105 +++++++++++ test/placement-tests/scopePolicies.json | 21 +++ test/placement-tests/testScoperequest.json | 144 +++++++++++++++ test/placement-tests/test_by_scope.yaml | 20 +++ test/placement-tests/vnfGroupPolicies.txt | 197 +++++++++++++++++++++ .../CloudAttributePolicy_vGMuxInfra_1.json | 34 ++++ .../CloudAttributePolicy_vG_1.json | 34 ++++ .../DistanceToLocationPolicy_vGMuxInfra_1.json | 30 ++++ .../DistanceToLocationPolicy_vG_1.json | 30 ++++ .../InventoryGroup_vGMuxInfra_1.json | 22 +++ test/policy-local-files/InventoryGroup_vG_1.json | 22 +++ .../PlacementOptimizationPolicy.json | 41 +++++ .../ResourceInstancePolicy_vG_1.json | 26 +++ .../policy-local-files/VNFPolicy_vGMuxInfra_1.json | 36 ++++ test/policy-local-files/VNFPolicy_vG_1.json | 36 ++++ .../ZonePolicy_vGMuxInfra_1.json | 26 +++ test/policy-local-files/ZonePolicy_vG_1.json | 26 +++ test/test-requirements.txt | 4 + test/test_ConductorApiBuilder.py | 39 ++++ test/test_PolicyCalls.py | 115 ++++++++++++ 28 files changed, 1444 insertions(+) create mode 100644 test/bad_test_Utils.py create mode 100644 test/dummy_test_dummy.py create mode 100644 test/placement-tests/request.json create mode 100644 test/placement-tests/request_mso.json create mode 100644 test/placement-tests/request_mso_subs_name_blank.json create mode 100644 test/placement-tests/request_mso_subs_name_default.json create mode 100644 test/placement-tests/request_mso_subs_name_none.json create mode 100644 test/placement-tests/request_mso_subs_name_null.json create mode 100644 test/placement-tests/request_vCPE.json create mode 100644 test/placement-tests/scopePolicies.json create mode 100644 test/placement-tests/testScoperequest.json create mode 100644 test/placement-tests/test_by_scope.yaml create mode 100644 test/placement-tests/vnfGroupPolicies.txt create mode 100644 test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json create mode 100644 test/policy-local-files/CloudAttributePolicy_vG_1.json create mode 100644 test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json create mode 100644 test/policy-local-files/DistanceToLocationPolicy_vG_1.json create mode 100644 test/policy-local-files/InventoryGroup_vGMuxInfra_1.json create mode 100644 test/policy-local-files/InventoryGroup_vG_1.json create mode 100644 test/policy-local-files/PlacementOptimizationPolicy.json create mode 100644 test/policy-local-files/ResourceInstancePolicy_vG_1.json create mode 100644 test/policy-local-files/VNFPolicy_vGMuxInfra_1.json create mode 100644 test/policy-local-files/VNFPolicy_vG_1.json create mode 100644 test/policy-local-files/ZonePolicy_vGMuxInfra_1.json create mode 100644 test/policy-local-files/ZonePolicy_vG_1.json create mode 100644 test/test-requirements.txt create mode 100644 test/test_ConductorApiBuilder.py create mode 100644 test/test_PolicyCalls.py (limited to 'test') diff --git a/test/bad_test_Utils.py b/test/bad_test_Utils.py new file mode 100644 index 0000000..3e5cecd --- /dev/null +++ b/test/bad_test_Utils.py @@ -0,0 +1,21 @@ +import unittest +import json + +from osdf.config.base import osdf_config +from osdf.utils.programming_utils import dot_notation + + +class TestUtils(unittest.TestCase): + + def test_metrics(self): + with open('test/placement-tests/request.json', 'r') as f: + data = json.load(f) + placementInfo = data["placementInfo"] + config_local = osdf_config.core + self.assertEqual("USOSTCDALTX0101UJZZ11", dot_notation(placementInfo, config_local['service_info']['vCPE']['vcpeHostName'])) + self.assertEqual("200", dot_notation(placementInfo, config_local['service_info']['vCPE']['e2eVpnKey'])) + self.assertEqual(['vGMuxInfra', 'vG'], dot_notation(placementInfo, 'demandInfo.placementDemand.resourceModuleName')) + + +if __name__ == '__main__': + unittest.main() diff --git a/test/dummy_test_dummy.py b/test/dummy_test_dummy.py new file mode 100644 index 0000000..dc46d50 --- /dev/null +++ b/test/dummy_test_dummy.py @@ -0,0 +1,14 @@ +import osdf +# import osdfapp +from osdf.config.loader import load_config_file + + +def test_dummy(): + """Generate time constraints from cm-request.json and cm-policy-response.json""" + try: + load_config_file("DUMMY") + except: + pass + return 1 + + diff --git a/test/placement-tests/request.json b/test/placement-tests/request.json new file mode 100644 index 0000000..2fd425c --- /dev/null +++ b/test/placement-tests/request.json @@ -0,0 +1,87 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://test.url.com:5000/callback/", + "sourceId": "so", + "optimizers": ["placement"], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "service", + "modelInvariantId": "fad5f4d5-1c94-4890-927d-9cec6e82997f", + "modelVersionId": "6e13c5e1-f172-436c-9cc4-0d64c94eb7f4", + "modelName": "vCPE", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "SUB12_0325_UD_0833", + "subscriberName": "SUB_12_0325_UD_0833", + "subscriberCommonSiteId": "DALTX0101" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "allotted", + "serviceResourceId": "61d563e8-e714-4393-8f99-cc480144a05e", + "resourceModuleName": "vGMuxInfra", + "exclusionCandidateInfo": [{ + "candidateType": "cloud", + "candidates": ["MDT54NJ", "BDM78NJ"] + }, { + "candidateType": "service", + "candidates": ["RT76U8F789", "PO098HJG"] + } + ], + "requiredCandidateInfo": [{ + "candidateType": "cloud", + "candidates": ["DHU87NY"] + }, { + "candidateType": "service", + "candidates": ["YHT675YH"] + } + ], + "resourceModelInfo": { + "modelCustomizationId": "", + "modelInvariantId": "h59988ce-3d81-4e07-81b5-53d3aa821134", + "modelName": "", + "modelVersion": "2.0", + "modelVersionId": "51d563e8-e714-4393-8f99-cc480144a05e", + "modelType": "allotted" + }, + "tenantId": "", + "tenantName": "" + }, { + "resourceInstanceType": "allotted", + "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e", + "resourceModuleName": "vG", + "resourceModelInfo": { + "modelCustomizationId": "", + "modelInvariantId": "a59988ce-3d81-4e07-81b5-53d3aa821134", + "modelName": "", + "modelVersion": "2.0", + "modelVersionId": "91d563e8-e714-4393-8f99-cc480144a05e", + "modelType": "allotted" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [] + }, + "policyId": [ + "" + ], + "serviceInstanceId": "1234-fsdf-23sdf-24kjnk", + "requestParameters": { + + "commonSiteId": "DALTX0101", + "vendorName": "xyz", + "e2eVpnKey": "200", + "vcpeHostName": "USOSTCDALTX0101UJZZ11" + + } + + } +} \ No newline at end of file diff --git a/test/placement-tests/request_mso.json b/test/placement-tests/request_mso.json new file mode 100644 index 0000000..2d854cb --- /dev/null +++ b/test/placement-tests/request_mso.json @@ -0,0 +1,63 @@ +{ + "requestInfo": { + "transactionId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "requestId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "callbackUrl": "http://127.0.0.1:7001", + "sourceId": "mso", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "", + "modelInvariantId": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", + "modelVersionId": "b8c45108-68df-48c5-8d58-c8dd4de833bb", + "modelName": "ADIOD vMX vPE_BV Service 488", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "subscriberName": "Avteet_Chayal", + "subscriberCommonSiteId": "MDTWNJ2B17" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + } + } + ] + }, + "policyId": [], + "serviceInstanceId": "28014cbe-b334-4d5c-839d-980157929b0b", + "orderInfo": "{\"requestParameters\": {\"aLaCarte\":false,\"usePreload\":true,\"subscriptionServiceType\":\"VPE\",\"alaCarteSet\":true,\"rebuildVolumeGroups\":false,\"userParams\":[{\"name\":\"2017488_adiodvpe0_vnf_config_template_version\",\"value\":\"17.2\"},{\"name\":\"2017488_adiodvpe0_bandwidth_units\",\"value\":\"Gbps\"},{\"name\":\"2017488_adiodvpe0_bandwidth\",\"value\":\"10\"},{\"name\":\"2017488_adiodvpe0_AIC_CLLI\",\"value\":\"MDTWNJ2B17\"},{\"name\":\"2017488_adiodvpe0_vnf_instance_name\",\"value\":\"mtnj309me6\"}],\"autoBuildVfModules\":false,\"cascadeDelete\":false}}" + } +} diff --git a/test/placement-tests/request_mso_subs_name_blank.json b/test/placement-tests/request_mso_subs_name_blank.json new file mode 100644 index 0000000..3195786 --- /dev/null +++ b/test/placement-tests/request_mso_subs_name_blank.json @@ -0,0 +1,63 @@ +{ + "requestInfo": { + "transactionId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "requestId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "callbackUrl": "http://127.0.0.1:7001", + "sourceId": "mso", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "", + "modelInvariantId": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", + "modelVersionId": "b8c45108-68df-48c5-8d58-c8dd4de833bb", + "modelName": "ADIOD vMX vPE_BV Service 488", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "subscriberName": "", + "subscriberCommonSiteId": "MDTWNJ2B17" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + } + } + ] + }, + "policyId": [], + "serviceInstanceId": "28014cbe-b334-4d5c-839d-980157929b0b", + "orderInfo": "{\"requestParameters\": {\"aLaCarte\":false,\"usePreload\":true,\"subscriptionServiceType\":\"VPE\",\"alaCarteSet\":true,\"rebuildVolumeGroups\":false,\"userParams\":[{\"name\":\"2017488_adiodvpe0_vnf_config_template_version\",\"value\":\"17.2\"},{\"name\":\"2017488_adiodvpe0_bandwidth_units\",\"value\":\"Gbps\"},{\"name\":\"2017488_adiodvpe0_bandwidth\",\"value\":\"10\"},{\"name\":\"2017488_adiodvpe0_AIC_CLLI\",\"value\":\"MDTWNJ2B17\"},{\"name\":\"2017488_adiodvpe0_vnf_instance_name\",\"value\":\"mtnj309me6\"}],\"autoBuildVfModules\":false,\"cascadeDelete\":false}}" + } +} diff --git a/test/placement-tests/request_mso_subs_name_default.json b/test/placement-tests/request_mso_subs_name_default.json new file mode 100644 index 0000000..86e2f82 --- /dev/null +++ b/test/placement-tests/request_mso_subs_name_default.json @@ -0,0 +1,63 @@ +{ + "requestInfo": { + "transactionId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "requestId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "callbackUrl": "http://127.0.0.1:7001", + "sourceId": "mso", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "", + "modelInvariantId": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", + "modelVersionId": "b8c45108-68df-48c5-8d58-c8dd4de833bb", + "modelName": "ADIOD vMX vPE_BV Service 488", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "subscriberName": "default", + "subscriberCommonSiteId": "MDTWNJ2B17" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + } + } + ] + }, + "policyId": [], + "serviceInstanceId": "28014cbe-b334-4d5c-839d-980157929b0b", + "orderInfo": "{\"requestParameters\": {\"aLaCarte\":false,\"usePreload\":true,\"subscriptionServiceType\":\"VPE\",\"alaCarteSet\":true,\"rebuildVolumeGroups\":false,\"userParams\":[{\"name\":\"2017488_adiodvpe0_vnf_config_template_version\",\"value\":\"17.2\"},{\"name\":\"2017488_adiodvpe0_bandwidth_units\",\"value\":\"Gbps\"},{\"name\":\"2017488_adiodvpe0_bandwidth\",\"value\":\"10\"},{\"name\":\"2017488_adiodvpe0_AIC_CLLI\",\"value\":\"MDTWNJ2B17\"},{\"name\":\"2017488_adiodvpe0_vnf_instance_name\",\"value\":\"mtnj309me6\"}],\"autoBuildVfModules\":false,\"cascadeDelete\":false}}" + } +} diff --git a/test/placement-tests/request_mso_subs_name_none.json b/test/placement-tests/request_mso_subs_name_none.json new file mode 100644 index 0000000..214e011 --- /dev/null +++ b/test/placement-tests/request_mso_subs_name_none.json @@ -0,0 +1,62 @@ +{ + "requestInfo": { + "transactionId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "requestId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "callbackUrl": "http://127.0.0.1:7001", + "sourceId": "mso", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "", + "modelInvariantId": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", + "modelVersionId": "b8c45108-68df-48c5-8d58-c8dd4de833bb", + "modelName": "ADIOD vMX vPE_BV Service 488", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "subscriberCommonSiteId": "MDTWNJ2B17" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + } + } + ] + }, + "policyId": [], + "serviceInstanceId": "28014cbe-b334-4d5c-839d-980157929b0b", + "orderInfo": "{\"requestParameters\": {\"aLaCarte\":false,\"usePreload\":true,\"subscriptionServiceType\":\"VPE\",\"alaCarteSet\":true,\"rebuildVolumeGroups\":false,\"userParams\":[{\"name\":\"2017488_adiodvpe0_vnf_config_template_version\",\"value\":\"17.2\"},{\"name\":\"2017488_adiodvpe0_bandwidth_units\",\"value\":\"Gbps\"},{\"name\":\"2017488_adiodvpe0_bandwidth\",\"value\":\"10\"},{\"name\":\"2017488_adiodvpe0_AIC_CLLI\",\"value\":\"MDTWNJ2B17\"},{\"name\":\"2017488_adiodvpe0_vnf_instance_name\",\"value\":\"mtnj309me6\"}],\"autoBuildVfModules\":false,\"cascadeDelete\":false}}" + } +} diff --git a/test/placement-tests/request_mso_subs_name_null.json b/test/placement-tests/request_mso_subs_name_null.json new file mode 100644 index 0000000..df7ae8f --- /dev/null +++ b/test/placement-tests/request_mso_subs_name_null.json @@ -0,0 +1,63 @@ +{ + "requestInfo": { + "transactionId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "requestId": "1b98ee53-3fbd-48ca-9b85-302792bf5918", + "callbackUrl": "http://127.0.0.1:7001", + "sourceId": "mso", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 600 + }, + "placementInfo": { + "serviceModelInfo": { + "modelType": "", + "modelInvariantId": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", + "modelVersionId": "b8c45108-68df-48c5-8d58-c8dd4de833bb", + "modelName": "ADIOD vMX vPE_BV Service 488", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "subscriberName": "null", + "subscriberCommonSiteId": "MDTWNJ2B17" + }, + "demandInfo": { + "placementDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + }, + "tenantId": "", + "tenantName": "" + } + ], + "licenseDemand": [{ + "resourceInstanceType": "VNF", + "serviceResourceId": "6ea4128a-ba41-4872-a1f8-2748d0e1c361", + "resourceModuleName": "2017-488_ADIOD-vPE 0", + "resourceModelInfo": { + "modelCustomizationId": "06ed941b-1d83-4132-8a1d-1874f4f4b89b", + "modelInvariantId": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "1.0", + "modelVersionId": "7cd2d399-2bcb-4ecf-bd32-c36cdca7aa03", + "modelType": "" + } + } + ] + }, + "policyId": [], + "serviceInstanceId": "28014cbe-b334-4d5c-839d-980157929b0b", + "orderInfo": "{\"requestParameters\": {\"aLaCarte\":false,\"usePreload\":true,\"subscriptionServiceType\":\"VPE\",\"alaCarteSet\":true,\"rebuildVolumeGroups\":false,\"userParams\":[{\"name\":\"2017488_adiodvpe0_vnf_config_template_version\",\"value\":\"17.2\"},{\"name\":\"2017488_adiodvpe0_bandwidth_units\",\"value\":\"Gbps\"},{\"name\":\"2017488_adiodvpe0_bandwidth\",\"value\":\"10\"},{\"name\":\"2017488_adiodvpe0_AIC_CLLI\",\"value\":\"MDTWNJ2B17\"},{\"name\":\"2017488_adiodvpe0_vnf_instance_name\",\"value\":\"mtnj309me6\"}],\"autoBuildVfModules\":false,\"cascadeDelete\":false}}" + } +} diff --git a/test/placement-tests/request_vCPE.json b/test/placement-tests/request_vCPE.json new file mode 100644 index 0000000..03e32d9 --- /dev/null +++ b/test/placement-tests/request_vCPE.json @@ -0,0 +1,105 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://so:5000/callbackUrl", + "sourceId": "SO", + "requestType": "create", + "numSolutions": 1, + "optimizers": ["placement"], + "timeout": 600 + }, + "requestParameters": { + "customerLatitude": 32.897480, + "customerLongitude": -97.040443, + "customerName": "xyz" + }, + "placementDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "tenantId": "vGMuxInfra-tenant", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vGMuxInfra-customeModelName" + }, + "existingCandidates": { + "identifierType": "service_instance_id", + "identifiers": ["87257b49-9602-4ca1-9817-094e52bc873b"] + }, + "excludedCandidates": { + "identifierType": "service_instance_id", + "identifiers": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d"] + }, + "requiredCandidates": { + "identifierType": "service_instance_id", + "identifiers": ["7e6c3e57-62cd-44f6-aa88-d0896998f7ec"] + } + }, + { + "resourceModuleName": "vG", + "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e", + "tenantId": "vG-tenant", + "resourceModelInfo": { + "modelInvariantId": "vG-modelInvariantId", + "modelVersionId": "vG-versionId", + "modelName": "vG-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vG-customeModelName" + }, + "existingCandidates": { + "identifierType": "service_instance_id", + "identifiers": ["21d5f3e8-e714-4383-8f99-cc480144505a"] + }, + "excludedCandidates": { + "identifierType": "service_instance_id", + "identifiers": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d"] + }, + "requiredCandidates": { + "identifierType": "cloud_region_id", + "identifiers": ["TXAUS219"] + } + } + ], + "serviceInfo": { + "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec", + "serviceModelInfo": { + "modelInvariantId": "vCPE-invariantId", + "modelVersionId": "vCPE-versionId", + "modelName": "vCPE-model", + "modelType": "service", + "modelVersion": "1.0", + "modelCustomizationName": "vCPE-customeModelName" + } + }, + "licenseDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "tenantId": "vGMuxInfra-tenant", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vGMuxInfra-customeModelName" + }, + "existingLicenses": { + "entitlementPoolUUID": [ + "87257b49-9602-4ca1-9817-094e52bc873b", + "43257b49-9602-4fe5-9337-094e52bc9435" + ], + "licenseKeyGroupUUID": [ + "87257b49-9602-4ca1-9817-094e52bc873b", + "43257b49-9602-4fe5-9337-094e52bc9435" + ] + } + } + ] +} diff --git a/test/placement-tests/scopePolicies.json b/test/placement-tests/scopePolicies.json new file mode 100644 index 0000000..123c8e2 --- /dev/null +++ b/test/placement-tests/scopePolicies.json @@ -0,0 +1,21 @@ + { + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "type": "JSON", + "config": "{\"service\":\"ResourceRegionPolicy\",\"policyName\":\"bg4702.ResourceRegionPolicy_vhnportal_v1\",\"description\":\"ResourceRegionPolicy@CreatedBy:mh7921\",\"templateVersion\":\"1802V01\",\"version\":\"1802V01\",\"priority\":\"1\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vhnPortalResourceRegion\",\"policyScope\":{\"serviceType\":[\"DHV\"],\"geoRegion\":[\"US\",\"INTERNATIONAL\"],\"subscriberRole\":[\"FFA Homing\"],\"networkType\":[\"ip\"],\"resourceInstanceType\":[\"Primary Service_Admin\",\"Secondary Service_Admin\"]},\"resourceRegionProperty\":{\"request\":\"{\\\"dhv_service_instance\\\": {\\\"get_param\\\": \\\"SERVICE_INST\\\"}, \\\"service_type\\\": \\\"vHNPortal\\\", \\\"e2evpnkey\\\": {\\\"get_param\\\": \\\"E2EVPNKEY\\\"}}\",\"controller\":\"SDN-C\"},\"type\":\"region_fit\",\"resourceInstanceType\":[\"Primary Service_Admin\",\"Secondary Service_Admin\"]}}", + "policyName": "bg4702.Config_MS_ResourceRegionPolicy_vhnportal_v1.1.xml", + "policyVersion": "1", + "matchingConditions": { + "serviceType": "DHV", + "ECOMPName": "SNIRO-Placement", + "ONAPName": "SNIRO-Placement", + "geoRegion": "US,INTERNATIONAL", + "service": "ResourceRegionPolicy", + "subscriberRole": "FFA Homing", + "type": "region_fit", + "networkType": "ip", + "resourceInstanceType": "Primary Service_Admin,Secondary Service_Admin" + }, + "responseAttributes": {}, + "property": null + } \ No newline at end of file diff --git a/test/placement-tests/testScoperequest.json b/test/placement-tests/testScoperequest.json new file mode 100644 index 0000000..36f0c17 --- /dev/null +++ b/test/placement-tests/testScoperequest.json @@ -0,0 +1,144 @@ +{ + "placementInfo": { + "serviceModelInfo": { + "modelVersion": "1.0", + "modelName": "vCPE", + "modelInvariantId": "250c90b4-42f9-4cd9-9270-fd33a0676f92", + "modelVersionId": "c233e7f3-bd70-4a2c-a88f-4f5743109e8d", + "modelType": "service" + }, + "orderInfo":" { \"requestParameters\": { \"e2eVpnKey\": \"VPNL61657\", \"dhvVendorName\": \"VELOCLOUD\", \"dhvIPSec2TransportBandwidthUp\": \"10\", \"vpnList\": [ { \"vpnInfo\": { \"pvcId\": \"5952413\", \"vpnId\": \"61657\" } } ], \"dhvSiteEffectiveTransportBandwidth\": \"10\", \"ucpeHostName\": \"US292IORLFL0102UJZZ01\", \"commonSiteId\": \"90101124\", \"dhvIPSec2TransportBandwidthDown\": \"10\", \"vnfList\": [ { \"vnfInfo\": { \"vnfType\": \"HN\", \"veloCloudNominalThroughput\": \"100\", \"vnfHostName\": \"US292IORLFL0102UVHN01\", \"vnfPartNumber\": \"DHV-VNF-VC-10M\", \"vnfManagementOption\": \"ATT\", \"vnfSoftwareVersion\": \"2.4.1\" } } ] } }", + "serviceInstanceId": "4701bd3c-b722-4d07-abc0-183ea398fac5", + "demandInfo": { + "placementDemand": [ + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "a297f69d-4d68-4d1f-8b06-be61bddf9e7f", + "resourceInstanceType": "vVIGaaS", + "resourceModuleName": "Primary Tunnel_XConn for DHV Testing_1 0", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "Tunnel_XConn for DHV Testing_1", + "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c", + "modelCustomizationId": "8ade4a5f-a446-4b14-9d12-3ccdd80ef55c", + "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa", + "modelType": "allottedResource" + } + }, + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "73190cfb-e9de-4185-8f18-cb339df6b92a", + "resourceInstanceType": "vVIGaaS", + "resourceModuleName": "Secondary Tunnel_XConn for DHV Testing_1 1", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "Tunnel_XConn for DHV Testing_1", + "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c", + "modelCustomizationId": "32b80123-84ea-4bda-82d9-4c70e812b450", + "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa", + "modelType": "allottedResource" + } + }, + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "f8489f98-db3d-4e84-9ec7-7f7b17b9857f", + "resourceInstanceType": "vHNPortalaaS", + "resourceModuleName": "Primary Service_Admin for DHV Test_1 0", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "Service_Admin for DHV Test_1", + "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2", + "modelCustomizationId": "bace7e9f-c0e7-4479-93df-aa10d387038b", + "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e", + "modelType": "allottedResource" + } + }, + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "8a8973d4-3a91-4fe6-a846-6f4c282f9005", + "resourceInstanceType": "vHNPortalaaS", + "resourceModuleName": "Secondary Service_Admin for DHV Test_1 1", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "Service_Admin for DHV Test_1", + "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2", + "modelCustomizationId": "cb6d359d-8f83-41b6-b0cc-fb3cdf978e25", + "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e", + "modelType": "allottedResource" + } + }, + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "3f2b0c6d-6867-4369-b597-d929305da414", + "resourceInstanceType": "vHNGWaaS", + "resourceModuleName": "Primary IP_Mux_Demux updated_1 0", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "IP_Mux_Demux updated_1", + "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f", + "modelCustomizationId": "925db703-945a-4b14-aafa-607c99c32f46", + "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f", + "modelType": "allottedResource" + } + }, + { + "tenantName": "", + "tenantId": "", + "serviceResourceId": "caea369e-90e6-4bf0-9aa4-c80ffb10c77e", + "resourceInstanceType": "vHNGWaaS", + "resourceModuleName": "Secondary IP_Mux_Demux updated_1 1", + "resourceModelInfo": { + "modelVersion": "1.0", + "modelName": "IP_Mux_Demux updated_1", + "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f", + "modelCustomizationId": "5f5793d7-843c-4f8e-b01d-35ece0b17ead", + "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f", + "modelType": "allottedResource" + } + } + ] + }, + "subscriberInfo": { + "subscriberCommonSiteId": null, + "globalSubscriberId": "300NCQ", + "subscriberName": "Test Customer" + }, + "policyId": [ + "SNIRO.DistanceToLocationPolicy_vhngw", + "SNIRO.VNFPolicy_vhngatewayprimary1_v1", + "SNIRO.ResourceInstancePolicy_hngateway", + "SNIRO.ResourceRegionPolicy_hngateway_v1", + "SNIRO.VNFPolicy_vhngatewaysecondary1_v1", + "SNIRO.ZonePolicy_vhngw", + "SNIRO.PlacementOptimizationPolicy_dhv_v3", + "SNIRO.VNFPolicy_vhnportal_primary1_v1", + "SNIRO.ResourceInstancePolicy_vhnportal_v3", + "SNIRO.ResourceRegionPolicy_vhnportal_v1", + "SNIRO.VNFPolicy_vhnportalsecondary1_v1", + "SNIRO.ZonePolicy_vhnportal", + "SNIRO.DistanceToLocationPolicy_vvig", + "SNIRO.InventoryGroupPolicy_vvig", + "SNIRO.VNFPolicy_vvigprimary1_v1", + "SNIRO.ResourceInstancePolicy_vvig", + "SNIRO.VNFPolicy_vvigsecondary1_v1" + ] + }, + "requestInfo": { + "transactionId": "264e9db9-6d59-4888-9c90-51245d7c811f", + "sourceId": "mso", + "requestType": "initial", + "callbackUrl": "http://127.0.0.1:7001", + "requestId": "264e9db9-6d59-4888-9c90-51245d7c811f", + "optimizer": [ + "placement", + "license" + ], + "numSolutions": 1, + "timeout": 1800 + } +} diff --git a/test/placement-tests/test_by_scope.yaml b/test/placement-tests/test_by_scope.yaml new file mode 100644 index 0000000..0b53e5f --- /dev/null +++ b/test/placement-tests/test_by_scope.yaml @@ -0,0 +1,20 @@ +policy_info: + placement: + policy_fetch: by_scope + policy_scope: + default_scope: XXX_1802 + scope_vcpe: oof_beijing + service_name: placementInfo.serviceModelInfo.modelName + policy_subscriber: SubscriberPolicy + subscriber_name: placementInfo.subscriberInfo.subscriberName + policy_type_vcpe: + - CloudAttributePolicy + - DistanceToLocationPolicy + - instanceReservationPolicy + - PlacementOptimizationPolicy + - ResourceInstancePolicy + - VNFPolicy + - ZonePolicy + default: # if no explicit service related information is needed + policy_fetch: by_name + policy_scope: none diff --git a/test/placement-tests/vnfGroupPolicies.txt b/test/placement-tests/vnfGroupPolicies.txt new file mode 100644 index 0000000..16aca6c --- /dev/null +++ b/test/placement-tests/vnfGroupPolicies.txt @@ -0,0 +1,197 @@ +[ + { + "content": { + "identity": "vhngateway-pri-sec-1", + "policyScope": { + "geoRegion": [ + "US", + "INTERNATIONAL" + ], + "networkType": [ + "ip" + ], + "resourceInstanceType": [ + "Primary IP_Mux_Demux", + "Secondary IP_Mux_Demux" + ], + "serviceType": [ + "DHV" + ], + "subscriberRole": [ + "FFA Homing" + ] + }, + "property": [ + { + "attributes": { + "equipmentRole": "", + "globalCustomerId": "", + "modelInvariantId": "", + "modelVersionId": "", + "operationalStatus": "out-of-service-path", + "orchestrationStatus": [ + "Activate", + "Activated" + ] + }, + "inventoryProvider": "aai", + "inventoryType": "cloud" + }, + { + "attributes": { + "equipmentRole": "", + "globalCustomerId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "modelInvariantId": "", + "modelVersionId": "", + "operationalStatus": "out-of-service-path", + "orchestrationStatus": [ + "Activate", + "Activated" + ] + }, + "inventoryProvider": "aai", + "inventoryType": "service" + } + ], + "resourceInstanceType": [ + "Primary IP_Mux_Demux", + "Secondary IP_Mux_Demux" + ], + "type": "vnfPolicy" + }, + "description": "VNFPolicy@CreatedBy:mh7921", + "guard": "False", + "policyName": "bg4702.VNFPolicy_vhngatewayprimary_v1", + "priority": "1", + "riskLevel": "3", + "riskType": "test", + "service": "VNFPolicy", + "templateVersion": "1802V01", + "version": "1802V01" + }, + { + "content": { + "identity": "vhnportal-pri-sec-1", + "policyScope": { + "geoRegion": [ + "US", + "INTERNATIONAL" + ], + "networkType": [ + "ip" + ], + "resourceInstanceType": [ + "Primary Service_Admin", + "Secondary Service_Admin" + ], + "serviceType": [ + "DHV" + ], + "subscriberRole": [ + "FFA Homing" + ] + }, + "property": [ + { + "attributes": { + "equipmentRole": "", + "globalCustomerId": "", + "modelInvariantId": "", + "modelVersionId": "", + "operationalStatus": "out-of-service-path", + "orchestrationStatus": [ + "Activate", + "Activated" + ] + }, + "inventoryProvider": "aai", + "inventoryType": "cloud" + }, + { + "attributes": { + "equipmentRole": "", + "globalCustomerId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "modelInvariantId": "", + "modelVersionId": "", + "operationalStatus": "out-of-service-path", + "orchestrationStatus": [ + "Activate", + "Activated" + ] + }, + "inventoryProvider": "aai", + "inventoryType": "service" + } + ], + "resourceInstanceType": [ + "Primary Service_Admin", + "Secondary Service_Admin" + ], + "type": "vnfPolicy" + }, + "description": "VNFPolicy@CreatedBy:mh7921", + "guard": "False", + "policyName": "bg4702.VNFPolicy_vhnportal_primary_v1", + "priority": "1", + "riskLevel": "3", + "riskType": "test", + "service": "VNFPolicy", + "templateVersion": "1802V01", + "version": "1802V01" + }, + { + "content": { + "identity": "vvig-pri-sec-1", + "policyScope": { + "geoRegion": [ + "US", + "INTERNATIONAL" + ], + "networkType": [ + "ip" + ], + "resourceInstanceType": [ + "Primary Tunnel_XConn", + "Secondary Tunnel_XConn" + ], + "serviceType": [ + "DHV" + ], + "subscriberRole": [ + "FFA Homing" + ] + }, + "property": [ + { + "attributes": { + "equipmentRole": "", + "globalCustomerId": "21014aa2-526b-11e6-beb8-9e71128cae77", + "modelInvariantId": "", + "modelVersionId": "", + "operationalStatus": "out-of-service-path", + "orchestrationStatus": [ + "Activate", + "Activated" + ] + }, + "inventoryProvider": "aai", + "inventoryType": "service" + } + ], + "resourceInstanceType": [ + "Primary Tunnel_XConn", + "Secondary Tunnel_XConn" + ], + "type": "vnfPolicy" + }, + "description": "VNFPolicy@CreatedBy:mh7921", + "guard": "False", + "policyName": "bg4702.VNFPolicy_vvig1_v1", + "priority": "1", + "riskLevel": "3", + "riskType": "test", + "service": "VNFPolicy", + "templateVersion": "1802V01", + "version": "1802V01" + } +] \ No newline at end of file diff --git a/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json b/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json new file mode 100644 index 0000000..57c0039 --- /dev/null +++ b/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json @@ -0,0 +1,34 @@ +{ + "service": "CloudAttributePolicy", + "policyName": "CloudAttributePolicy_vGMuxInfra", + "description": "Attribute policy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "3", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vGMuxInfra_cloud_attributes", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra"] + }, + "cloudAttributeProperty": { + "networkRoles": { + "all": [ + "vGMuxInfra.OAM", + "vGMuxInfra.SR_IOV_Provider2_1", + "vGMuxInfra.SR_IOV_Provider2_2" + ] + }, + "complex": { + "any": [ ] + } + }, + "type": "attribute", + "resourceInstanceType": ["vGMuxInfra"] + } +} diff --git a/test/policy-local-files/CloudAttributePolicy_vG_1.json b/test/policy-local-files/CloudAttributePolicy_vG_1.json new file mode 100644 index 0000000..cbe2a88 --- /dev/null +++ b/test/policy-local-files/CloudAttributePolicy_vG_1.json @@ -0,0 +1,34 @@ +{ + "service": "CloudAttributePolicy", + "policyName": "cloud AttributePolicy_vG", + "description": "Attribute policy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "10", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vG_cloud_attributes", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG"] + }, + "cloudAttributeProperty": { + "networkRoles": { + "all": [ + "vG.OAM", + "vG.SR_IOV_Provider2_1", + "vG.SR_IOV_Provider2_2" + ] + }, + "complex": { + "any": [ ] + } + }, + "type": "attribute", + "resourceInstanceType": ["vG"] + } +} diff --git a/test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json b/test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json new file mode 100644 index 0000000..414c167 --- /dev/null +++ b/test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json @@ -0,0 +1,30 @@ +{ + "service": "DistanceToLocationPolicy", + "policyName": "DistanceToLocationPolicy_vGMuxInfra", + "description": "DistanceToLocationPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "distanceToLocationProperty": { + "locationInfo": "customer_loc", + "distanceCondition": { + "parameter": "distance", + "value": "50000 km", + "operator": "less" + } + }, + "identity": "distance-vGMuxInfra", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra"] + }, + "type": "distance_to_location", + "resourceInstanceType": ["vGMuxInfra"] + } +} diff --git a/test/policy-local-files/DistanceToLocationPolicy_vG_1.json b/test/policy-local-files/DistanceToLocationPolicy_vG_1.json new file mode 100644 index 0000000..737ee19 --- /dev/null +++ b/test/policy-local-files/DistanceToLocationPolicy_vG_1.json @@ -0,0 +1,30 @@ +{ + "service": "DistanceToLocationPolicy", + "policyName": "DistanceToLocationPolicy_vG", + "description": "DistanceToLocationPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "distanceToLocationProperty": { + "locationInfo": "customer_loc", + "distanceCondition": { + "parameter": "distance", + "value": "50000 km", + "operator": "less" + } + }, + "identity": "distance-vG", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG"] + }, + "type": "distance_to_location", + "resourceInstanceType": ["vG"] + } +} diff --git a/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json b/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json new file mode 100644 index 0000000..20ff7f7 --- /dev/null +++ b/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json @@ -0,0 +1,22 @@ +{ + "service": "InventoryGroupPolicy", + "policyName": "InventoryGroupPolicy_vGMuxInfra", + "description": "InventoryGroupPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vGMuxInfra-pri-sec-2", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra"] + }, + "type": "inventory_group", + "resourceInstanceType": ["vGMuxInfra"] + } +} diff --git a/test/policy-local-files/InventoryGroup_vG_1.json b/test/policy-local-files/InventoryGroup_vG_1.json new file mode 100644 index 0000000..99ae309 --- /dev/null +++ b/test/policy-local-files/InventoryGroup_vG_1.json @@ -0,0 +1,22 @@ +{ + "service": "InventoryGroupPolicy", + "policyName": "InventoryGroupPolicy_vG", + "description": "InventoryGroupPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vG-pri-sec-1", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG"] + }, + "type": "inventory_group", + "resourceInstanceType": ["vG"] + } +} diff --git a/test/policy-local-files/PlacementOptimizationPolicy.json b/test/policy-local-files/PlacementOptimizationPolicy.json new file mode 100644 index 0000000..7c43435 --- /dev/null +++ b/test/policy-local-files/PlacementOptimizationPolicy.json @@ -0,0 +1,41 @@ +{ + "service": "PlacementOptimizationPolicy", + "policyName": "PlacementOptimizationPolicy", + "description": "PlacementOptimizationPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "5", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "objectiveParameter": { + "parameterAttributes": [ + { + "resource": ["vGMuxInfra"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "2", + "operator": "product" + }, + { + "resource": ["vG"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + } + ], + "operator": "sum" + }, + "identity": "optimization", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra","vG"] + }, + "type": "placementOptimization", + "objective": "minimize" + } +} diff --git a/test/policy-local-files/ResourceInstancePolicy_vG_1.json b/test/policy-local-files/ResourceInstancePolicy_vG_1.json new file mode 100644 index 0000000..21ae0e4 --- /dev/null +++ b/test/policy-local-files/ResourceInstancePolicy_vG_1.json @@ -0,0 +1,26 @@ +{ + "service": "ResourceInstancePolicy", + "policyName": "ResourceInstancePolicy_vG", + "description": "ResourceInstancePolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "5", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vG-resourceInstance", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG", "vGMuxInfra"] + }, + "resourceInstanceProperty": { + "request": "{\"test\": \"123\"}", + "controller": "SDN-C" + }, + "type": "instance_fit", + "resourceInstanceType": ["vG", "vGMuxInfra"] + } +} diff --git a/test/policy-local-files/VNFPolicy_vGMuxInfra_1.json b/test/policy-local-files/VNFPolicy_vGMuxInfra_1.json new file mode 100644 index 0000000..b0963d6 --- /dev/null +++ b/test/policy-local-files/VNFPolicy_vGMuxInfra_1.json @@ -0,0 +1,36 @@ +{ + "service": "VNFPolicy", + "policyName": "VNFPolicy_vGMuxInfra", + "description": "VNFPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vGMuxInfra-pri-sec-1", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra"] + }, + "property": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": "" + }, + { + "inventoryProvider": "aai", + "serviceType": "vGMuxInfraaaS", + "inventoryType": "service", + "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77" + } + ], + "type": "vnfPolicy", + "resourceInstanceType": ["vGMuxInfra"] + } +} diff --git a/test/policy-local-files/VNFPolicy_vG_1.json b/test/policy-local-files/VNFPolicy_vG_1.json new file mode 100644 index 0000000..de0a158 --- /dev/null +++ b/test/policy-local-files/VNFPolicy_vG_1.json @@ -0,0 +1,36 @@ +{ + "service": "VNFPolicy", + "policyName": "VNFPolicy_vG", + "description": "VNFPolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vG-pri-sec-1", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG"] + }, + "property": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": " " + }, + { + "inventoryProvider": "aai", + "serviceType": "vGaaS", + "inventoryType": "service", + "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77" + } + ], + "type": "vnfPolicy", + "resourceInstanceType": ["vG"] + } +} diff --git a/test/policy-local-files/ZonePolicy_vGMuxInfra_1.json b/test/policy-local-files/ZonePolicy_vGMuxInfra_1.json new file mode 100644 index 0000000..9f941e4 --- /dev/null +++ b/test/policy-local-files/ZonePolicy_vGMuxInfra_1.json @@ -0,0 +1,26 @@ +{ + "service": "ZonePolicy", + "policyName": "ZonePolicy_vGMuxInfra", + "description": "ZonePolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "5", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "zone-vGMuxInfra", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vGMuxInfra"] + }, + "zoneProperty": { + "qualifier": "different", + "category": "complex" + }, + "type": "zone", + "resourceInstanceType": ["vGMuxInfra"] + } +} diff --git a/test/policy-local-files/ZonePolicy_vG_1.json b/test/policy-local-files/ZonePolicy_vG_1.json new file mode 100644 index 0000000..8104f6b --- /dev/null +++ b/test/policy-local-files/ZonePolicy_vG_1.json @@ -0,0 +1,26 @@ +{ + "service": "ZonePolicy", + "policyName": "ZonePolicy_vG", + "description": "ZonePolicy", + "templateVersion": "1702.03", + "version": "1707", + "priority": "5", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "zone-vG", + "policyScope": { + "serviceType": ["vCPE"], + "geoRegion": ["US", "INTERNATIONAL"], + "networkType": ["ip"], + "resourceInstanceType": ["vG"] + }, + "zoneProperty": { + "qualifier": "different", + "category": "complex" + }, + "type": "zone", + "resourceInstanceType": ["vG"] + } +} diff --git a/test/test-requirements.txt b/test/test-requirements.txt new file mode 100644 index 0000000..b16a37e --- /dev/null +++ b/test/test-requirements.txt @@ -0,0 +1,4 @@ +coverage +moto +pytest +pytest-tap diff --git a/test/test_ConductorApiBuilder.py b/test/test_ConductorApiBuilder.py new file mode 100644 index 0000000..b988efa --- /dev/null +++ b/test/test_ConductorApiBuilder.py @@ -0,0 +1,39 @@ +import unittest +import json +import yaml +from osdf.optimizers.placementopt.conductor.api_builder import conductor_api_builder + + +class TestConductorApiBuilder(unittest.TestCase): + + def test_conductor_api_call_builder(self): + #main_dir = ".." + main_dir = "" + conductor_api_template = main_dir + "osdf/templates/conductor_interface.json" + parameter_data_file = main_dir + "test/placement-tests/request.json" + policy_data_path = main_dir + "test/policy-local-files/" + local_config_file = main_dir + "config/common_config.yaml" + + policy_data_files = ["CloudAttributePolicy_vGMuxInfra_1.json", + "CloudAttributePolicy_vG_1.json", + "DistanceToLocationPolicy_vGMuxInfra_1.json", + "DistanceToLocationPolicy_vG_1.json", + "InventoryGroup_vGMuxInfra_1.json", + "InventoryGroup_vG_1.json", + "PlacementOptimizationPolicy.json", + "ResourceInstancePolicy_vG_1.json", + "VNFPolicy_vGMuxInfra_1.json", + "VNFPolicy_vG_1.json", + "ZonePolicy_vGMuxInfra_1.json", + "ZonePolicy_vG_1.json"] + request_json = json.loads(open(parameter_data_file).read()) + policies = [json.loads(open(policy_data_path + file).read()) for file in policy_data_files] + local_config = yaml.load(open(local_config_file)) + templ_string = conductor_api_builder(request_json, policies, local_config, [], conductor_api_template) + templ_json = json.loads(templ_string) + self.assertEqual(templ_json["name"], "yyy-yyy-yyyy") + + +if __name__ == "__main__": + unittest.main() + diff --git a/test/test_PolicyCalls.py b/test/test_PolicyCalls.py new file mode 100644 index 0000000..b05b6dc --- /dev/null +++ b/test/test_PolicyCalls.py @@ -0,0 +1,115 @@ +import json +import unittest + +from osdf.config.base import osdf_config +from osdf.adapters.policy import interface +from osdf.utils.interfaces import RestClient +import yaml +from mock import patch +from osdf.optimizers.placementopt.conductor import translation + + +class TestPolicyCalls(unittest.TestCase): + + def test_get_subscriber_name(self): + req_json_obj = json.loads(open("./test/placement-tests/request_mso.json").read()) + config_core = osdf_config.core + pmain = config_core['policy_info']['placement'] + print(pmain) + subs_name = interface.get_subscriber_name(req_json_obj, pmain) + print("subscriber_name=", subs_name) + self.assertEquals(subs_name, "Avteet_Chayal") + + + def test_get_subscriber_name_null(self): + req_json_file = "./test/placement-tests/request_mso_subs_name_null.json" + req_json_obj = json.loads(open(req_json_file).read()) + config_core = osdf_config.core + + pmain = config_core['policy_info']['placement'] + print(pmain) + subs_name = interface.get_subscriber_name(req_json_obj, pmain) + print("subscriber_name=", subs_name) + self.assertEquals(subs_name, "DEFAULT") + + + def test_get_subscriber_name_blank(self): + req_json_file = "./test/placement-tests/request_mso_subs_name_blank.json" + req_json_obj = json.loads(open(req_json_file).read()) + config_core = osdf_config.core + + pmain = config_core['policy_info']['placement'] + print(pmain) + subs_name = interface.get_subscriber_name(req_json_obj, pmain) + print("subscriber_name=", subs_name) + self.assertEquals(subs_name, "DEFAULT") + + + def test_get_subscriber_name_default(self): + req_json_file = "./test/placement-tests/request_mso_subs_name_default.json" + req_json_obj = json.loads(open(req_json_file).read()) + config_core = osdf_config.core + + pmain = config_core['policy_info']['placement'] + print(pmain) + subs_name = interface.get_subscriber_name(req_json_obj, pmain) + print("subscriber_name=", subs_name) + self.assertEquals(subs_name, "DEFAULT") + + + def test_get_subscriber_name_none(self): + req_json_file = "./test/placement-tests/request_mso_subs_name_none.json" + req_json_obj = json.loads(open(req_json_file).read()) + config_core = osdf_config.core + + pmain = config_core['policy_info']['placement'] + print(pmain) + subs_name = interface.get_subscriber_name(req_json_obj, pmain) + print("subscriber_name=", subs_name) + self.assertEquals(subs_name, "DEFAULT") + + + def test_get_by_scope(self): + req_json_file = "./test/placement-tests/testScoperequest.json" + allPolicies = "./test/placement-tests/scopePolicies.json" + req_json_obj = json.loads(open(req_json_file).read()) + req_json_obj2 = json.loads(open(allPolicies).read()) + config_core = osdf_config.core + yamlFile = "./test/placement-tests/test_by_scope.yaml" + + with open(yamlFile) as yamlFile2: + policyConfigFile = yaml.load(yamlFile2) + with patch('osdf.adapters.policy.interface.get_subscriber_role', return_value=('FFA Homing', [])) as mock_open: + with patch('osdf.utils.interfaces.RestClient.request', return_value = req_json_obj2): + policiesList = interface.get_by_scope(RestClient, req_json_obj, policyConfigFile, 'placement') + print(policiesList) + #catches Exception if policiesList is null + self.assertTrue(policiesList, 'is null') + self.assertRaises(Exception) + + def test_gen_demands(self): + actionsList = [] + genDemandslist = [] + req_json = "./test/placement-tests/testScoperequest.json" + policiesList = "./test/placement-tests/vnfGroupPolicies.txt" + fh = json.loads(open(policiesList).read()) + #print(fh) + req_json = json.loads(open(req_json).read()) + config_core = osdf_config.core + service_type = req_json['placementInfo'].get('serviceType', None) + # service_type = data_mapping.get_request_service_type(req_json_file) + genDemands = translation.gen_demands(req_json['placementInfo']['demandInfo'], fh) + #print(genDemands) + #print(req_json_file['placementInfo']['demandInfo']['placementDemand'][0]) + for action in req_json['placementInfo']['demandInfo']['placementDemand']: + #print(action['resourceModuleName']) + actionsList.append(action['resourceModuleName']) + for key2,value in genDemands.items(): + #print(key2) + genDemandslist.append(key2) + #genDemandslist.remove('Primary IP_Mux_Demux updated_1 0') + #catches Exception if lists are not equal + self.assertListEqual(genDemandslist, actionsList, 'generated demands are not equal to the passed input [placementDemand][resourceModuleName] list') + +if __name__ == '__main__': + unittest.main() -- cgit 1.2.3-korg