summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/functest/simulators/simulated-config/osdf_config.yaml3
-rw-r--r--test/simple_route_opt/AAI.json164
-rw-r--r--test/simple_route_opt/routeOpt.json34
-rw-r--r--test/test_simple_route_opt.py57
4 files changed, 258 insertions, 0 deletions
diff --git a/test/functest/simulators/simulated-config/osdf_config.yaml b/test/functest/simulators/simulated-config/osdf_config.yaml
index eccad14..414d7c7 100755
--- a/test/functest/simulators/simulated-config/osdf_config.yaml
+++ b/test/functest/simulators/simulated-config/osdf_config.yaml
@@ -71,3 +71,6 @@ configDbGetNbrListUrl: 'getNbrList'
pciHMSUsername: "" # pcihandler username for call back.
pciHMSPassword: "" # pcihandler password for call back.
+aaiUrl: "https://api.url:30233"
+aaiGetLinksUrl: "/aai/v16/network/logical-links"
+
diff --git a/test/simple_route_opt/AAI.json b/test/simple_route_opt/AAI.json
new file mode 100644
index 0000000..6ef264b
--- /dev/null
+++ b/test/simple_route_opt/AAI.json
@@ -0,0 +1,164 @@
+{
+ "logical-link": [
+ {
+ "link-name": "link-id-1",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1585009311719",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-3",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "20.20.20.20"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-3"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/10.10.10.10/p-interfaces/p-interface/p-interface-2",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "10.10.10.10"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "link-id-2",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1584943281792",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/22.22.22.22/p-interfaces/p-interface/p-interface-7",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "22.22.22.22"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-6",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "11.11.11.11"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-6"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "link-id-3",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1584943345290",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-5",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "11.11.11.11"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-5"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-4",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "20.20.20.20"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-4"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "rahul",
+ "in-maint": true,
+ "link-type": "example-link-type-val-rahul",
+ "resource-version": "1585023629505",
+ "operational-status": "UP"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/simple_route_opt/routeOpt.json b/test/simple_route_opt/routeOpt.json
new file mode 100644
index 0000000..887b85b
--- /dev/null
+++ b/test/simple_route_opt/routeOpt.json
@@ -0,0 +1,34 @@
+{
+ "requestInfo": {
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "callbackUrl": "https://wiki.onap.org:5000/callbackUrl",
+ "sourceId": "",
+ "requestType": "create",
+ "numSolutions": 1,
+ "optimizers": [
+ "route"
+ ],
+ "timeout": 600
+ },
+ "routeInfo": {
+ "routeRequests": [
+ {
+ "srcPort": {
+ "accessTopologyId": "Topo113",
+ "accessClientId": "clientU12",
+ "accessProviderId": "VDF1234",
+ "accessNodeId": "22.22.22.22",
+ "accessLtpId": "1345"
+ },
+ "dstPort": {
+ "accessTopologyId": "Topo3421",
+ "accessClientId": "clientD123",
+ "accessProviderId": "VDF3214",
+ "accessNodeId": "10.10.10.10",
+ "accessLtpId": "3452"
+ }
+ }
+ ]
+ }
+}
diff --git a/test/test_simple_route_opt.py b/test/test_simple_route_opt.py
new file mode 100644
index 0000000..3b4facc
--- /dev/null
+++ b/test/test_simple_route_opt.py
@@ -0,0 +1,57 @@
+from apps.route.optimizers.simple_route_opt import RouteOpt
+from osdf.utils.interfaces import json_from_file
+from unittest.mock import patch
+import osdf.config.loader as config_loader
+from osdf.utils.programming_utils import DotDict
+import unittest
+
+
+class TestSimpleRouteOptimization(unittest.TestCase):
+ @patch('apps.route.optimizers.simple_route_opt.requests.get')
+ @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc')
+ def test_process_nst_selection_solutions( self, mock_solve, mock_get):
+
+ main_dir = ""
+ response_data_file = main_dir + "test/simple_route_opt/AAI.json"
+ mock_get.return_value.json.return_value = json_from_file(response_data_file)
+ mock_get.return_value.status_code = 200
+ mock_solve.return_value = [{'x': [1, 1, 1]}]
+ 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))
+ parameter_data_file = main_dir + "test/simple_route_opt/routeOpt.json"
+ request_json = json_from_file(parameter_data_file)
+ mock_response = {
+ "requestId": "yyy-yyy-yyyy",
+ "requestStatus": "accepted",
+ "solutions": [
+ {
+ "end_node": "10.10.10.10",
+ "link": "link-id-1",
+ "start_node": "20.20.20.20"
+ },
+ {
+ "end_node": "11.11.11.11",
+ "link": "link-id-2",
+ "start_node": "22.22.22.22"
+ },
+ {
+ "end_node": "20.20.20.20",
+ "link": "link-id-3",
+ "start_node": "11.11.11.11"
+ }
+ ],
+ "statusMessage": " ",
+ "transactionId": "xxx-xxx-xxxx"
+ }
+ routopt = RouteOpt()
+ actual_response = routopt.get_route(request_json,self.osdf_config)
+ self.assertEqual(mock_response, actual_response)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+