From ad29f38cbcb164a7f328b26daf789dbff90deb98 Mon Sep 17 00:00:00 2001 From: Ankitkumar Patel Date: Wed, 28 Mar 2018 14:27:53 -0400 Subject: Update the SO sync and async responses. Updated the sync and async responses and addes testcases related to policy adaptors. Issue-ID: OPTFRA-208 Change-Id: Ia0f88df1b897b6158674f3c3a7ef239f2328dcfc Signed-off-by: Ankitkumar Patel --- test/config/common_config.yaml | 3 +- test/policy-local-files/QueryPolicy_vCPE_2.json | 23 +++++++++++++++ test/policy-local-files/meta-valid-policies.txt | 1 + test/test_ConductorApiBuilder.py | 1 - test/test_getPolicy.py | 37 +++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 test/policy-local-files/QueryPolicy_vCPE_2.json create mode 100644 test/test_getPolicy.py (limited to 'test') diff --git a/test/config/common_config.yaml b/test/config/common_config.yaml index 2461fd8..a3ef82e 100644 --- a/test/config/common_config.yaml +++ b/test/config/common_config.yaml @@ -11,15 +11,16 @@ osdf_temp: # special configuration required for "workarounds" or testing local_policies: global_disabled: False local_placement_policies_enabled: True + placement_policy_dir_vcpe: "../test/policy-local-files/" 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 + - QueryPolicy_vCPE_2.json - hpa_policy_vGMuxInfra_1.json - hpa_policy_vG_1.json - vnfPolicy_vG.json diff --git a/test/policy-local-files/QueryPolicy_vCPE_2.json b/test/policy-local-files/QueryPolicy_vCPE_2.json new file mode 100644 index 0000000..7f1db83 --- /dev/null +++ b/test/policy-local-files/QueryPolicy_vCPE_2.json @@ -0,0 +1,23 @@ +{ + "service": "optimizationQueryPolicy", + "policyName": "oofBeijing.queryPolicy_vCPE", + "description": "Optimization query policy for vCPE", + "templateVersion": "0.0.1", + "version": "oofBeijing", + "priority": "5", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "queryProperties": [ + {"attribute":"locationId", "attribute_location": "customerLocation", "value": ""}, + {"attribute":"id", "attribute_location": "vpnInfo.vpnId", "value": ""}, + {"attribute":"upstreamBW", "attribute_location": "vpnInfo.upstreamBW", "value": ""}, + {"attribute":"customerLatitude", "attribute_location": "customerLatitude", "value": 1.1}, + {"attribute":"customerLongitude", "attribute_location": "customerLongitude", "value": 2.2} + ], + "serviceName": "vCPE", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG", "optimizationQueryPolicy"], + "policyType": "optimizationQueryPolicy" + } +} diff --git a/test/policy-local-files/meta-valid-policies.txt b/test/policy-local-files/meta-valid-policies.txt index 7fc72ea..772ec1a 100644 --- a/test/policy-local-files/meta-valid-policies.txt +++ b/test/policy-local-files/meta-valid-policies.txt @@ -5,6 +5,7 @@ Distance_vGMuxInfra_1.json Distance_vG_1.json Placement_Optimization_1.json QueryPolicy_vCPE.json +QueryPolicy_vCPE_2.json hpa_policy_vGMuxInfra_1.json hpa_policy_vG_1.json vnfPolicy_vG.json diff --git a/test/test_ConductorApiBuilder.py b/test/test_ConductorApiBuilder.py index d13a6a5..f8683a3 100644 --- a/test/test_ConductorApiBuilder.py +++ b/test/test_ConductorApiBuilder.py @@ -39,7 +39,6 @@ class TestConductorApiBuilder(unittest.TestCase): 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 = self.main_dir conductor_api_template = main_dir + "osdf/templates/conductor_interface.json" # "osdf/templates/conductor_interface.json" diff --git a/test/test_getPolicy.py b/test/test_getPolicy.py new file mode 100644 index 0000000..07ffd8a --- /dev/null +++ b/test/test_getPolicy.py @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------- +# 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 json +import unittest + +from osdf.adapters.policy.interface import get_policies +from osdf.utils.interfaces import json_from_file +from mock import patch + + +class TestGetPolicy(unittest.TestCase): + + def setUp(self): + main_dir = "" + parameter_data_file = main_dir + "test/placement-tests/request.json" # "test/placement-tests/request.json" + self.request_json = json_from_file(parameter_data_file) + + def test_get_policy_function(self): + with patch('osdf.adapters.policy.interface.remote_api', return_value=[{"x: y"}]): + policy_list = get_policies(self.request_json, "placement") + policy_exist = True if len(policy_list) > 0 else False + self.assertEqual(policy_exist, True) -- cgit 1.2.3-korg