aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorvrvarma <vv8305@att.com>2019-04-12 00:46:37 -0400
committervrvarma <vv8305@att.com>2019-04-12 00:48:49 -0400
commite1f6d80752920a7ef990134f02abb3db9b5a6232 (patch)
tree5232b24e83948e1a0c6093e7cf182bd140750050 /test
parent75f7a15a5a14af434e0e8430fcec880106d64dbf (diff)
Updating code for pci-anr optimization calls
Include pci-anr minizinc model Refactor the code to handle pci & pci-anr optimizations Fix pytest unit test cases Change-Id: I59eba39850a90e5aaf45f0e2de1881ebb5a9d5d8 Signed-off-by: vrvarma <vv8305@att.com> Issue-ID: OPTFRA-416 Signed-off-by: vrvarma <vv8305@att.com>
Diffstat (limited to 'test')
-rw-r--r--test/functest/simulators/configdb/response-payloads/getCellList-2000.json1
-rw-r--r--test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json14
-rw-r--r--test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json6
-rw-r--r--test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json6
-rw-r--r--test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json6
-rw-r--r--test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json6
-rw-r--r--test/pci-optimization-tests/pci_anr_request.json29
-rw-r--r--test/pci-optimization-tests/request.json2
-rw-r--r--test/test_process_pci_anr_opt.py79
9 files changed, 148 insertions, 1 deletions
diff --git a/test/functest/simulators/configdb/response-payloads/getCellList-2000.json b/test/functest/simulators/configdb/response-payloads/getCellList-2000.json
new file mode 100644
index 0000000..77cf7db
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getCellList-2000.json
@@ -0,0 +1 @@
+["cell20","cell21","cell22","cell23","cell24"] \ No newline at end of file
diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json
new file mode 100644
index 0000000..86c7d2c
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json
@@ -0,0 +1,14 @@
+[
+ {
+ "cellId": "cell21",
+ "pciValue": 0
+ },
+ {
+ "cellId": "cell22",
+ "pciValue": 1
+ },
+ {
+ "cellId": "cell23",
+ "pciValue": 2
+ }
+] \ No newline at end of file
diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json
new file mode 100644
index 0000000..490c15f
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json
@@ -0,0 +1,6 @@
+[
+ {
+ "cellId": "cell20",
+ "pciValue":0
+ }
+] \ No newline at end of file
diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json
new file mode 100644
index 0000000..426e13b
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json
@@ -0,0 +1,6 @@
+[
+ {
+ "cellId": "cell20",
+ "pciValue": 0
+ }
+] \ No newline at end of file
diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json
new file mode 100644
index 0000000..de582eb
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json
@@ -0,0 +1,6 @@
+[
+ {
+ "cellId": "cell24",
+ "pciValue": 0
+ }
+] \ No newline at end of file
diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json
new file mode 100644
index 0000000..8d8d3fb
--- /dev/null
+++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json
@@ -0,0 +1,6 @@
+[
+ {
+ "cellId": "cell23",
+ "pciValue": 2
+ }
+] \ No newline at end of file
diff --git a/test/pci-optimization-tests/pci_anr_request.json b/test/pci-optimization-tests/pci_anr_request.json
new file mode 100644
index 0000000..e8947b1
--- /dev/null
+++ b/test/pci-optimization-tests/pci_anr_request.json
@@ -0,0 +1,29 @@
+{
+ "requestInfo": {
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/",
+ "sourceId": "SO",
+ "requestType": "create",
+ "numSolutions": 1,
+ "optimizers": [
+ "pci-anr"
+ ],
+ "timeout": 600
+ },
+ "cellInfo": {
+ "networkId": "2000",
+ "cellIdList": [
+ "cell20"
+ ]
+ },
+ "anrInputList": [
+ {
+ "cellId": "cell20",
+ "removeableNeighbors": [
+ "cell23"
+ ]
+ }
+ ],
+ "trigger": "NbrListChange"
+} \ No newline at end of file
diff --git a/test/pci-optimization-tests/request.json b/test/pci-optimization-tests/request.json
index 7ec9ab5..517ee10 100644
--- a/test/pci-optimization-tests/request.json
+++ b/test/pci-optimization-tests/request.json
@@ -7,7 +7,7 @@
"requestType": "create",
"numSolutions": 1,
"optimizers": [
- "placement"
+ "pci"
],
"timeout": 600
},
diff --git a/test/test_process_pci_anr_opt.py b/test/test_process_pci_anr_opt.py
new file mode 100644
index 0000000..8c6a34c
--- /dev/null
+++ b/test/test_process_pci_anr_opt.py
@@ -0,0 +1,79 @@
+# -------------------------------------------------------------------------
+# Copyright (c) 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.pciopt.pci_opt_processor import process_pci_optimation
+import osdf.config.loader as config_loader
+from osdf.utils.interfaces import json_from_file
+from osdf.utils.programming_utils import DotDict
+
+
+class TestProcessPlacementOpt(unittest.TestCase):
+
+ def setUp(self):
+ mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8')
+ self.patcher_req = patch('osdf.optimizers.pciopt.configdb.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.pciopt.pci_opt_processor.process_pci_optimation',
+ return_value=mock_req_accept_message)
+
+ mock_mzn_response = [{'pci': {0: 0, 1: 1, 2: 2, 3: 3, 4: 0}, 'used_ignorables': [0]}]
+
+ self.patcher_minizinc_callback = patch(
+ 'osdf.optimizers.pciopt.solver.optimizer.solve',
+ return_value=mock_mzn_response )
+ 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()
+ self.Mock_mzn_callback = self.patcher_minizinc_callback.start()
+
+ def tearDown(self):
+ patch.stopall()
+
+ def test_process_pci_anr_opt_solutions(self):
+ main_dir = ""
+ parameter_data_file = main_dir + "test/pci-optimization-tests/pci_anr_request.json"
+ policy_data_path = main_dir + "test/policy-local-files/"
+ self.config_spec = {
+ "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml",
+ "core": "test/functest/simulators/simulated-config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+
+ 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]
+
+ templ_string = process_pci_optimation(request_json, self.osdf_config,policies)
+
+
+if __name__ == "__main__":
+ unittest.main()
+