summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/functest/simulators/simulated-config/osdf_config.yaml4
-rw-r--r--test/inter_domain_route_opt/bandwidth_attributes.json176
-rw-r--r--test/inter_domain_route_opt/controllers_for_interfaces.json62
-rw-r--r--test/inter_domain_route_opt/controllers_list.json16
-rw-r--r--test/inter_domain_route_opt/get_links.json157
-rw-r--r--test/inter_domain_route_opt/request.json30
-rw-r--r--test/test_inter_domain_route_opt.py151
7 files changed, 596 insertions, 0 deletions
diff --git a/test/functest/simulators/simulated-config/osdf_config.yaml b/test/functest/simulators/simulated-config/osdf_config.yaml
index 414d7c7..d4d20c9 100755
--- a/test/functest/simulators/simulated-config/osdf_config.yaml
+++ b/test/functest/simulators/simulated-config/osdf_config.yaml
@@ -73,4 +73,8 @@ pciHMSPassword: "" # pcihandler password for call back.
aaiUrl: "https://api.url:30233"
aaiGetLinksUrl: "/aai/v16/network/logical-links"
+aaiGetControllersUrl: /aai/v19/external-system/esr-thirdparty-sdnc-list
+controllerQueryUrl: /aai/v19/query?format=resource
+aaiGetInterDomainLinksUrl: /aai/v19/network/logical-links?link-type=inter-domain&operational-status=up
+
diff --git a/test/inter_domain_route_opt/bandwidth_attributes.json b/test/inter_domain_route_opt/bandwidth_attributes.json
new file mode 100644
index 0000000..0de7e51
--- /dev/null
+++ b/test/inter_domain_route_opt/bandwidth_attributes.json
@@ -0,0 +1,176 @@
+{
+ "int-1-bw":{
+ "interface-name":"int1",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ },
+ "int-3-bw":{
+ "interface-name":"int3",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ },
+ "int-4-bw":{
+ "interface-name":"int4",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ },
+ "int-5-bw":{
+ "interface-name":"int5",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ },
+ "int-6-bw":{
+ "interface-name":"int6",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ },
+ "int-7-bw":{
+ "interface-name":"int7",
+ "bandwidth-attributes":{
+ "bandwidth-attribute":[
+ {
+ "bwa-id":"bw6",
+ "resource-version":"1596387588545",
+ "available-bandwidth-map":{
+ "available-bandwidth":[
+ {
+ "ab-id":"ab226",
+ "odu-type":"ODU2",
+ "number":1,
+ "resource-version":"1596387588545"
+ },
+ {
+ "ab-id":"ab112",
+ "odu-type":"ODU4",
+ "number":8,
+ "resource-version":"1596387588545"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "resource-version":"1596387588545",
+ "in-maint":false
+ }
+}
diff --git a/test/inter_domain_route_opt/controllers_for_interfaces.json b/test/inter_domain_route_opt/controllers_for_interfaces.json
new file mode 100644
index 0000000..3de47d1
--- /dev/null
+++ b/test/inter_domain_route_opt/controllers_for_interfaces.json
@@ -0,0 +1,62 @@
+{
+ "int-1-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller1",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ },
+ "int-3-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller2",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ },
+ "int-4-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller2",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ },
+ "int-5-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller3",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ },
+ "int-6-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller3",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ },
+ "int-7-cont":{
+ "results":[
+ {
+ "esr-thirdparty-sdnc":{
+ "thirdparty-sdnc-id":"Controller4",
+ "resource-version":"1593421890494"
+ }
+ }
+ ]
+ }
+}
diff --git a/test/inter_domain_route_opt/controllers_list.json b/test/inter_domain_route_opt/controllers_list.json
new file mode 100644
index 0000000..158f530
--- /dev/null
+++ b/test/inter_domain_route_opt/controllers_list.json
@@ -0,0 +1,16 @@
+{
+ "esr-thirdparty-sdnc":[
+ {
+ "thirdparty-sdnc-id":"Controller1"
+ },
+ {
+ "thirdparty-sdnc-id":"Controller2"
+ },
+ {
+ "thirdparty-sdnc-id":"Controller3"
+ },
+ {
+ "thirdparty-sdnc-id":"Controller4"
+ }
+ ]
+}
diff --git a/test/inter_domain_route_opt/get_links.json b/test/inter_domain_route_opt/get_links.json
new file mode 100644
index 0000000..0e70523
--- /dev/null
+++ b/test/inter_domain_route_opt/get_links.json
@@ -0,0 +1,157 @@
+{
+ "logical-link":[
+ {
+ "link-name":"link1",
+ "in-maint":false,
+ "link-type":"inter-domain",
+ "resource-version":"1588952379221",
+ "operational-status":"up",
+ "relationship-list":{
+ "relationship":[
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf1/p-interfaces/p-interface/int1",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf1"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int1"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int3",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf2"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int3"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name":"link2",
+ "in-maint":false,
+ "link-type":"inter-domain",
+ "resource-version":"1588952379221",
+ "operational-status":"up",
+ "relationship-list":{
+ "relationship":[
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int4",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf2"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int4"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int5",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf3"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int5"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name":"link3",
+ "in-maint":false,
+ "link-type":"inter-domain",
+ "resource-version":"1588952379221",
+ "operational-status":"up",
+ "relationship-list":{
+ "relationship":[
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int6",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf3"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int6"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to":"p-interface",
+ "relationship-label":"tosca.relationships.network.LinksTo",
+ "related-link":"/aai/v19/network/pnfs/pnf/pnf4/p-interfaces/p-interface/int7",
+ "relationship-data":[
+ {
+ "relationship-key":"pnf.pnf-name",
+ "relationship-value":"pnf4"
+ },
+ {
+ "relationship-key":"p-interface.interface-name",
+ "relationship-value":"int7"
+ }
+ ],
+ "related-to-property":[
+ {
+ "property-key":"p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/test/inter_domain_route_opt/request.json b/test/inter_domain_route_opt/request.json
new file mode 100644
index 0000000..041a32f
--- /dev/null
+++ b/test/inter_domain_route_opt/request.json
@@ -0,0 +1,30 @@
+{
+ "requestInfo":{
+ "transactionId":"123456",
+ "requestId":"789456",
+ "callbackUrl":"",
+ "callbackHeader": "",
+ "sourceId":"SDNC",
+ "requestType":"create",
+ "numSolutions":1,
+ "optimizers":[
+ "route"
+ ],
+ "timeout":600
+ },
+ "routeInfo":{
+ "routeRequest":{
+ "srcDetails":{
+ "interfaceId":"int19",
+ "nodeId":"pnf1",
+ "controllerId":"Controller1"
+ },
+ "dstDetails":{
+ "interfaceId":"int20",
+ "nodeId":"pnf4",
+ "controllerId":"Controller3"
+ },
+ "serviceRate":"ODU2"
+ }
+ }
+}
diff --git a/test/test_inter_domain_route_opt.py b/test/test_inter_domain_route_opt.py
new file mode 100644
index 0000000..3d18abc
--- /dev/null
+++ b/test/test_inter_domain_route_opt.py
@@ -0,0 +1,151 @@
+# -------------------------------------------------------------------------
+# Copyright (c) 2020 Fujitsu Limited 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 unittest
+
+from unittest.mock import patch
+from apps.route.optimizers.inter_domain_route_opt import InterDomainRouteOpt
+import osdf.config.loader as config_loader
+from osdf.utils.interfaces import json_from_file
+from osdf.utils.programming_utils import DotDict
+
+count = 1
+
+def mocked_requests_get(*args, **kwargs):
+ class MockResponse:
+ def __init__(self, json_data, status_code):
+ self.json_data = json_data
+ self.status_code = status_code
+
+ def json(self):
+ return self.json_data
+
+ main_dir = ""
+ response_data_file = main_dir + "test/inter_domain_route_opt/get_links.json"
+ bandwidth_attributes = main_dir + "test/inter_domain_route_opt/bandwidth_attributes.json"
+ bandwidth_attribute_values = json_from_file(bandwidth_attributes)
+
+ controllers_list = main_dir + "test/inter_domain_route_opt/controllers_list.json"
+
+ if args[0] == 'https://api.url:30233/aai/v19/network/logical-links?link-type=inter-domain&operational-status=up':
+ return MockResponse(json_from_file(response_data_file), 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf1/p-interfaces/p-interface/int1?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-1-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int3?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-3-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int4?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-4-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int5?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-5-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int6?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-6-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf4/p-interfaces/p-interface/int7?depth=all':
+ return MockResponse(bandwidth_attribute_values["int-7-bw"], 200)
+ elif args[0] == 'https://api.url:30233/aai/v19/external-system/esr-thirdparty-sdnc-list':
+ return MockResponse(json_from_file(controllers_list), 200)
+ return MockResponse(None, 404)
+
+
+def mocked_requests_put(*args, **kwargs):
+ class MockResponse:
+ def __init__(self, json_data, status_code):
+ self.json_data = json_data
+ self.status_code = status_code
+
+ def json(self):
+ return self.json_data
+ main_dir = ""
+ controllers_for_interfaces = main_dir + "test/inter_domain_route_opt/controllers_for_interfaces.json"
+ controllers_for_interfaces_values = json_from_file(controllers_for_interfaces)
+
+ global count
+
+ if count == 1:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-1-cont"], 200)
+ elif count == 2:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-3-cont"], 200)
+ elif count == 3:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-4-cont"], 200)
+ elif count == 4:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-5-cont"], 200)
+ elif count == 5:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-6-cont"], 200)
+ elif count == 6:
+ count += 1
+ return MockResponse(controllers_for_interfaces_values["int-7-cont"], 200)
+
+ return MockResponse(None, 404)
+
+
+
+class TestInterDomainRouteOpt(unittest.TestCase):
+ @patch('apps.route.optimizers.inter_domain_route_opt.requests.get', side_effect=mocked_requests_get)
+ @patch('apps.route.optimizers.inter_domain_route_opt.requests.put', side_effect=mocked_requests_put)
+ @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc')
+ def test_process_get_route(self, mock_solve , mock_put, mock_get):
+ main_dir = ""
+ mock_solve.return_value = [{'x': [1, 1, 0, 0, 0, 0]}]
+ 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/inter_domain_route_opt/request.json"
+ request_json = json_from_file(parameter_data_file)
+ routopt = InterDomainRouteOpt()
+ actual_response = routopt.get_route(request_json,self.osdf_config)
+ mock_response = {
+ "requestId":"789456",
+ "transactionId":"123456",
+ "statusMessage":"SUCCESS",
+ "requestStatus":"accepted",
+ "solutions":{
+ "routeInfo":{
+ "serviceRoute":[
+ {
+ "srcInterfaceId":"int19",
+ "dstInterfaceId":"int1",
+ "controllerId":"Controller1"
+ },
+ {
+ "srcInterfaceId":"int3",
+ "dstInterfaceId":"int4",
+ "controllerId":"Controller2"
+ },
+ {
+ "srcInterfaceId":"int5",
+ "dstInterfaceId":"int20",
+ "controllerId":"Controller3"
+ }
+ ],
+ "linkList":[
+ "link1",
+ "link2"
+ ]
+ }
+ }
+ }
+ self.assertEqual(mock_response, actual_response)
+
+
+if __name__ == '__main__':
+ unittest.main()
+ \ No newline at end of file