diff options
author | dhebeha <dhebeha.mj71@wipro.com> | 2020-05-13 01:33:52 +0530 |
---|---|---|
committer | dhebeha <dhebeha.mj71@wipro.com> | 2020-05-13 10:39:41 +0530 |
commit | 0227fc0b5a69558cb68fd9977e12558fbb51a203 (patch) | |
tree | d906c0db686b0c5dc8b6d93cb746de3d271534ae /test/apps/slice_selection | |
parent | 76efb65c4fffbd5b940a75c36329a2e0409be382 (diff) |
return slice profile when serviceProfile is non shareable
Issue-ID: OPTFRA-754
Signed-off-by: dhebeha <dhebeha.mj71@wipro.com>
Change-Id: Ib330881be60d8bcc5683571a76ef8fe52452b869
Diffstat (limited to 'test/apps/slice_selection')
9 files changed, 290 insertions, 126 deletions
diff --git a/test/apps/slice_selection/new_solution_nsi_response.json b/test/apps/slice_selection/new_solution_nsi_response.json index de248c6..02023ce 100644 --- a/test/apps/slice_selection/new_solution_nsi_response.json +++ b/test/apps/slice_selection/new_solution_nsi_response.json @@ -10,16 +10,19 @@ "newNSISolutions":[ { "matchLevel":"", - "NSTInfo":null, + "NSTInfo":{"invariantUUID": "fda3c1e8-7653-4acd-80ef-f5755c1d3859", + "UUID": "a6906768-1cae-4e78-acd1-d753ac61f3e8", + "NSTName": "URLLC_1" + }, "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 + "coverageAreaTAList":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "uEMobilityLevel":"stationary", + "resourceSharingLevel":"0", + "expDataRateUL":100, + "expDataRateDL":100 }, "NSSTInfo":{ "NSSTName":"URLLC_Core_1" @@ -32,11 +35,11 @@ { "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 + "coverageAreaTAList":"[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "uEMobilityLevel":"stationary", + "resourceSharingLevel":"0", + "expDataRateUL":100, + "expDataRateDL":100 }, "NSSTInfo":{ "NSSTName":"URLLC_Ran_1" @@ -50,4 +53,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/test/apps/slice_selection/no_rec.json b/test/apps/slice_selection/no_rec.json new file mode 100644 index 0000000..855afac --- /dev/null +++ b/test/apps/slice_selection/no_rec.json @@ -0,0 +1,18 @@ +{ + "plans": [ + { + "id": "d8c07237-5f66-4aa6-871c-a04221d99458", + "links": [ + [ + { + "href": "https://oof-has-api:8091/v1/plans/d8c07237-5f66-4aa6-871c-a04221d99458", + "rel": "self" + } + ] + ], + "message": "Plan d8c07237-5f66-4aa6-871c-a04221d99458 search failed, no recommendations found by machine dev-oof-has-solver-65d478b6d-ql5fp", + "name": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "status": "not found" + } + ] +} diff --git a/test/apps/slice_selection/no_recomm_conductor_response.json b/test/apps/slice_selection/no_recomm_conductor_response.json new file mode 100644 index 0000000..f23af87 --- /dev/null +++ b/test/apps/slice_selection/no_recomm_conductor_response.json @@ -0,0 +1,18 @@ +{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations": []
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/no_recomm_nsi_response.json b/test/apps/slice_selection/no_recomm_nsi_response.json new file mode 100644 index 0000000..daf151d --- /dev/null +++ b/test/apps/slice_selection/no_recomm_nsi_response.json @@ -0,0 +1,37 @@ +{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions":{
+ "sharedNSISolutions":[
+
+ ],
+ "newNSISolutions":[
+ {
+ "matchLevel":"",
+ "NSTInfo":{"invariantUUID": "fda3c1e8-7653-4acd-80ef-f5755c1d3859",
+ "UUID": "a6906768-1cae-4e78-acd1-d753ac61f3e8",
+ "NSTName": "URLLC_1"
+ },
+
+ "NSSISolutions":[
+ {
+ "sliceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0,
+ "domainType":"cn",
+ "resourceSharingLevel":"shared"
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/test/apps/slice_selection/not_shared_nsi_request.json b/test/apps/slice_selection/not_shared_nsi_request.json new file mode 100644 index 0000000..1e22f41 --- /dev/null +++ b/test/apps/slice_selection/not_shared_nsi_request.json @@ -0,0 +1,31 @@ +{
+ "serviceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0,
+ "resourceSharingLevel": "non-shared"
+ },
+ "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"
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/not_shared_nsi_response.json b/test/apps/slice_selection/not_shared_nsi_response.json new file mode 100644 index 0000000..873ad2e --- /dev/null +++ b/test/apps/slice_selection/not_shared_nsi_response.json @@ -0,0 +1,37 @@ +{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions":{
+ "sharedNSISolutions":[
+
+ ],
+ "newNSISolutions":[
+ {
+ "matchLevel":"",
+ "NSTInfo":{"invariantUUID": "fda3c1e8-7653-4acd-80ef-f5755c1d3859",
+ "UUID": "a6906768-1cae-4e78-acd1-d753ac61f3e8",
+ "NSTName": "URLLC_1"
+ },
+
+ "NSSISolutions":[
+ {
+ "sliceProfile": {
+ "latency": 2,
+ "security": "High",
+ "reliability": 99.9999,
+ "trafficDensity": 1,
+ "connDensity": 100000,
+ "expDataRate": 50,
+ "jitter": 1,
+ "survivalTime": 0,
+ "domainType": "cn",
+ "resourceSharingLevel": "non-shared"
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/test/apps/slice_selection/nsi_request.json b/test/apps/slice_selection/nsi_request.json index 69d6e80..72b2c8b 100644 --- a/test/apps/slice_selection/nsi_request.json +++ b/test/apps/slice_selection/nsi_request.json @@ -7,7 +7,8 @@ "connDensity": 100000, "expDataRate": 50, "jitter": 1, - "survivalTime": 0 + "survivalTime": 0, + "resourceSharingLevel":"shared" }, "serviceInfo":{ "serviceInstanceId": "209fb01e-60ca-4325-b074-c5ad4e0499f8", @@ -27,4 +28,4 @@ "modelName": "URLLC_1" } ] -}
\ 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 index 2c74196..46257dd 100644 --- a/test/apps/slice_selection/shared_solution_nsi_response.json +++ b/test/apps/slice_selection/shared_solution_nsi_response.json @@ -15,12 +15,12 @@ "invariantUUID": "", "sliceProfile": [ { - "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", - "exp_data_rate_dl": 100, - "exp_data_rate_ul": 100, + "coverageAreaTAList": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "expDataRateDL": 100, + "expDataRateUL": 100, "latency": 20, - "resource_sharing_level": "0", - "ue_mobility_level": "stationary" + "resourceSharingLevel": "0", + "uEMobilityLevel": "stationary" } ] }, @@ -31,12 +31,12 @@ "invariantUUID": "", "sliceProfile": [ { - "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", - "exp_data_rate_dl": 100, - "exp_data_rate_ul": 100, + "coverageAreaTAList": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "expDataRateDL": 100, + "expDataRateUL": 100, "latency": 15, - "resource_sharing_level": "0", - "ue_mobility_level": "stationary" + "resourceSharingLevel": "0", + "uEMobilityLevel": "stationary" } ] } diff --git a/test/apps/slice_selection/test_remote_opt_processor.py b/test/apps/slice_selection/test_remote_opt_processor.py index d9b4f24..136bb71 100644 --- a/test/apps/slice_selection/test_remote_opt_processor.py +++ b/test/apps/slice_selection/test_remote_opt_processor.py @@ -1,102 +1,121 @@ -# ------------------------------------------------------------------------- -# 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() - +# -------------------------------------------------------------------------
+# 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'
+ not_shared_request_file = main_dir + 'test/apps/slice_selection/not_shared_nsi_request.json'
+ #response files
+ 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'
+ no_solution_response_file = main_dir + 'test/apps/slice_selection/no_recomm_nsi_response.json'
+ not_shared_response_file = main_dir + 'test/apps/slice_selection/not_shared_nsi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nsi_error_response.json'
+
+ not_shared_request_json = json_from_file(not_shared_request_file)
+ not_shared_response_json = json_from_file(not_shared_response_file)
+ 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)
+ no_solution_response_json = json_from_file(no_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
+ 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
+ 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()
+ # not-shared solution
+ self.assertEquals(not_shared_response_json,
+ process_nsi_selection_opt(not_shared_request_json, self.osdf_config))
+ # no recommendation
+ no_solution_conductor_response_file = 'test/apps/slice_selection/no_rec.json'
+ no_solution_conductor_response = json_from_file(no_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=no_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ self.assertEquals(no_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()
+
|