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 ##############################################################################
19 from common import test_utils
22 class TransportGNPYtesting(unittest.TestCase):
25 def __init_logfile(cls):
26 if os.path.isfile("./transportpce_tests/gnpy.log"):
27 os.remove("transportpce_tests/gnpy.log")
33 cls.processes = test_utils.start_tpce()
36 def tearDownClass(cls):
37 for process in cls.processes:
38 test_utils.shutdown_process(process)
39 print("all processes killed")
44 # Mount the different topologies
45 def test_01_connect_clliNetwork(self):
46 url = ("{}/config/ietf-network:networks/network/clli-network"
47 .format(test_utils.RESTCONF_BASE_URL))
48 topo_cllinet_file = "sample_configs/gnpy/clliNetwork.json"
49 if os.path.isfile(topo_cllinet_file):
50 with open(topo_cllinet_file, 'r') as clli_net:
51 body = clli_net.read()
52 response = requests.request(
53 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
54 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
55 self.assertEqual(response.status_code, requests.codes.ok)
58 def test_02_connect_openroadmNetwork(self):
59 url = ("{}/config/ietf-network:networks/network/openroadm-network"
60 .format(test_utils.RESTCONF_BASE_URL))
61 topo_ordnet_file = "sample_configs/gnpy/openroadmNetwork.json"
62 if os.path.isfile(topo_ordnet_file):
63 with open(topo_ordnet_file, 'r') as ord_net:
65 response = requests.request(
66 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
67 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
68 self.assertEqual(response.status_code, requests.codes.ok)
71 def test_03_connect_openroadmTopology(self):
72 url = ("{}/config/ietf-network:networks/network/openroadm-topology"
73 .format(test_utils.RESTCONF_BASE_URL))
74 topo_ordtopo_file = "sample_configs/gnpy/openroadmTopology.json"
75 if os.path.isfile(topo_ordtopo_file):
76 with open(topo_ordtopo_file, 'r') as ord_topo:
77 body = ord_topo.read()
78 response = requests.request(
79 "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON,
80 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
81 self.assertEqual(response.status_code, requests.codes.ok)
84 # Path computed by PCE is feasible according to Gnpy
85 def test_04_path_computation_FeasibleWithPCE(self):
86 url = ("{}/operations/transportpce-pce:path-computation-request"
87 .format(test_utils.RESTCONF_BASE_URL))
90 "service-name": "service-1",
91 "resource-reserve": "true",
92 "pce-metric": "hop-count",
93 "service-handler-header": {
94 "request-id": "request-1"
97 "node-id": "XPONDER-1",
98 "service-rate": "100",
99 "service-format": "Ethernet",
103 "node-id": "XPONDER-5",
104 "service-rate": "100",
105 "service-format": "Ethernet",
110 response = requests.request(
111 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
112 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
113 self.assertEqual(response.status_code, requests.codes.ok)
114 res = response.json()
115 self.assertEqual(res['output']['configuration-response-common'][
116 'response-code'], '200')
117 self.assertEqual(res['output']['configuration-response-common'][
119 'Path is calculated by PCE')
120 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
122 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
123 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
125 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
128 # Path computed by PCE is not feasible by GNPy and GNPy cannot find
129 # another one (low SNR)
130 def test_05_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
131 url = ("{}/operations/transportpce-pce:path-computation-request"
132 .format(test_utils.RESTCONF_BASE_URL))
135 "service-name": "service-2",
136 "resource-reserve": "true",
137 "pce-metric": "hop-count",
138 "service-handler-header": {
139 "request-id": "request-2"
142 "node-id": "XPONDER-1",
143 "service-rate": "100",
144 "service-format": "Ethernet",
148 "node-id": "XPONDER-5",
149 "service-rate": "100",
150 "service-format": "Ethernet",
153 "hard-constraints": {
159 "node-id": "OpenROADM-2"
165 "node-id": "OpenROADM-3"
171 "node-id": "OpenROADM-4"
179 response = requests.request(
180 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
181 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
182 self.assertEqual(response.status_code, requests.codes.ok)
183 res = response.json()
184 self.assertEqual(res['output']['configuration-response-common'][
185 'response-code'], '500')
186 self.assertEqual(res['output']['configuration-response-common'][
188 'No path available by PCE and GNPy ')
189 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
191 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'],
193 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
195 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'],
199 # #PCE cannot find a path while GNPy finds a feasible one
200 def test_06_path_computation_NotFoundByPCE_FoundByGNPy(self):
201 url = ("{}/operations/transportpce-pce:path-computation-request"
202 .format(test_utils.RESTCONF_BASE_URL))
205 "service-name": "service-3",
206 "resource-reserve": "true",
207 "pce-metric": "hop-count",
208 "service-handler-header": {
209 "request-id": "request-3"
212 "node-id": "XPONDER-1",
213 "service-rate": "100",
214 "service-format": "Ethernet",
218 "node-id": "XPONDER-4",
219 "service-rate": "100",
220 "service-format": "Ethernet",
223 "hard-constraints": {
229 "node-id": "OpenROADM-2"
235 "node-id": "OpenROADM-3"
243 response = requests.request(
244 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
245 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
246 self.assertEqual(response.status_code, requests.codes.ok)
247 res = response.json()
248 self.assertEqual(res['output']['configuration-response-common'][
249 'response-code'], '200')
250 self.assertEqual(res['output']['configuration-response-common'][
252 'Path is calculated by GNPy')
253 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
255 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
256 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
258 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
261 # Not found path by PCE and GNPy cannot find another one
262 def test_07_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
263 url = ("{}/operations/transportpce-pce:path-computation-request"
264 .format(test_utils.RESTCONF_BASE_URL))
267 "service-name": "service-4",
268 "resource-reserve": "true",
269 "pce-metric": "hop-count",
270 "service-handler-header": {
271 "request-id": "request-4"
274 "node-id": "XPONDER-1",
275 "service-rate": "100",
276 "service-format": "Ethernet",
280 "node-id": "XPONDER-4",
281 "service-rate": "100",
282 "service-format": "Ethernet",
285 "hard-constraints": {
291 "node-id": "OpenROADM-2"
297 "node-id": "OpenROADM-3"
303 "node-id": "OpenROADM-4"
309 "node-id": "OpenROADM-3"
317 response = requests.request(
318 "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
319 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
320 self.assertEqual(response.status_code, requests.codes.ok)
321 res = response.json()
322 self.assertEqual(res['output']['configuration-response-common'][
323 'response-code'], '500')
324 self.assertEqual(res['output']['configuration-response-common'][
326 'No path available by PCE and GNPy ')
329 # Disconnect the different topologies
330 def test_08_disconnect_openroadmTopology(self):
331 url = ("{}/config/ietf-network:networks/network/openroadm-topology"
332 .format(test_utils.RESTCONF_BASE_URL))
334 response = requests.request(
335 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
336 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
337 self.assertEqual(response.status_code, requests.codes.ok)
340 def test_09_disconnect_openroadmNetwork(self):
341 url = ("{}/config/ietf-network:networks/network/openroadm-network"
342 .format(test_utils.RESTCONF_BASE_URL))
344 response = requests.request(
345 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
346 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
347 self.assertEqual(response.status_code, requests.codes.ok)
350 def test_10_disconnect_clliNetwork(self):
351 url = ("{}/config/ietf-network:networks/network/clli-network"
352 .format(test_utils.RESTCONF_BASE_URL))
354 response = requests.request(
355 "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON,
356 auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
357 self.assertEqual(response.status_code, requests.codes.ok)
361 if __name__ == "__main__":
362 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
363 unittest.main(verbosity=2)