3 ##############################################################################
4 # Copyright (c) 2019 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 ##############################################################################
24 class TransportPCEPortMappingTesting(unittest.TestCase):
26 honeynode_process1 = None
27 honeynode_process2 = None
29 restconf_baseurl = "http://localhost:8181/restconf"
33 print ("starting honeynode1...")
34 cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
37 print ("starting honeynode2...")
38 cls.honeynode_process2 = test_utils.start_roadma_honeynode()
40 print ("all honeynodes started")
42 print ("starting opendaylight...")
43 cls.odl_process = test_utils.start_tpce()
45 print ("opendaylight started")
48 def tearDownClass(cls):
49 for child in psutil.Process(cls.odl_process.pid).children():
50 child.send_signal(signal.SIGINT)
52 cls.odl_process.send_signal(signal.SIGINT)
53 cls.odl_process.wait()
54 for child in psutil.Process(cls.honeynode_process1.pid).children():
55 child.send_signal(signal.SIGINT)
57 cls.honeynode_process1.send_signal(signal.SIGINT)
58 cls.honeynode_process1.wait()
59 for child in psutil.Process(cls.honeynode_process2.pid).children():
60 child.send_signal(signal.SIGINT)
62 cls.honeynode_process2.send_signal(signal.SIGINT)
63 cls.honeynode_process2.wait()
66 print ("execution of {}".format(self.id().split(".")[-1]))
69 def test_01_rdm_device_connected(self):
70 url = ("{}/config/network-topology:"
71 "network-topology/topology/topology-netconf/node/ROADM-A1"
72 .format(self.restconf_baseurl))
74 "node-id": "ROADM-A1",
75 "netconf-node-topology:username": "admin",
76 "netconf-node-topology:password": "admin",
77 "netconf-node-topology:host": "127.0.0.1",
78 "netconf-node-topology:port": "17841",
79 "netconf-node-topology:tcp-only": "false",
80 "netconf-node-topology:pass-through": {}}]}
81 headers = {'content-type': 'application/json'}
82 response = requests.request(
83 "PUT", url, data=json.dumps(data), headers=headers,
84 auth=('admin', 'admin'))
85 self.assertEqual(response.status_code, requests.codes.created)
88 def test_02_rdm_device_connected(self):
89 url = ("{}/operational/network-topology:"
90 "network-topology/topology/topology-netconf/node/ROADM-A1"
91 .format(self.restconf_baseurl))
92 headers = {'content-type': 'application/json'}
93 response = requests.request(
94 "GET", url, headers=headers, auth=('admin', 'admin'))
95 self.assertEqual(response.status_code, requests.codes.ok)
98 res['node'][0]['netconf-node-topology:connection-status'],
102 def test_03_rdm_portmapping_info(self):
103 url = ("{}/config/transportpce-portmapping:network/"
104 "nodes/ROADM-A1/node-info"
105 .format(self.restconf_baseurl))
106 headers = {'content-type': 'application/json'}
107 response = requests.request(
108 "GET", url, headers=headers, auth=('admin', 'admin'))
109 self.assertEqual(response.status_code, requests.codes.ok)
110 res = response.json()
112 {u'node-info': {u'node-type': u'rdm',
113 u'node-ip-address': u'127.0.0.11',
114 u'node-clli': u'NodeA',
115 u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
116 u'node-model': u'model2'}},
120 def test_04_rdm_portmapping_DEG1_TTP_TXRX(self):
121 url = ("{}/config/transportpce-portmapping:network/"
122 "nodes/ROADM-A1/mapping/DEG1-TTP-TXRX"
123 .format(self.restconf_baseurl))
124 headers = {'content-type': 'application/json'}
125 response = requests.request(
126 "GET", url, headers=headers, auth=('admin', 'admin'))
127 self.assertEqual(response.status_code, requests.codes.ok)
128 res = response.json()
130 {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0',
131 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'},
134 def test_05_rdm_portmapping_DEG2_TTP_TXRX_with_ots_oms(self):
135 url = ("{}/config/transportpce-portmapping:network/"
136 "nodes/ROADM-A1/mapping/DEG2-TTP-TXRX"
137 .format(self.restconf_baseurl))
138 headers = {'content-type': 'application/json'}
139 response = requests.request(
140 "GET", url, headers=headers, auth=('admin', 'admin'))
141 self.assertEqual(response.status_code, requests.codes.ok)
142 res = response.json()
144 {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0',
145 'logical-connection-point': 'DEG2-TTP-TXRX',
146 'supporting-oms': 'OMS-DEG2-TTP-TXRX', 'supporting-ots': 'OTS-DEG2-TTP-TXRX',
147 'port-direction': 'bidirectional'},
150 def test_06_rdm_portmapping_SRG1_PP3_TXRX(self):
151 url = ("{}/config/transportpce-portmapping:network/"
152 "nodes/ROADM-A1/mapping/SRG1-PP3-TXRX"
153 .format(self.restconf_baseurl))
154 headers = {'content-type': 'application/json'}
155 response = requests.request(
156 "GET", url, headers=headers, auth=('admin', 'admin'))
157 self.assertEqual(response.status_code, requests.codes.ok)
158 res = response.json()
160 {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0',
161 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'},
164 def test_07_rdm_portmapping_SRG3_PP1_TXRX(self):
165 url = ("{}/config/transportpce-portmapping:network/"
166 "nodes/ROADM-A1/mapping/SRG3-PP1-TXRX"
167 .format(self.restconf_baseurl))
168 headers = {'content-type': 'application/json'}
169 response = requests.request(
170 "GET", url, headers=headers, auth=('admin', 'admin'))
171 self.assertEqual(response.status_code, requests.codes.ok)
172 res = response.json()
174 {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0',
175 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'},
178 def test_08_xpdr_device_connected(self):
179 url = ("{}/config/network-topology:"
180 "network-topology/topology/topology-netconf/node/XPDR-A1"
181 .format(self.restconf_baseurl))
183 "node-id": "XPDR-A1",
184 "netconf-node-topology:username": "admin",
185 "netconf-node-topology:password": "admin",
186 "netconf-node-topology:host": "127.0.0.1",
187 "netconf-node-topology:port": "17840",
188 "netconf-node-topology:tcp-only": "false",
189 "netconf-node-topology:pass-through": {}}]}
190 headers = {'content-type': 'application/json'}
191 response = requests.request(
192 "PUT", url, data=json.dumps(data), headers=headers,
193 auth=('admin', 'admin'))
194 self.assertEqual(response.status_code, requests.codes.created)
197 def test_09_xpdr_device_connected(self):
198 url = ("{}/operational/network-topology:"
199 "network-topology/topology/topology-netconf/node/XPDR-A1"
200 .format(self.restconf_baseurl))
201 headers = {'content-type': 'application/json'}
202 response = requests.request(
203 "GET", url, headers=headers, auth=('admin', 'admin'))
204 self.assertEqual(response.status_code, requests.codes.ok)
205 res = response.json()
207 res['node'][0]['netconf-node-topology:connection-status'],
211 def test_10_xpdr_portmapping_info(self):
212 url = ("{}/config/transportpce-portmapping:network/"
213 "nodes/XPDR-A1/node-info"
214 .format(self.restconf_baseurl))
215 headers = {'content-type': 'application/json'}
216 response = requests.request(
217 "GET", url, headers=headers, auth=('admin', 'admin'))
218 self.assertEqual(response.status_code, requests.codes.ok)
219 res = response.json()
221 {u'node-info': {u'node-type': u'xpdr',
222 u'node-ip-address': u'1.2.3.4',
223 u'node-clli': u'NodeA',
224 u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
225 u'node-model': u'model2'}},
229 def test_11_xpdr_portmapping_NETWORK1(self):
230 url = ("{}/config/transportpce-portmapping:network/"
231 "nodes/XPDR-A1/mapping/XPDR1-NETWORK1"
232 .format(self.restconf_baseurl))
233 headers = {'content-type': 'application/json'}
234 response = requests.request(
235 "GET", url, headers=headers, auth=('admin', 'admin'))
236 self.assertEqual(response.status_code, requests.codes.ok)
237 res = response.json()
239 {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
240 'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
241 'port-direction': 'bidirectional', 'associated-lcp': 'XPDR1-CLIENT1'},
244 def test_12_xpdr_portmapping_NETWORK2(self):
245 url = ("{}/config/transportpce-portmapping:network/"
246 "nodes/XPDR-A1/mapping/XPDR1-NETWORK2"
247 .format(self.restconf_baseurl))
248 headers = {'content-type': 'application/json'}
249 response = requests.request(
250 "GET", url, headers=headers, auth=('admin', 'admin'))
251 self.assertEqual(response.status_code, requests.codes.ok)
252 res = response.json()
254 {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
255 'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
256 'associated-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network'},
259 def test_13_xpdr_portmapping_CLIENT1(self):
260 url = ("{}/config/transportpce-portmapping:network/"
261 "nodes/XPDR-A1/mapping/XPDR1-CLIENT1"
262 .format(self.restconf_baseurl))
263 headers = {'content-type': 'application/json'}
264 response = requests.request(
265 "GET", url, headers=headers, auth=('admin', 'admin'))
266 self.assertEqual(response.status_code, requests.codes.ok)
267 res = response.json()
269 {'supporting-port': 'C1',
270 'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
271 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
272 'associated-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client'},
275 def test_14_xpdr_portmapping_CLIENT2(self):
276 url = ("{}/config/transportpce-portmapping:network/"
277 "nodes/XPDR-A1/mapping/XPDR1-CLIENT2"
278 .format(self.restconf_baseurl))
279 headers = {'content-type': 'application/json'}
280 response = requests.request(
281 "GET", url, headers=headers, auth=('admin', 'admin'))
282 self.assertEqual(response.status_code, requests.codes.ok)
283 res = response.json()
285 {'supporting-port': 'C1',
286 'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT',
287 'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
288 'associated-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client'},
291 def test_15_xpdr_device_disconnected(self):
292 url = ("{}/config/network-topology:"
293 "network-topology/topology/topology-netconf/node/XPDR-A1"
294 .format(self.restconf_baseurl))
295 headers = {'content-type': 'application/json'}
296 response = requests.request(
297 "DELETE", url, headers=headers,
298 auth=('admin', 'admin'))
299 self.assertEqual(response.status_code, requests.codes.ok)
302 def test_16_xpdr_device_disconnected(self):
303 url = ("{}/operational/network-topology:network-topology/topology/"
304 "topology-netconf/node/XPDR-A1".format(self.restconf_baseurl))
305 headers = {'content-type': 'application/json'}
306 response = requests.request(
307 "GET", url, headers=headers, auth=('admin', 'admin'))
308 self.assertEqual(response.status_code, requests.codes.not_found)
309 res = response.json()
311 {"error-type":"application", "error-tag":"data-missing",
312 "error-message":"Request could not be completed because the relevant data model content does not exist"},
313 res['errors']['error'])
315 def test_17_xpdr_device_disconnected(self):
316 url = ("{}/config/transportpce-portmapping:network/nodes/XPDR-A1".format(self.restconf_baseurl))
317 headers = {'content-type': 'application/json'}
318 response = requests.request(
319 "GET", url, headers=headers, auth=('admin', 'admin'))
320 self.assertEqual(response.status_code, requests.codes.not_found)
321 res = response.json()
323 {"error-type":"application", "error-tag":"data-missing",
324 "error-message":"Request could not be completed because the relevant data model content does not exist"},
325 res['errors']['error'])
327 def test_18_rdm_device_disconnected(self):
328 url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1"
329 .format(self.restconf_baseurl))
330 headers = {'content-type': 'application/json'}
331 response = requests.request(
332 "DELETE", url, headers=headers,
333 auth=('admin', 'admin'))
334 self.assertEqual(response.status_code, requests.codes.ok)
337 def test_19_rdm_device_disconnected(self):
338 url = ("{}/operational/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1"
339 .format(self.restconf_baseurl))
340 headers = {'content-type': 'application/json'}
341 response = requests.request(
342 "GET", url, headers=headers, auth=('admin', 'admin'))
343 self.assertEqual(response.status_code, requests.codes.not_found)
344 res = response.json()
346 {"error-type":"application", "error-tag":"data-missing",
347 "error-message":"Request could not be completed because the relevant data model content does not exist"},
348 res['errors']['error'])
350 def test_20_rdm_device_disconnected(self):
351 url = ("{}/config/transportpce-portmapping:network/nodes/ROADM-A1".format(self.restconf_baseurl))
352 headers = {'content-type': 'application/json'}
353 response = requests.request(
354 "GET", url, headers=headers, auth=('admin', 'admin'))
355 self.assertEqual(response.status_code, requests.codes.not_found)
356 res = response.json()
358 {"error-type":"application", "error-tag":"data-missing",
359 "error-message":"Request could not be completed because the relevant data model content does not exist"},
360 res['errors']['error'])
363 if __name__ == "__main__":
364 unittest.main(verbosity=2)