aboutsummaryrefslogtreecommitdiffstats
path: root/test/apps/slice_selection
diff options
context:
space:
mode:
Diffstat (limited to 'test/apps/slice_selection')
-rw-r--r--test/apps/slice_selection/conductor_error_response.json18
-rw-r--r--test/apps/slice_selection/new_solution_conductor_response.json87
-rw-r--r--test/apps/slice_selection/new_solution_nsi_response.json53
-rw-r--r--test/apps/slice_selection/nsi_error_response.json6
-rw-r--r--test/apps/slice_selection/nsi_request.json30
-rw-r--r--test/apps/slice_selection/shared_solution_conductor_response.json87
-rw-r--r--test/apps/slice_selection/shared_solution_nsi_response.json16
-rw-r--r--test/apps/slice_selection/slice_policies.txt4
-rw-r--r--test/apps/slice_selection/test_remote_opt_processor.py102
9 files changed, 403 insertions, 0 deletions
diff --git a/test/apps/slice_selection/conductor_error_response.json b/test/apps/slice_selection/conductor_error_response.json
new file mode 100644
index 0000000..95a9750
--- /dev/null
+++ b/test/apps/slice_selection/conductor_error_response.json
@@ -0,0 +1,18 @@
+{
+ "plans": [
+ {
+ "status": "error",
+ "message": "Some error message",
+ "name": "Plan Name 1",
+ "links": [
+ [
+ {
+ "href": "http://conductor:8091/v1/plans/plan_id",
+ "rel": "self"
+ }
+ ]
+ ],
+ "id": "plan_id"
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/new_solution_conductor_response.json b/test/apps/slice_selection/new_solution_conductor_response.json
new file mode 100644
index 0000000..39fef7b
--- /dev/null
+++ b/test/apps/slice_selection/new_solution_conductor_response.json
@@ -0,0 +1,87 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations":[
+ {
+ "URLLC_Core_1":{
+ "inventory_provider":"aai",
+ "candidate":{
+ "exp_data_rate":0,
+ "conn_density":0,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor":0,
+ "cs_availability":null,
+ "candidate_id":"1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "area_traffic_cap_dl":null,
+ "latency":20,
+ "service_area_dimension":null,
+ "domain":"cn",
+ "e2e_latency":0,
+ "area_traffic_cap_ul":null,
+ "inventory_provider":"aai",
+ "exp_data_rate_ul":100,
+ "max_number_of_ues":0,
+ "ue_mobility_level":"stationary",
+ "candidate_type":"nssi",
+ "traffic_density":0,
+ "payload_size":0,
+ "exp_data_rate_dl":100,
+ "jitter":0,
+ "survival_time":0,
+ "resource_sharing_level":"0",
+ "inventory_type":"nssi",
+ "reliability":null,
+ "cost":1.0,
+ "nsi_name":"nsi_test_0211",
+ "instance_name":"nssi_test_0211"
+ }
+ },
+ "URLLC_Ran_1":{
+ "inventory_provider":"aai",
+ "candidate":{
+ "exp_data_rate":0,
+ "conn_density":0,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor":0,
+ "cs_availability":null,
+ "candidate_id":"490c68b0-639c-11ea-bc55-0242ac130003",
+ "area_traffic_cap_dl":null,
+ "latency":15,
+ "service_area_dimension":null,
+ "domain":"cn",
+ "e2e_latency":0,
+ "area_traffic_cap_ul":null,
+ "inventory_provider":"aai",
+ "exp_data_rate_ul":100,
+ "max_number_of_ues":0,
+ "ue_mobility_level":"stationary",
+ "candidate_type":"nssi",
+ "traffic_density":0,
+ "payload_size":0,
+ "exp_data_rate_dl":100,
+ "jitter":0,
+ "survival_time":0,
+ "resource_sharing_level":"0",
+ "inventory_type":"nssi",
+ "reliability":null,
+ "cost":1.0,
+ "nsi_name":"nsi_test_0212",
+ "instance_name":"nssi_test_ran_0211"
+ }
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/new_solution_nsi_response.json b/test/apps/slice_selection/new_solution_nsi_response.json
new file mode 100644
index 0000000..de248c6
--- /dev/null
+++ b/test/apps/slice_selection/new_solution_nsi_response.json
@@ -0,0 +1,53 @@
+{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions":{
+ "sharedNSISolutions":[
+
+ ],
+ "newNSISolutions":[
+ {
+ "matchLevel":"",
+ "NSTInfo":null,
+ "NSSISolutions":[
+ {
+ "sliceProfile":{
+ "latency":20,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue_mobility_level":"stationary",
+ "resource_sharing_level":"0",
+ "exp_data_rate_ul":100,
+ "exp_data_rate_dl":100
+ },
+ "NSSTInfo":{
+ "NSSTName":"URLLC_Core_1"
+ },
+ "NSSISolution":{
+ "NSSIName":"nssi_test_0211",
+ "NSSIId":"1a636c4d-5e76-427e-bfd6-241a947224b0"
+ }
+ },
+ {
+ "sliceProfile":{
+ "latency":15,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue_mobility_level":"stationary",
+ "resource_sharing_level":"0",
+ "exp_data_rate_ul":100,
+ "exp_data_rate_dl":100
+ },
+ "NSSTInfo":{
+ "NSSTName":"URLLC_Ran_1"
+ },
+ "NSSISolution":{
+ "NSSIName":"nssi_test_ran_0211",
+ "NSSIId":"490c68b0-639c-11ea-bc55-0242ac130003"
+ }
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/nsi_error_response.json b/test/apps/slice_selection/nsi_error_response.json
new file mode 100644
index 0000000..c09bda8
--- /dev/null
+++ b/test/apps/slice_selection/nsi_error_response.json
@@ -0,0 +1,6 @@
+{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"error",
+ "statusMessage":"Some error message"
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/nsi_request.json b/test/apps/slice_selection/nsi_request.json
new file mode 100644
index 0000000..69d6e80
--- /dev/null
+++ b/test/apps/slice_selection/nsi_request.json
@@ -0,0 +1,30 @@
+{
+ "serviceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0
+ },
+ "serviceInfo":{
+ "serviceInstanceId": "209fb01e-60ca-4325-b074-c5ad4e0499f8",
+ "serviceName": ""
+ },
+ "requestInfo": {
+ "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "sourceId": "SO",
+ "timeout": 5
+ },
+ "NSTInfoList": [
+ {
+ "modelInvariantId": "fda3c1e8-7653-4acd-80ef-f5755c1d3859",
+ "modelVersionId": "a6906768-1cae-4e78-acd1-d753ac61f3e8",
+ "modelName": "URLLC_1"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/shared_solution_conductor_response.json b/test/apps/slice_selection/shared_solution_conductor_response.json
new file mode 100644
index 0000000..5bccd44
--- /dev/null
+++ b/test/apps/slice_selection/shared_solution_conductor_response.json
@@ -0,0 +1,87 @@
+{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations":[
+ {
+ "URLLC_Core_1":{
+ "inventory_provider":"aai",
+ "candidate":{
+ "exp_data_rate":0,
+ "conn_density":0,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor":0,
+ "cs_availability":null,
+ "candidate_id":"1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "area_traffic_cap_dl":null,
+ "latency":20,
+ "service_area_dimension":null,
+ "domain":"cn",
+ "e2e_latency":0,
+ "area_traffic_cap_ul":null,
+ "inventory_provider":"aai",
+ "exp_data_rate_ul":100,
+ "max_number_of_ues":0,
+ "ue_mobility_level":"stationary",
+ "candidate_type":"nssi",
+ "traffic_density":0,
+ "payload_size":0,
+ "exp_data_rate_dl":100,
+ "jitter":0,
+ "survival_time":0,
+ "resource_sharing_level":"0",
+ "inventory_type":"nssi",
+ "reliability":null,
+ "cost":1.0,
+ "nsi_name":"nsi_test_0212",
+ "instance_name":"nssi_test_0211"
+ }
+ },
+ "URLLC_Ran_1":{
+ "inventory_provider":"aai",
+ "candidate":{
+ "exp_data_rate":0,
+ "conn_density":0,
+ "coverage_area_ta_list":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "activity_factor":0,
+ "cs_availability":null,
+ "candidate_id":"490c68b0-639c-11ea-bc55-0242ac130003",
+ "area_traffic_cap_dl":null,
+ "latency":15,
+ "service_area_dimension":null,
+ "domain":"cn",
+ "e2e_latency":0,
+ "area_traffic_cap_ul":null,
+ "inventory_provider":"aai",
+ "exp_data_rate_ul":100,
+ "max_number_of_ues":0,
+ "ue_mobility_level":"stationary",
+ "candidate_type":"nssi",
+ "traffic_density":0,
+ "payload_size":0,
+ "exp_data_rate_dl":100,
+ "jitter":0,
+ "survival_time":0,
+ "resource_sharing_level":"0",
+ "inventory_type":"nssi",
+ "reliability":null,
+ "cost":1.0,
+ "nsi_name":"nsi_test_0212",
+ "instance_name":"nssi_test_ran_0211"
+ }
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/shared_solution_nsi_response.json b/test/apps/slice_selection/shared_solution_nsi_response.json
new file mode 100644
index 0000000..b0c0e2a
--- /dev/null
+++ b/test/apps/slice_selection/shared_solution_nsi_response.json
@@ -0,0 +1,16 @@
+{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions":{
+ "sharedNSISolutions":[
+ {
+ "NSIName":"nsi_test_0212"
+ }
+ ],
+ "newNSISolutions":[
+
+ ]
+ }
+} \ No newline at end of file
diff --git a/test/apps/slice_selection/slice_policies.txt b/test/apps/slice_selection/slice_policies.txt
new file mode 100644
index 0000000..e4ccb65
--- /dev/null
+++ b/test/apps/slice_selection/slice_policies.txt
@@ -0,0 +1,4 @@
+subscriber_policy_URLLC_1.json
+thresholdPolicy_URLLC_Core_1_latency.json
+thresholdPolicy_URLLC_Core_1_reliability.json
+vnfPolicy_URLLC_Core_1.json \ No newline at end of file
diff --git a/test/apps/slice_selection/test_remote_opt_processor.py b/test/apps/slice_selection/test_remote_opt_processor.py
new file mode 100644
index 0000000..d9b4f24
--- /dev/null
+++ b/test/apps/slice_selection/test_remote_opt_processor.py
@@ -0,0 +1,102 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# 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 requests import RequestException
+
+from apps.slice_selection.optimizers.conductor.remote_opt_processor import process_nsi_selection_opt
+from osdf.adapters.local_data import local_policies
+from osdf.utils.interfaces import json_from_file, yaml_from_file
+from osdf.utils.programming_utils import DotDict
+import osdf.config.loader as config_loader
+from mock import patch, MagicMock
+import json
+from osdf.logging.osdf_logging import error_log, debug_log
+from osdf.adapters.policy.interface import get_policies
+
+
+class TestRemoteOptProcessor(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ def tearDown(self):
+ patch.stopall()
+
+ def test_process_nsi_selection_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/slice_selection/nsi_request.json'
+ new_solution_response_file = main_dir + 'test/apps/slice_selection/new_solution_nsi_response.json'
+ shared_solution_response_file = main_dir + 'test/apps/slice_selection/shared_solution_nsi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nsi_error_response.json'
+
+ request_json = json_from_file(request_file)
+ new_solution_response_json = json_from_file(new_solution_response_file)
+ shared_solution_response_json = json_from_file(shared_solution_response_file)
+ error_response_json = json_from_file(error_response_file)
+
+ policies_path = main_dir + 'test/policy-local-files'
+ slice_policies_file = main_dir + 'test/apps/slice_selection/slice_policies.txt'
+
+ valid_policies_files = local_policies.get_policy_names_from_file(slice_policies_file)
+ policies = [json_from_file(policies_path + '/' + name) for name in valid_policies_files]
+ self.patcher_get_policies = patch('osdf.adapters.policy.interface.remote_api',
+ return_value=policies)
+ self.Mock_get_policies = self.patcher_get_policies.start()
+
+ new_solution_conductor_response_file = 'test/apps/slice_selection/new_solution_conductor_response.json'
+ new_solution_conductor_response = json_from_file(new_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=new_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(new_solution_response_json, process_nsi_selection_opt(request_json, self.osdf_config))
+ self.patcher_req.stop()
+
+ shared_solution_conductor_response_file = 'test/apps/slice_selection/shared_solution_conductor_response.json'
+ shared_solution_conductor_response = json_from_file(shared_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=shared_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(shared_solution_response_json,
+ process_nsi_selection_opt(request_json, self.osdf_config))
+ self.patcher_req.stop()
+
+ conductor_error_response_file = 'test/apps/slice_selection/conductor_error_response.json'
+ conductor_error_response = json_from_file(conductor_error_response_file)
+
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=RequestException(response=json.dumps(conductor_error_response)))
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(error_response_json, process_nsi_selection_opt(request_json, self.osdf_config))
+ self.patcher_req.stop()
+
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=Exception("test_exception"))
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals('test_exception',
+ process_nsi_selection_opt(request_json, self.osdf_config).get('statusMessage'))
+ self.patcher_req.stop()
+
+
+if __name__ == "__main__":
+ unittest.main()
+