aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/conductor/test_conductor_translation.py53
-rw-r--r--test/config/common_config.yaml43
-rw-r--r--test/config/has_config.yaml24
-rwxr-xr-xtest/config/osdf_config.yaml34
-rw-r--r--test/local_data/test_local_policies.py12
-rw-r--r--test/operation/test_responses.py15
-rw-r--r--test/placement-tests/request.json186
-rw-r--r--test/placement-tests/response.json49
-rw-r--r--test/policy-local-files/Affinity_vCPE_1.json21
-rw-r--r--test/policy-local-files/Capacity_vGMuxInfra.json21
-rw-r--r--test/policy-local-files/Capacity_vG_1.json21
-rw-r--r--test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json34
-rw-r--r--test/policy-local-files/CloudAttributePolicy_vG_1.json34
-rw-r--r--test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json30
-rw-r--r--test/policy-local-files/DistanceToLocationPolicy_vG_1.json30
-rw-r--r--test/policy-local-files/Distance_vGMuxInfra_1.json21
-rw-r--r--test/policy-local-files/Distance_vG_1.json21
-rw-r--r--test/policy-local-files/INVALID-policies/INVALID-Affinity_vCPE_1.json21
-rw-r--r--test/policy-local-files/InventoryGroup_vGMuxInfra_1.json22
-rw-r--r--test/policy-local-files/InventoryGroup_vG_1.json22
-rw-r--r--test/policy-local-files/Min_Guarantee_vGMuxInfra_1.json21
-rw-r--r--test/policy-local-files/Placement_Optimization_1.json (renamed from test/policy-local-files/PlacementOptimizationPolicy.json)17
-rw-r--r--test/policy-local-files/QueryPolicy_vCPE.json20
-rw-r--r--test/policy-local-files/ResourceInstancePolicy_vG_1.json26
-rw-r--r--test/policy-local-files/VNFPolicy_vGMuxInfra_1.json36
-rw-r--r--test/policy-local-files/VNFPolicy_vG_1.json36
-rw-r--r--test/policy-local-files/ZonePolicy_vGMuxInfra_1.json26
-rw-r--r--test/policy-local-files/ZonePolicy_vG_1.json26
-rw-r--r--test/policy-local-files/hpa_policy_vGMuxInfra_1.json144
-rw-r--r--test/policy-local-files/hpa_policy_vG_1.json144
-rw-r--r--test/policy-local-files/meta-invalid-policies.txt4
-rw-r--r--test/policy-local-files/meta-valid-policies.txt12
-rw-r--r--test/policy-local-files/vnfPolicy_vG.json31
-rw-r--r--test/policy-local-files/vnfPolicy_vGMuxInfra.json31
-rw-r--r--test/policy/test_policy_interface.py64
-rw-r--r--test/test_ConductorApiBuilder.py39
-rw-r--r--test/test_PolicyCalls.py60
-rw-r--r--test/test_api_validation.py5
-rw-r--r--test/test_process_placement_opt.py58
39 files changed, 1016 insertions, 498 deletions
diff --git a/test/conductor/test_conductor_translation.py b/test/conductor/test_conductor_translation.py
new file mode 100644
index 0000000..b277b6a
--- /dev/null
+++ b/test/conductor/test_conductor_translation.py
@@ -0,0 +1,53 @@
+# -------------------------------------------------------------------------
+# Copyright (c) 2017-2018 AT&T Intellectual Property
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+import mock
+import unittest
+
+from flask import Response
+from mock import patch
+from osdf.adapters.local_data import local_policies
+from osdf.optimizers.placementopt.conductor import translation as tr
+from osdf.utils.interfaces import json_from_file, yaml_from_file
+
+
+class TestConductorTranslation(unittest.TestCase):
+
+ def setUp(self):
+ 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"
+
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ self.request_json = json_from_file(parameter_data_file)
+ self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
+
+ def tearDown(self):
+ pass
+
+ def test_gen_demands(self):
+ res = tr.gen_demands(self.request_json, self.policies)
+ assert res is not None
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/test/config/common_config.yaml b/test/config/common_config.yaml
new file mode 100644
index 0000000..1c041d9
--- /dev/null
+++ b/test/config/common_config.yaml
@@ -0,0 +1,43 @@
+osdf_system:
+ libpath: /opt/app/osdf/libs
+ osdf_ports:
+ internal: 24699 # inside the Docker container, the app listens to this port
+ external: 14699 # clients use this port on DockerHost
+ osdf_ip_default: 0.0.0.0
+# # Important Note: At deployment time, we need to ensure the port mapping is done
+# ssl_context: ['./../etc/sniromanager.crt', './../etc/sniromanager.key']
+
+osdf_temp: # special configuration required for "workarounds" or testing
+ local_policies:
+ global_disabled: False
+ local_placement_policies_enabled: True
+ placement_policy_files_vcpe: # workaroud for policy platform glitches (or "work-arounds" for other components)
+ - Affinity_vCPE_1.json
+ - Capacity_vGMuxInfra.json
+ - Capacity_vG_1.json
+ - Distance_vGMuxInfra_1.json
+ - Distance_vG_1.json
+ - Min_Guarantee_vGMuxInfra_1.json
+ - Placement_Optimization_1.json
+ - QueryPolicy_vCPE.json
+ - hpa_policy_vGMuxInfra_1.json
+ - hpa_policy_vG_1.json
+ - vnfPolicy_vG.json
+ - vnfPolicy_vGMuxInfra.json
+service_info:
+ vCPE:
+ vcpeHostName: requestParameters.vcpeHostName
+ e2eVpnKey: requestParameters.e2eVpnKey
+
+policy_info:
+ placement:
+ policy_fetch: by_scope
+ policy_scope:
+ default_scope: OSDF_R2
+ scope_vcpe: OSDF_R2
+ service_name: placementInfo.serviceModelInfo.modelName
+ policy_subscriber: SubscriberPolicy
+ subscriber_name: placementInfo.subscriberInfo.subscriberName
+ default: # if no explicit service related information is needed
+ policy_fetch: by_name
+ policy_scope: none
diff --git a/test/config/has_config.yaml b/test/config/has_config.yaml
new file mode 100644
index 0000000..8cbeda2
--- /dev/null
+++ b/test/config/has_config.yaml
@@ -0,0 +1,24 @@
+policy_config_mapping:
+ attributes:
+ hypervisor: hypervisor,
+ cloud_version: cloudVersion,
+ cloud_type: cloudType,
+ dataplane: dataPlane,
+ network_roles: networkRoles,
+ complex: complex,
+ state: state,
+ country: country,
+ geo_region: geoRegion,
+ exclusivity_groups: exclusivityGroups,
+ replication_role: replicationRole,
+ remapping:
+ model-invariant-id: modelInvariantId,
+ model-version-id: modelVersionId
+ candidates:
+ # for (k1, v1), if k1 is in demand, set prop[k2] = _get_candidates(demand[k1])
+ exclusionCandidateInfo: excluded_candidates,
+ requiredCandidateInfo: required_candidates
+ extra_fields:
+ # we have [k1, k2, k3, k4] type items and x is policy-content-properties
+ # if x[k1] == k2: set prop[k3] = k4
+ - [inventoryType, cloud, region, {get_param: CHOSEN_REGION}] \ No newline at end of file
diff --git a/test/config/osdf_config.yaml b/test/config/osdf_config.yaml
new file mode 100755
index 0000000..69ebdf0
--- /dev/null
+++ b/test/config/osdf_config.yaml
@@ -0,0 +1,34 @@
+osdfUserNameForSO: "" # The OSDF Manager username for MSO.
+odfPasswordForSO: "" # The OSDF Manager password for MSO.
+
+# msoUrl: "" # The SO url for call back. This will be part of the request, so no need
+soUsername: "" # SO username for call back.
+soPassword: "" # SO password for call back.
+
+conductorUrl: "https://OOF-HAS-CONDUCTOR-HOST:8091"
+conductorUsername: "CONDUCTOR-USER"
+conductorPassword: "CONDUCTOR-PASSWD"
+conductorPingWaitTime: 60 # seconds to wait before calling the conductor retry URL
+conductorMaxRetries: 30 # if we don't get something in 30 minutes, give up
+
+# Policy Platform -- requires ClientAuth, Authorization, and Environment
+policyPlatformUrl: https://POLICY-URL:8081/pdp/getConfig # Policy Dev platform URL
+policyPlatformEnv: TEST # Environment for policy platform
+policyPlatformUsername: POLICY-USER # Policy platform username.
+policyPlatformPassword: POLICY-PASSWD # Policy platform password.
+policyClientUsername: POLICY-CLIENT-USER # For use with ClientAuth
+policyClientPassword: POLICY-CLIENT-PASSWD # For use with ClientAuth
+
+messageReaderHosts: https://DMAAP-HOST1:3905,https://DMAAP-HOST2:3905,https://DMAAP-HOST3:3905
+messageReaderTopic: org.onap.oof.osdf.multicloud
+messageReaderAafUserId: DMAAP-OSDF-MC-USER
+messageReaderAafPassword: DMAAP-OSDF-MC-PASSWD
+
+sdcUrl: https://SDC-HOST:8443/sdc/v1/catalog
+sdcUsername: SDC-OSDF-USER
+sdcPassword: SDC-OSDF-PASSWD
+sdcONAPInstanceID: ONAP-OSDF
+
+osdfPlacementUrl: "http://127.0.0.1:24699/osdf/api/v2/placement"
+osdfPlacementUsername: "test"
+osdfPlacementPassword: "testpwd"
diff --git a/test/local_data/test_local_policies.py b/test/local_data/test_local_policies.py
index 120b186..13154c5 100644
--- a/test/local_data/test_local_policies.py
+++ b/test/local_data/test_local_policies.py
@@ -15,9 +15,8 @@
#
# -------------------------------------------------------------------------
#
+import re
import unittest
-import json
-import yaml
from osdf.adapters.local_data import local_policies
@@ -27,9 +26,12 @@ class TestLocalPolicies(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self.folder = './test/policy-local-files'
- self.invalid_policies = ['INVALID-one.json', 'INVALID-two.json']
- self.valid_policies = ['CloudAttributePolicy_vG_1.json', 'CloudAttributePolicy_vGMuxInfra_1.json']
-
+ self.valid_policies_file = self.folder + '/' + 'meta-valid-policies.txt'
+ self.invalid_policies_file = self.folder + '/' + 'meta-invalid-policies.txt'
+ self.valid_policies = local_policies.get_policy_names_from_file(self.valid_policies_file)
+ self.invalid_policies = local_policies.get_policy_names_from_file(self.invalid_policies_file)
+
+
def test_get_local_policies_no_policies(self):
with self.assertRaises(FileNotFoundError):
res = local_policies.get_local_policies(self.folder, self.invalid_policies)
diff --git a/test/operation/test_responses.py b/test/operation/test_responses.py
index 253cb7c..2e089ec 100644
--- a/test/operation/test_responses.py
+++ b/test/operation/test_responses.py
@@ -28,7 +28,20 @@ class TestLocalPolicies(unittest.TestCase):
super(self.__class__, self).__init__(*args, **kwargs)
self.folder = './test/policy-local-files'
self.invalid_policies = ['INVALID-one.json', 'INVALID-two.json']
- self.valid_policies = ['CloudAttributePolicy_vG_1.json', 'CloudAttributePolicy_vGMuxInfra_1.json']
+ self.valid_policies = [
+ 'Affinity_vCPE_1.json',
+ 'Capacity_vG_1.json',
+ 'Distance_vG_1.json',
+ 'Placement_Optimization_1.json',
+ 'hpa_policy_vGMuxInfra_1.json',
+ 'vnfPolicy_vG.json',
+ 'Capacity_vGMuxInfra.json',
+ 'Distance_vGMuxInfra_1.json',
+ 'Min_Guarantee_vGMuxInfra_1.json',
+ 'QueryPolicy_vCPE.json',
+ 'hpa_policy_vG_1.json',
+ 'vnfPolicy_vGMuxInfra.json'
+ ]
def test_get_local_policies_no_policies(self):
with self.assertRaises(FileNotFoundError):
diff --git a/test/placement-tests/request.json b/test/placement-tests/request.json
index 2fd425c..c4cb31f 100644
--- a/test/placement-tests/request.json
+++ b/test/placement-tests/request.json
@@ -1,87 +1,101 @@
-{
- "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"
-
- }
-
- }
+{
+ "requestInfo": {
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/",
+ "sourceId": "SO",
+ "requestType": "create",
+ "numSolutions": 1,
+ "optimizers": ["placement"],
+ "timeout": 600
+ },
+ "placementInfo": {
+ "requestParameters": { "customerLatitude": 32.89748, "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"
+ }
+ },
+ {
+ "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": "serviceInstanceId",
+ "cloudOwner": "",
+ "identifiers": ["gjhd-098-fhd-987"]
+ }
+ ],
+ "excludedCandidates": [
+ {
+ "identifierType": "serviceInstanceId",
+ "cloudOwner": "",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ {
+ "identifierType": "vimId",
+ "cloudOwner": "vmware",
+ "identifiers": ["NYMDT67"]
+ }
+ ],
+ "requiredCandidates": [
+ {
+ "identifierType": "vimId",
+ "cloudOwner": "amazon",
+ "identifiers": ["TXAUS219"]
+ }
+ ]
+ }
+ ]
+ },
+ "serviceInfo": {
+ "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec",
+ "serviceName": "vCPE",
+ "modelInfo": {
+ "modelInvariantId": "vCPE-invariantId",
+ "modelVersionId": "vCPE-versionId",
+ "modelName": "vCPE-model",
+ "modelType": "service",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "vCPE-customeModelName"
+ }
+ },
+ "licenseInfo": {
+ "licenseDemands": [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "vGMuxInfra-xx",
+ "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"]
+ }
+ }
+ ]
+ }
} \ No newline at end of file
diff --git a/test/placement-tests/response.json b/test/placement-tests/response.json
new file mode 100644
index 0000000..f6c1bea
--- /dev/null
+++ b/test/placement-tests/response.json
@@ -0,0 +1,49 @@
+{
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "requestStatus": "completed",
+ "statusMessage": "Success!",
+ "solutions": {
+ "placementSolutions": [
+ [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "someResourceId",
+ "solution": {
+ "identifierType": "serviceInstanceId",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ "assignmentInfo": [
+ { "key": "cloudOwner", "value": "amazon" },
+ { "key": "vnfHostName", "value": "ahr344gh" },
+ { "key": "isRehome", "value": "False" },
+ { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" }
+ ]
+ },
+ {
+ "resourceModuleName": "vG",
+ "serviceResourceId": "someResourceId",
+ "solution": {
+ "identifierType": "cloudRegionId",
+ "cloudOwner": "amazon",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ "assignmentInfo": [
+ { "key": "cloudOwner", "value": "amazon" },
+ { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" }
+ ]
+ }
+ ]
+ ],
+ "licenseSolutions": [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "someResourceId",
+ "entitlementPoolUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "licenseKeyGroupUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/test/policy-local-files/Affinity_vCPE_1.json b/test/policy-local-files/Affinity_vCPE_1.json
new file mode 100644
index 0000000..c42e9d8
--- /dev/null
+++ b/test/policy-local-files/Affinity_vCPE_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "affinityPolicy",
+ "policyName": "oofBeijing.affinityPolicy_vcpe",
+ "description": "Affinity policy for vCPE",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "5",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "identity": "affinity_vCPE",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"],
+ "affinityProperty": {
+ "qualifier": "different",
+ "category": "complex"
+ },
+ "policyType": "affinityPolicy",
+ "resources": ["vGMuxInfra", "vG"]
+ }
+}
diff --git a/test/policy-local-files/Capacity_vGMuxInfra.json b/test/policy-local-files/Capacity_vGMuxInfra.json
new file mode 100644
index 0000000..9eec54d
--- /dev/null
+++ b/test/policy-local-files/Capacity_vGMuxInfra.json
@@ -0,0 +1,21 @@
+{
+ "service": "capacityPolicy",
+ "policyName": "oofBeijing.capacityPolicy_vGMuxInfra",
+ "description": "Capacity policy for vGMuxInfra",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "5",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "identity": "capacity_vGMuxInfra",
+ "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
+ "resources": ["vGMuxInfra"],
+ "capacityProperty": {
+ "cpu": {"value": 2, "operator": ">"},
+ "memory": {"value": 4, "operator": ">", "unit": "Gb"}
+ },
+ "policyType": "capacityPolicy"
+ }
+}
diff --git a/test/policy-local-files/Capacity_vG_1.json b/test/policy-local-files/Capacity_vG_1.json
new file mode 100644
index 0000000..d5644a8
--- /dev/null
+++ b/test/policy-local-files/Capacity_vG_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "capacityPolicy",
+ "policyName": "oofBeijing.capacityPolicy_vGMuxInfra",
+ "description": "Capacity policy for vGMuxInfra",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "5",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "identity": "capacity_vGMuxInfra",
+ "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vG"],
+ "resources": ["vG"],
+ "capacityProperty": {
+ "cpu": {"value": 2, "operator": ">"},
+ "memory": {"value": 4, "operator": ">", "unit": "Gb"}
+ },
+ "policyType": "capacityPolicy"
+ }
+}
diff --git a/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json b/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json
deleted file mode 100644
index 57c0039..0000000
--- a/test/policy-local-files/CloudAttributePolicy_vGMuxInfra_1.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "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
deleted file mode 100644
index cbe2a88..0000000
--- a/test/policy-local-files/CloudAttributePolicy_vG_1.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "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
deleted file mode 100644
index 414c167..0000000
--- a/test/policy-local-files/DistanceToLocationPolicy_vGMuxInfra_1.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "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
deleted file mode 100644
index 737ee19..0000000
--- a/test/policy-local-files/DistanceToLocationPolicy_vG_1.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "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/Distance_vGMuxInfra_1.json b/test/policy-local-files/Distance_vGMuxInfra_1.json
new file mode 100644
index 0000000..a835ef1
--- /dev/null
+++ b/test/policy-local-files/Distance_vGMuxInfra_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "distancePolicy",
+ "policyName": "oofBeijing.distancePolicy_vGMuxInfra",
+ "description": "Distance Policy for vGMuxInfra",
+ "templateVersion": "0.0.1",
+ "version": "oofBeijing",
+ "priority": "3",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "distanceProperties": {
+ "locationInfo": "customer_location",
+ "distance": { "value": "500", "operator": "<", "unit": "km" }
+ },
+ "identity": "distance-vGMuxInfra",
+ "resources": ["vGMuxInfra"],
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
+ "policyType": "distancePolicy"
+ }
+}
diff --git a/test/policy-local-files/Distance_vG_1.json b/test/policy-local-files/Distance_vG_1.json
new file mode 100644
index 0000000..1af021a
--- /dev/null
+++ b/test/policy-local-files/Distance_vG_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "distancePolicy",
+ "policyName": "oofBeijing.distancePolicy_vG",
+ "description": "Distance Policy for vG",
+ "templateVersion": "0.0.1",
+ "version": "oofBeijing",
+ "priority": "3",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "distanceProperties": {
+ "locationInfo": "customer_location",
+ "distance": { "value": "1500", "operator": "<", "unit": "km" }
+ },
+ "identity": "distance-vG",
+ "resources": ["vG"],
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"],
+ "policyType": "distancePolicy"
+ }
+}
diff --git a/test/policy-local-files/INVALID-policies/INVALID-Affinity_vCPE_1.json b/test/policy-local-files/INVALID-policies/INVALID-Affinity_vCPE_1.json
new file mode 100644
index 0000000..86670c3
--- /dev/null
+++ b/test/policy-local-files/INVALID-policies/INVALID-Affinity_vCPE_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "affinityPolicy",
+ "MISSINGpolicyName": "oofBeijing.affinityPolicy_vcpe",
+ "description": "Affinity policy for vCPE",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "5",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "identity": "affinity_vCPE",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"],
+ "affinityProperty": {
+ "qualifier": "different",
+ "category": "complex"
+ },
+ "policyType": "affinityPolicy",
+ "resources": ["vGMuxInfra", "vG"]
+ }
+}
diff --git a/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json b/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json
deleted file mode 100644
index 20ff7f7..0000000
--- a/test/policy-local-files/InventoryGroup_vGMuxInfra_1.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "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
deleted file mode 100644
index 99ae309..0000000
--- a/test/policy-local-files/InventoryGroup_vG_1.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "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/Min_Guarantee_vGMuxInfra_1.json b/test/policy-local-files/Min_Guarantee_vGMuxInfra_1.json
new file mode 100644
index 0000000..654c548
--- /dev/null
+++ b/test/policy-local-files/Min_Guarantee_vGMuxInfra_1.json
@@ -0,0 +1,21 @@
+{
+ "service": "minGuaranteePolicy",
+ "policyName": "oofBeijing.minGuaranee_vGMuxInfra",
+ "description": "Min guarantee policy for vGMuxInfra",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "5",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "identity": "minGuarantee_vGMuxInfra",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
+ "minGuaranteeProperty": {
+ "cpu": {"value": "true", "operator": "="},
+ "memory": {"value": "false", "operator": "="}
+ },
+ "policyType": "minGuaraneePolicy",
+ "resourceInstanceType": ["vGMuxInfra"]
+ }
+}
diff --git a/test/policy-local-files/PlacementOptimizationPolicy.json b/test/policy-local-files/Placement_Optimization_1.json
index 7c43435..5748c99 100644
--- a/test/policy-local-files/PlacementOptimizationPolicy.json
+++ b/test/policy-local-files/Placement_Optimization_1.json
@@ -1,9 +1,9 @@
{
"service": "PlacementOptimizationPolicy",
- "policyName": "PlacementOptimizationPolicy",
- "description": "PlacementOptimizationPolicy",
+ "policyName": "oofBeijing.PlacementOptimizationPolicy_vGMuxInfra",
+ "description": "Placement Optimization Policy for vGMuxInfra",
"templateVersion": "1702.03",
- "version": "1707",
+ "version": "oofBeijing",
"priority": "5",
"riskType": "test",
"riskLevel": "3",
@@ -15,7 +15,7 @@
"resource": ["vGMuxInfra"],
"customerLocationInfo": "customer_loc",
"parameter": "distance",
- "weight": "2",
+ "weight": "1",
"operator": "product"
},
{
@@ -29,13 +29,8 @@
"operator": "sum"
},
"identity": "optimization",
- "policyScope": {
- "serviceType": ["vCPE"],
- "geoRegion": ["US", "INTERNATIONAL"],
- "networkType": ["ip"],
- "resourceInstanceType": ["vGMuxInfra","vG"]
- },
- "type": "placementOptimization",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"],
+ "policyType": "placementOptimization",
"objective": "minimize"
}
}
diff --git a/test/policy-local-files/QueryPolicy_vCPE.json b/test/policy-local-files/QueryPolicy_vCPE.json
new file mode 100644
index 0000000..4ed83f9
--- /dev/null
+++ b/test/policy-local-files/QueryPolicy_vCPE.json
@@ -0,0 +1,20 @@
+{
+ "service": "optimizationQueryPolicy",
+ "policyName": "oofBeijing.queryPolicy_vCPE",
+ "description": "Optimization query policy for vCPE",
+ "templateVersion": "0.0.1",
+ "version": "oofBeijing",
+ "priority": "3",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "queryProperties": [
+ {"attribute":"locationId", "value": "orderInfo.customerLocation"},
+ {"attribute":"id", "value": "orderInfo.vpnInfo"},
+ {"attribute":"upstreamBW", "value": "orderInfo.vpnInfo"}
+ ],
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"],
+ "type": "optimizationQueryPolicy"
+ }
+}
diff --git a/test/policy-local-files/ResourceInstancePolicy_vG_1.json b/test/policy-local-files/ResourceInstancePolicy_vG_1.json
deleted file mode 100644
index 21ae0e4..0000000
--- a/test/policy-local-files/ResourceInstancePolicy_vG_1.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "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
deleted file mode 100644
index b0963d6..0000000
--- a/test/policy-local-files/VNFPolicy_vGMuxInfra_1.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "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
deleted file mode 100644
index de0a158..0000000
--- a/test/policy-local-files/VNFPolicy_vG_1.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "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
deleted file mode 100644
index 9f941e4..0000000
--- a/test/policy-local-files/ZonePolicy_vGMuxInfra_1.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "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
deleted file mode 100644
index 8104f6b..0000000
--- a/test/policy-local-files/ZonePolicy_vG_1.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "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/policy-local-files/hpa_policy_vGMuxInfra_1.json b/test/policy-local-files/hpa_policy_vGMuxInfra_1.json
new file mode 100644
index 0000000..bf09532
--- /dev/null
+++ b/test/policy-local-files/hpa_policy_vGMuxInfra_1.json
@@ -0,0 +1,144 @@
+{
+ "service": "hpaPolicy",
+ "policyName": "oofBeijing.hpaPolicy_vGMuxInfra",
+ "description": "HPA policy for vGMuxInfra",
+ "templateVersion": "0.0.1",
+ "version": "1.0",
+ "priority": "3",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "resources": "vGMuxInfra",
+ "identity": "hpaPolicy_vGMuxInfra",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
+ "policyType": "hpaPolicy",
+ "flavorFeatures": [
+ {
+ "flavorLabel": "flavor_label_vm_01",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "cpuTopology",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"numCpuSockets", "values": "2","operator": ">=", "unit": ""},
+ {"attribute":"numCpuSockets", "values": "4","operator": "<=", "unit": ""},
+ {"attribute":"numCpuCores", "value": "2", "operator":">=", "unit": ""},
+ {"attribute":"numCpuCores", "value": "4", "operator":"<=", "unit": ""},
+ {"attribute":"numCpuThreads", "value": "4", "operator":">=", "unit": ""},
+ {"attribute":"numCpuThreads", "value": "8", "operator":"<=", "unit": ""}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "ovsDpdk",
+ "mandatory" : "False",
+ "score" : "3",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"dataProcessingAccelerationLibrary", "value":"ovsDpdk_version", "operator": "=", "unit":""}
+ ]
+ },
+ {
+ "hpa_feature" : "cpuInstructionSetExtensions",
+ "mandatory" : "True",
+ "architecture": "INTEL-64",
+ "featureAttributes": [
+ {"attribute":"instructionSetExtensions", "value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""}
+ ]
+ }
+ ]
+ },
+ {
+ "flavorLabel": "flavor_label_vm_02",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "cpuPinningy",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"logicalCpuThreadPinningPolicy", "value":"<CPUTHREADPOLICY>", "operator": "=", "unit":""},
+ {"attribute":"logicalCpuPinningPolicy", "value": "<CPUPOLICY>","operator": "=", "unit":""}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "localStorage",
+ "mandatory" : "False",
+ "score" : "5",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "diskSize", "value": "2", "operator": "=", "unit": "GB"},
+ {"attribute": "ephemeralDiskSize", "value": "2", "operator": "=", "unit": "GB"},
+ {"attribute": "swapMemSize", "value":"16", "operator": "=", "unit": "MB"}
+ ]
+ },
+ {
+ "hpa_feature" : "pcie",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "pciCount", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "pciVendorId", "value":"8086", "operator": "=", "unit": ""},
+ {"attribute": "pciDeviceId", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "functionType", "value": "<PCITYPEVALUE>","operator": "=", "unit": ""}
+ ]
+ }
+ ]
+ },
+ {
+ "flavorLabel": "flavor_label_vm_03",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "numa",
+ "mandatory" : "False",
+ "score" : "5",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numaNodes", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "numaCpu-0", "values":"2", "operator": "=", "unit": ""},
+ {"attribute": "numaMem-0", "value": "2048", "operator": "=", "unit": "MB"},
+ {"attribute": "numaCpu-1", "values":"4", "operator": "=", "unit": ""},
+ {"attribute": "numaMem-1", "value": "4096", "operator": "=", "unit": "MB"}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "hugePages",
+ "mandatory" : "False",
+ "score" : "7",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "memoryPageSize", "value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""}
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/test/policy-local-files/hpa_policy_vG_1.json b/test/policy-local-files/hpa_policy_vG_1.json
new file mode 100644
index 0000000..98d8cea
--- /dev/null
+++ b/test/policy-local-files/hpa_policy_vG_1.json
@@ -0,0 +1,144 @@
+{
+ "service": "hpaPolicy",
+ "policyName": "oofBeijing.hpaPolicy_vG",
+ "description": "HPA policy for vG",
+ "templateVersion": "0.0.1",
+ "version": "1.0",
+ "priority": "3",
+ "riskType": "test",
+ "riskLevel": "2",
+ "guard": "False",
+ "content": {
+ "resources": "vG",
+ "identity": "hpaPolicy_vG",
+ "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"],
+ "policyType": "hpaPolicy",
+ "flavorFeatures": [
+ {
+ "flavorLabel": "flavor_label_vm_01",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "cpuTopology",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"numCpuSockets", "values": "2","operator": ">=", "unit": ""},
+ {"attribute":"numCpuSockets", "values": "4","operator": "<=", "unit": ""},
+ {"attribute":"numCpuCores", "value": "2", "operator":">=", "unit": ""},
+ {"attribute":"numCpuCores", "value": "4", "operator":"<=", "unit": ""},
+ {"attribute":"numCpuThreads", "value": "4", "operator":">=", "unit": ""},
+ {"attribute":"numCpuThreads", "value": "8", "operator":"<=", "unit": ""}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "ovsDpdk",
+ "mandatory" : "False",
+ "score" : "3",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"dataProcessingAccelerationLibrary", "value":"ovsDpdk_version", "operator": "=", "unit":""}
+ ]
+ },
+ {
+ "hpa_feature" : "cpuInstructionSetExtensions",
+ "mandatory" : "True",
+ "architecture": "INTEL-64",
+ "featureAttributes": [
+ {"attribute":"instructionSetExtensions", "value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""}
+ ]
+ }
+ ]
+ },
+ {
+ "flavorLabel": "flavor_label_vm_02",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "cpuPinningy",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute":"logicalCpuThreadPinningPolicy", "value":"<CPUTHREADPOLICY>", "operator": "=", "unit":""},
+ {"attribute":"logicalCpuPinningPolicy", "value": "<CPUPOLICY>","operator": "=", "unit":""}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "localStorage",
+ "mandatory" : "False",
+ "score" : "5",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "diskSize", "value": "2", "operator": "=", "unit": "GB"},
+ {"attribute": "ephemeralDiskSize", "value": "2", "operator": "=", "unit": "GB"},
+ {"attribute": "swapMemSize", "value":"16", "operator": "=", "unit": "MB"}
+ ]
+ },
+ {
+ "hpa_feature" : "pcie",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "pciCount", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "pciVendorId", "value":"8086", "operator": "=", "unit": ""},
+ {"attribute": "pciDeviceId", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "functionType", "value": "<PCITYPEVALUE>","operator": "=", "unit": ""}
+ ]
+ }
+ ]
+ },
+ {
+ "flavorLabel": "flavor_label_vm_03",
+ "flavorProperties":[
+ {
+ "hpa_feature" : "numa",
+ "mandatory" : "False",
+ "score" : "5",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numaNodes", "value": "2", "operator": "=", "unit": ""},
+ {"attribute": "numaCpu-0", "values":"2", "operator": "=", "unit": ""},
+ {"attribute": "numaMem-0", "value": "2048", "operator": "=", "unit": "MB"},
+ {"attribute": "numaCpu-1", "values":"4", "operator": "=", "unit": ""},
+ {"attribute": "numaMem-1", "value": "4096", "operator": "=", "unit": "MB"}
+ ]
+ },
+ {
+ "hpa_feature" : "basicCapabilities",
+ "mandatory" : "True",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "numVirtualCpu", "value": "6", "operator": "=", "unit": ""},
+ {"attribute": "virtualMemSize", "value":"6", "operator": "=", "unit": "GB"}
+ ]
+ },
+ {
+ "hpa_feature" : "hugePages",
+ "mandatory" : "False",
+ "score" : "7",
+ "architecture": "generic",
+ "featureAttributes": [
+ {"attribute": "memoryPageSize", "value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""}
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/test/policy-local-files/meta-invalid-policies.txt b/test/policy-local-files/meta-invalid-policies.txt
new file mode 100644
index 0000000..9d9ed9b
--- /dev/null
+++ b/test/policy-local-files/meta-invalid-policies.txt
@@ -0,0 +1,4 @@
+INVALID-policies/NO-FILE-EXISTS.json # non-existent policy file
+
+# missing policy name
+INVALID-policies/INVALID-Affinity_vCPE_1.json
diff --git a/test/policy-local-files/meta-valid-policies.txt b/test/policy-local-files/meta-valid-policies.txt
new file mode 100644
index 0000000..a0ce3fe
--- /dev/null
+++ b/test/policy-local-files/meta-valid-policies.txt
@@ -0,0 +1,12 @@
+Affinity_vCPE_1.json
+Capacity_vGMuxInfra.json
+Capacity_vG_1.json
+Distance_vGMuxInfra_1.json
+Distance_vG_1.json
+Min_Guarantee_vGMuxInfra_1.json
+Placement_Optimization_1.json
+QueryPolicy_vCPE.json
+hpa_policy_vGMuxInfra_1.json
+hpa_policy_vG_1.json
+vnfPolicy_vG.json
+vnfPolicy_vGMuxInfra.json
diff --git a/test/policy-local-files/vnfPolicy_vG.json b/test/policy-local-files/vnfPolicy_vG.json
new file mode 100644
index 0000000..ead038c
--- /dev/null
+++ b/test/policy-local-files/vnfPolicy_vG.json
@@ -0,0 +1,31 @@
+{
+ "service": "VnfPolicy",
+ "policyName": "oofBeijing.vnfPolicy_vG",
+ "description": "vnfPolicy",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "6",
+ "riskType": "test",
+ "riskLevel": "3",
+ "guard": "False",
+ "content": {
+ "identity": "vnf_vG",
+ "policyScope": ["vCPE", "INTERNATIONAL", "ip", "vG"],
+ "policyType": "vnf_policy",
+ "resources": ["vG"],
+ "vnfProperties": [
+ {
+ "inventoryProvider": "aai",
+ "serviceType": "",
+ "inventoryType": "cloud",
+ "customerId": ""
+ },
+ {
+ "inventoryProvider": "multicloud",
+ "serviceType": "HNGATEWAY",
+ "inventoryType": "service",
+ "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77"
+ }
+ ]
+ }
+}
diff --git a/test/policy-local-files/vnfPolicy_vGMuxInfra.json b/test/policy-local-files/vnfPolicy_vGMuxInfra.json
new file mode 100644
index 0000000..787563b
--- /dev/null
+++ b/test/policy-local-files/vnfPolicy_vGMuxInfra.json
@@ -0,0 +1,31 @@
+{
+ "service": "VnfPolicy",
+ "policyName": "oofBeijing.vnfPolicy_vGMuxInfra",
+ "description": "vnfPolicy",
+ "templateVersion": "1702.03",
+ "version": "oofBeijing",
+ "priority": "6",
+ "riskType": "test",
+ "riskLevel": "3",
+ "guard": "False",
+ "content": {
+ "identity": "vnf_vGMuxInfra",
+ "policyScope": ["vCPE", "INTERNATIONAL", "ip", "vGMuxInfra"],
+ "policyType": "vnf_policy",
+ "resources": ["vGMuxInfra"],
+ "vnfProperties": [
+ {
+ "inventoryProvider": "aai",
+ "serviceType": "",
+ "inventoryType": "cloud",
+ "customerId": ""
+ },
+ {
+ "inventoryProvider": "multicloud",
+ "serviceType": "HNGATEWAY",
+ "inventoryType": "service",
+ "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77"
+ }
+ ]
+ }
+}
diff --git a/test/policy/test_policy_interface.py b/test/policy/test_policy_interface.py
new file mode 100644
index 0000000..5dc75c3
--- /dev/null
+++ b/test/policy/test_policy_interface.py
@@ -0,0 +1,64 @@
+# -------------------------------------------------------------------------
+# Copyright (c) 2017-2018 AT&T Intellectual Property
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+import mock
+import os
+import unittest
+
+from osdf.adapters.local_data import local_policies
+import osdf.config.loader as config_loader
+from osdf.utils.interfaces import json_from_file
+from osdf.utils.programming_utils import DotDict
+from osdf.optimizers.placementopt.conductor import translation as tr
+from osdf.adapters.policy import interface as pol
+
+
+class TestPolicyInterface(unittest.TestCase):
+
+ def setUp(self):
+ self.config_spec = {
+ "deployment": os.environ.get("OSDF_MANAGER_CONFIG_FILE", "config/osdf_config.yaml"),
+ "core": "config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ 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"
+
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ self.valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ self.request_json = json_from_file(parameter_data_file)
+ self.policies = [json_from_file(policy_data_path + '/' + name) for name in self.valid_policies_files]
+
+ def tearDown(self):
+ pass
+
+ def test_gen_demands(self):
+ res = tr.gen_demands(self.request_json, self.policies)
+ assert res is not None
+
+ def test_get_by_name(self):
+ pol.get_by_name(mock.MagicMock(), self.valid_policies_files[0])
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/test/test_ConductorApiBuilder.py b/test/test_ConductorApiBuilder.py
index f809c56..8395a47 100644
--- a/test/test_ConductorApiBuilder.py
+++ b/test/test_ConductorApiBuilder.py
@@ -18,33 +18,34 @@
import unittest
import json
import yaml
+
+from osdf.adapters.local_data import local_policies
from osdf.optimizers.placementopt.conductor.api_builder import conductor_api_builder
+from osdf.utils.interfaces import json_from_file
class TestConductorApiBuilder(unittest.TestCase):
+ def setUp(self):
+ self.main_dir = ""
+ conductor_api_template = self.main_dir + "osdf/templates/conductor_interface.json"
+ parameter_data_file = self.main_dir + "test/placement-tests/request.json"
+ policy_data_path = self.main_dir + "test/policy-local-files/"
+ local_config_file = self.main_dir + "config/common_config.yaml"
+
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ self.request_json = json_from_file(parameter_data_file)
+ self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
+
+
def test_conductor_api_call_builder(self):
- #main_dir = ".."
- main_dir = ""
+ main_dir = self.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]
+ request_json = self.request_json
+ policies = self.policies
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)
diff --git a/test/test_PolicyCalls.py b/test/test_PolicyCalls.py
index 0378dbd..83cce55 100644
--- a/test/test_PolicyCalls.py
+++ b/test/test_PolicyCalls.py
@@ -18,16 +18,32 @@
import json
import unittest
+from osdf.adapters.local_data import local_policies
from osdf.config.base import osdf_config
from osdf.adapters.policy import interface
-from osdf.utils.interfaces import RestClient
+from osdf.utils.interfaces import RestClient, json_from_file
import yaml
from mock import patch
from osdf.optimizers.placementopt.conductor import translation
class TestPolicyCalls(unittest.TestCase):
-
+
+ def setUp(self):
+ main_dir = ""
+ 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"
+
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ self.request_json = json_from_file(parameter_data_file)
+ self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
+
+ def tearDown(self):
+ pass
+
def test_get_subscriber_name(self):
req_json_obj = json.loads(open("./test/placement-tests/request_mso.json").read())
config_core = osdf_config.core
@@ -36,8 +52,7 @@ class TestPolicyCalls(unittest.TestCase):
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())
@@ -48,7 +63,6 @@ class TestPolicyCalls(unittest.TestCase):
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"
@@ -60,7 +74,6 @@ class TestPolicyCalls(unittest.TestCase):
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"
@@ -73,7 +86,6 @@ class TestPolicyCalls(unittest.TestCase):
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())
@@ -84,49 +96,35 @@ class TestPolicyCalls(unittest.TestCase):
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
+ policy_config_file = 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, policy_config_file, 'placement')
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 = "./test/placement-tests/request.json"
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'])
+ genDemands = translation.gen_demands(req_json, self.policies)
+ for action in req_json['placementInfo']['placementDemands']:
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')
+ self.assertListEqual(genDemandslist, actionsList, 'generated demands are not equal to the passed input'
+ '[placementDemand][resourceModuleName] list')
if __name__ == '__main__':
unittest.main()
diff --git a/test/test_api_validation.py b/test/test_api_validation.py
index 9045530..80e0ba0 100644
--- a/test/test_api_validation.py
+++ b/test/test_api_validation.py
@@ -37,6 +37,11 @@ class TestReqValidation(unittest.TestCase):
class TestResponseValidation(unittest.TestCase):
+ def test_res_validation(self):
+ req_file = "./test/placement-tests/response.json"
+ req_json = json.loads(open(req_file).read())
+ self.assertEqual(PlacementResponse(req_json).validate(), None)
+
def test_invalid_response(self):
resp_json = {}
self.assertRaises(ModelValidationError, lambda: PlacementResponse(resp_json).validate())
diff --git a/test/test_process_placement_opt.py b/test/test_process_placement_opt.py
index 3cf9701..01be17d 100644
--- a/test/test_process_placement_opt.py
+++ b/test/test_process_placement_opt.py
@@ -15,39 +15,51 @@
#
# -------------------------------------------------------------------------
#
+import mock
import unittest
-import json
-import yaml
-from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt
+
+from flask import Response
from mock import patch
+from osdf.adapters.local_data import local_policies
+from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt
+from osdf.utils.interfaces import json_from_file, yaml_from_file
+
-class TestConductorApiBuilder(unittest.TestCase):
+class TestProcessPlacementOpt(unittest.TestCase):
- def test_conductor_api_call_builder(self):
- #main_dir = ".."
+ def setUp(self):
+ mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8')
+ self.patcher_req = patch('osdf.optimizers.placementopt.conductor.conductor.request',
+ return_value={"solutionInfo": {"placementInfo": "dummy"}})
+ self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept',
+ return_value=mock_req_accept_message)
+ self.patcher_callback = patch(
+ 'osdf.optimizers.placementopt.conductor.remote_opt_processor.process_placement_opt',
+ return_value=mock_req_accept_message)
+ self.patcher_RestClient = patch(
+ 'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock())
+ self.Mock_req = self.patcher_req.start()
+ self.Mock_req_accept = self.patcher_req_accept.start()
+ self.Mock_callback = self.patcher_callback.start()
+ self.Mock_RestClient = self.patcher_RestClient.start()
+
+ def tearDown(self):
+ patch.stopall()
+
+ def test_process_placement_opt(self):
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))
- with patch('osdf.optimizers.placementopt.conductor.conductor.request', return_value={"solutionInfo": {"placementInfo": "dummy"}}):
- templ_string = process_placement_opt(request_json, policies, local_config, [])
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ request_json = json_from_file(parameter_data_file)
+ policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
+ local_config = yaml_from_file(local_config_file)
+ templ_string = process_placement_opt(request_json, policies, local_config, [])
if __name__ == "__main__":