3 ##############################################################################
4 # Copyright (c) 2017 Orange, Inc. and others. All rights reserved.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
17 from common import test_utils
20 class TransportGNPYtesting(unittest.TestCase):
23 def __init_logfile(cls):
24 if os.path.isfile("./transportpce_tests/gnpy.log"):
25 os.remove("transportpce_tests/gnpy.log")
31 cls.processes = test_utils.start_tpce()
34 def tearDownClass(cls):
35 for process in cls.processes:
36 test_utils.shutdown_process(process)
37 print("all processes killed")
42 # Mount the different topologies
43 def test_01_connect_clliNetwork(self):
44 url = ("{}/config/ietf-network:networks/network/clli-network"
45 .format(test_utils.RESTCONF_BASE_URL))
46 topo_cllinet_file = "sample_configs/gnpy/clliNetwork.json"
47 if os.path.isfile(topo_cllinet_file):
48 with open(topo_cllinet_file, 'r') as clli_net:
49 body = clli_net.read()
50 response = requests.request(
51 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
52 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
53 self.assertEqual(response.status_code, requests.codes.ok)
56 def test_02_connect_openroadmNetwork(self):
57 url = ("{}/config/ietf-network:networks/network/openroadm-network"
58 .format(test_utils.RESTCONF_BASE_URL))
59 topo_ordnet_file = "sample_configs/gnpy/openroadmNetwork.json"
60 if os.path.isfile(topo_ordnet_file):
61 with open(topo_ordnet_file, 'r') as ord_net:
63 response = requests.request(
64 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
65 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
66 self.assertEqual(response.status_code, requests.codes.ok)
69 def test_03_connect_openroadmTopology(self):
70 url = ("{}/config/ietf-network:networks/network/openroadm-topology"
71 .format(test_utils.RESTCONF_BASE_URL))
72 topo_ordtopo_file = "sample_configs/gnpy/openroadmTopology.json"
73 if os.path.isfile(topo_ordtopo_file):
74 with open(topo_ordtopo_file, 'r') as ord_topo:
75 body = ord_topo.read()
76 response = requests.request(
77 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
78 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
79 self.assertEqual(response.status_code, requests.codes.ok)
82 # Path computed by PCE is feasible according to Gnpy
83 def test_04_path_computation_FeasibleWithPCE(self):
84 url = ("{}/operations/transportpce-pce:path-computation-request"
85 .format(test_utils.RESTCONF_BASE_URL))
88 "service-name": "service-1",
89 "resource-reserve": "true",
90 "pce-metric": "hop-count",
91 "service-handler-header": {
92 "request-id": "request-1"
95 "node-id": "XPONDER-1",
96 "service-rate": "100",
97 "service-format": "Ethernet",
101 "node-id": "XPONDER-5",
102 "service-rate": "100",
103 "service-format": "Ethernet",
108 response = requests.request(
109 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
110 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
111 self.assertEqual(response.status_code, requests.codes.ok)
112 res = response.json()
113 self.assertEqual(res['output']['configuration-response-common'][
114 'response-code'], '200')
115 self.assertEqual(res['output']['configuration-response-common'][
117 'Path is calculated by PCE')
118 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
120 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
121 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
123 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
126 # Path computed by PCE is not feasible by GNPy and GNPy cannot find
127 # another one (low SNR)
128 def test_05_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
129 url = ("{}/operations/transportpce-pce:path-computation-request"
130 .format(test_utils.RESTCONF_BASE_URL))
133 "service-name": "service-2",
134 "resource-reserve": "true",
135 "pce-metric": "hop-count",
136 "service-handler-header": {
137 "request-id": "request-2"
140 "node-id": "XPONDER-1",
141 "service-rate": "100",
142 "service-format": "Ethernet",
146 "node-id": "XPONDER-5",
147 "service-rate": "100",
148 "service-format": "Ethernet",
151 "hard-constraints": {
157 "node-id": "OpenROADM-2"
163 "node-id": "OpenROADM-3"
169 "node-id": "OpenROADM-4"
177 response = requests.request(
178 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
179 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
180 self.assertEqual(response.status_code, requests.codes.ok)
181 res = response.json()
182 self.assertEqual(res['output']['configuration-response-common'][
183 'response-code'], '500')
184 self.assertEqual(res['output']['configuration-response-common'][
186 'No path available by PCE and GNPy ')
187 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
189 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'],
191 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
193 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'],
197 # #PCE cannot find a path while GNPy finds a feasible one
198 def test_06_path_computation_NotFoundByPCE_FoundByGNPy(self):
199 url = ("{}/operations/transportpce-pce:path-computation-request"
200 .format(test_utils.RESTCONF_BASE_URL))
203 "service-name": "service-3",
204 "resource-reserve": "true",
205 "pce-metric": "hop-count",
206 "service-handler-header": {
207 "request-id": "request-3"
210 "node-id": "XPONDER-1",
211 "service-rate": "100",
212 "service-format": "Ethernet",
216 "node-id": "XPONDER-4",
217 "service-rate": "100",
218 "service-format": "Ethernet",
221 "hard-constraints": {
227 "node-id": "OpenROADM-2"
233 "node-id": "OpenROADM-3"
241 response = requests.request(
242 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
243 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
244 self.assertEqual(response.status_code, requests.codes.ok)
245 res = response.json()
246 self.assertEqual(res['output']['configuration-response-common'][
247 'response-code'], '200')
248 self.assertEqual(res['output']['configuration-response-common'][
250 'Path is calculated by GNPy')
251 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
253 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
254 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
256 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
259 # Not found path by PCE and GNPy cannot find another one
260 def test_07_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
261 url = ("{}/operations/transportpce-pce:path-computation-request"
262 .format(test_utils.RESTCONF_BASE_URL))
265 "service-name": "service-4",
266 "resource-reserve": "true",
267 "pce-metric": "hop-count",
268 "service-handler-header": {
269 "request-id": "request-4"
272 "node-id": "XPONDER-1",
273 "service-rate": "100",
274 "service-format": "Ethernet",
278 "node-id": "XPONDER-4",
279 "service-rate": "100",
280 "service-format": "Ethernet",
283 "hard-constraints": {
289 "node-id": "OpenROADM-2"
295 "node-id": "OpenROADM-3"
301 "node-id": "OpenROADM-4"
307 "node-id": "OpenROADM-3"
315 response = requests.request(
316 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
317 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
318 self.assertEqual(response.status_code, requests.codes.ok)
319 res = response.json()
320 self.assertEqual(res['output']['configuration-response-common'][
321 'response-code'], '500')
322 self.assertEqual(res['output']['configuration-response-common'][
324 'No path available by PCE and GNPy ')
327 # Disconnect the different topologies
328 def test_08_disconnect_openroadmTopology(self):
329 url = ("{}/config/ietf-network:networks/network/openroadm-topology"
330 .format(test_utils.RESTCONF_BASE_URL))
332 response = requests.request(
333 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
334 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
335 self.assertEqual(response.status_code, requests.codes.ok)
338 def test_09_disconnect_openroadmNetwork(self):
339 url = ("{}/config/ietf-network:networks/network/openroadm-network"
340 .format(test_utils.RESTCONF_BASE_URL))
342 response = requests.request(
343 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
344 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
345 self.assertEqual(response.status_code, requests.codes.ok)
348 def test_10_disconnect_clliNetwork(self):
349 url = ("{}/config/ietf-network:networks/network/clli-network"
350 .format(test_utils.RESTCONF_BASE_URL))
352 response = requests.request(
353 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
354 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
355 self.assertEqual(response.status_code, requests.codes.ok)
359 if __name__ == "__main__":
360 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
361 unittest.main(verbosity=2)