From edf98746a52408386efab26143778198b0efd3c5 Mon Sep 17 00:00:00 2001 From: dhebeha Date: Sat, 5 Sep 2020 20:16:48 +0530 Subject: Add support to process NSI selection request Issue-ID: OPTFRA-802 Signed-off-by: dhebeha Signed-off-by: krishnaa96 Change-Id: I85d951061abc697714425bd223b89102d4f2ede9 --- test/conductor/test_conductor_calls.py | 10 ++++++++-- test/conductor/test_conductor_translation.py | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'test/conductor') diff --git a/test/conductor/test_conductor_calls.py b/test/conductor/test_conductor_calls.py index d342fa5..8b4411d 100644 --- a/test/conductor/test_conductor_calls.py +++ b/test/conductor/test_conductor_calls.py @@ -35,6 +35,10 @@ class TestConductorCalls(unittest.TestCase): self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) self.lp = self.osdf_config.core.get('osdf_temp', {}).get('local_policies', {} ).get('placement_policy_files_vcpe') + self.template_fields = { + 'location_enabled': True, + 'version': '2017-10-10' + } def tearDown(self): pass @@ -46,7 +50,8 @@ class TestConductorCalls(unittest.TestCase): demands = req_json['placementInfo']['placementDemands'] request_parameters = req_json['placementInfo']['requestParameters'] service_info = req_json['serviceInfo'] - conductor.request(req_info, demands, request_parameters, service_info, True, self.osdf_config, policies) + conductor.request(req_info, demands, request_parameters, service_info, self.template_fields, + self.osdf_config, policies) def test_request_vfmod(self): req_json = json_from_file("./test/placement-tests/request_vfmod.json") @@ -55,7 +60,8 @@ class TestConductorCalls(unittest.TestCase): demands = req_json['placementInfo']['placementDemands'] request_parameters = req_json['placementInfo']['requestParameters'] service_info = req_json['serviceInfo'] - conductor.request(req_info, demands, request_parameters, service_info, True, self.osdf_config, policies) + conductor.request(req_info, demands, request_parameters, service_info, self.template_fields, + self.osdf_config, policies) if __name__ == "__main__": diff --git a/test/conductor/test_conductor_translation.py b/test/conductor/test_conductor_translation.py index 8b6c0a1..2a600e4 100644 --- a/test/conductor/test_conductor_translation.py +++ b/test/conductor/test_conductor_translation.py @@ -40,6 +40,9 @@ class TestConductorTranslation(unittest.TestCase): self.request_vfmod_json = json_from_file(parameter_data_file) self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + self.optimization_policies = [json_from_file(policy_data_path + '/' + + "slice-selection-files/opt_policy_nsi_reuse.json")] + def tearDown(self): pass @@ -58,6 +61,26 @@ class TestConductorTranslation(unittest.TestCase): res = tr.gen_demands(self.request_vfmod_json['placementInfo']['placementDemands'], vnf_policies) assert res is not None + def test_gen_optimization_policy(self): + expected = [{ + "goal": "minimize", + "operation_function": { + "operator": "sum", + "operands": [ + { + "function": "attribute", + "params": { + "attribute": "creation_cost", + "demand": "embb-nst" + } + } + ] + } + }] + self.assertEqual(expected, + tr.gen_optimization_policy(self.request_vfmod_json['placementInfo']['placementDemands'], + self.optimization_policies)) + if __name__ == "__main__": unittest.main() -- cgit 1.2.3-korg