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 ##############################################################################
23 class TransportPCEPortMappingTesting(unittest.TestCase):
25 honeynode_process1 = None
26 honeynode_process2 = None
28 restconf_baseurl = "http://localhost:8181/restconf"
31 def __start_honeynode1(cls):
32 executable = ("./honeynode/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
33 "/honeynode-distribution-1.18.01/honeycomb-tpce")
34 if os.path.isfile(executable):
35 with open('honeynode1.log', 'w') as outfile:
36 cls.honeynode_process1 = subprocess.Popen(
37 [executable, "17831", "sample_configs/ord_2.1/oper-XPDRA.xml"],
41 def __start_honeynode2(cls):
42 executable = ("./honeynode/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
43 "/honeynode-distribution-1.18.01/honeycomb-tpce")
44 if os.path.isfile(executable):
45 with open('honeynode2.log', 'w') as outfile:
46 cls.honeynode_process2 = subprocess.Popen(
47 [executable, "17830", "sample_configs/ord_2.1/oper-ROADMA.xml"],
52 executable = "../karaf/target/assembly/bin/karaf"
53 with open('odl.log', 'w') as outfile:
54 cls.odl_process = subprocess.Popen(
55 ["bash", executable, "server"], stdout=outfile,
56 stdin=open(os.devnull))
60 cls.__start_honeynode1()
62 cls.__start_honeynode2()
68 def tearDownClass(cls):
69 for child in psutil.Process(cls.odl_process.pid).children():
70 child.send_signal(signal.SIGINT)
72 cls.odl_process.send_signal(signal.SIGINT)
73 cls.odl_process.wait()
74 for child in psutil.Process(cls.honeynode_process1.pid).children():
75 child.send_signal(signal.SIGINT)
77 cls.honeynode_process1.send_signal(signal.SIGINT)
78 cls.honeynode_process1.wait()
79 for child in psutil.Process(cls.honeynode_process2.pid).children():
80 child.send_signal(signal.SIGINT)
82 cls.honeynode_process2.send_signal(signal.SIGINT)
83 cls.honeynode_process2.wait()
86 print ("execution of {}".format(self.id().split(".")[-1]))
89 # def test_01_restconfAPI(self):
90 # url = ("{}/operational/network-topology:network-topology/topology/"
91 # "topology-netconf/node/controller-config".format(self.restconf_baseurl))
92 # headers = {'content-type': 'application/json'}
93 # response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
94 # self.assertEqual(response.status_code, requests.codes.ok)
95 # res = response.json()
96 # self.assertEqual(res['node'] [0] ['netconf-node-topology:connection-status'],
99 def test_02_restconfAPI(self):
100 url = ("{}/config/transportpce-portmapping:network/nodes/controller-config".format(self.restconf_baseurl))
101 headers = {'content-type': 'application/json'}
102 response = requests.request(
103 "GET", url, headers=headers, auth=('admin', 'admin'))
104 self.assertEqual(response.status_code, requests.codes.not_found)
105 res = response.json()
107 {"error-type":"application", "error-tag":"data-missing",
108 "error-message":"Request could not be completed because the relevant data model content does not exist "},
109 res['errors']['error'])
111 def test_03_rdm_device_connected(self):
112 url = ("{}/config/network-topology:"
113 "network-topology/topology/topology-netconf/node/ROADMA"
114 .format(self.restconf_baseurl))
117 "netconf-node-topology:username": "admin",
118 "netconf-node-topology:password": "admin",
119 "netconf-node-topology:host": "127.0.0.1",
120 "netconf-node-topology:port": "17830",
121 "netconf-node-topology:tcp-only": "false",
122 "netconf-node-topology:pass-through": {}}]}
123 headers = {'content-type': 'application/json'}
124 response = requests.request(
125 "PUT", url, data=json.dumps(data), headers=headers,
126 auth=('admin', 'admin'))
127 self.assertEqual(response.status_code, requests.codes.created)
130 def test_04_rdm_device_connected(self):
131 url = ("{}/operational/network-topology:"
132 "network-topology/topology/topology-netconf/node/ROADMA"
133 .format(self.restconf_baseurl))
134 headers = {'content-type': 'application/json'}
135 response = requests.request(
136 "GET", url, headers=headers, auth=('admin', 'admin'))
137 self.assertEqual(response.status_code, requests.codes.ok)
138 res = response.json()
140 res['node'][0]['netconf-node-topology:connection-status'],
144 def test_05_rdm_portmapping_DEG1_TTP_TXRX(self):
145 url = ("{}/config/transportpce-portmapping:network/"
146 "nodes/ROADMA/mapping/DEG1-TTP-TXRX"
147 .format(self.restconf_baseurl))
148 headers = {'content-type': 'application/json'}
149 response = requests.request(
150 "GET", url, headers=headers, auth=('admin', 'admin'))
151 self.assertEqual(response.status_code, requests.codes.ok)
152 res = response.json()
154 {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0',
155 'logical-connection-point': 'DEG1-TTP-TXRX'},
158 def test_06_rdm_portmapping_SRG1_PP7_TXRX(self):
159 url = ("{}/config/transportpce-portmapping:network/"
160 "nodes/ROADMA/mapping/SRG1-PP7-TXRX"
161 .format(self.restconf_baseurl))
162 headers = {'content-type': 'application/json'}
163 response = requests.request(
164 "GET", url, headers=headers, auth=('admin', 'admin'))
165 self.assertEqual(response.status_code, requests.codes.ok)
166 res = response.json()
168 {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0',
169 'logical-connection-point': 'SRG1-PP7-TXRX'},
172 def test_07_rdm_portmapping_SRG3_PP1_TXRX(self):
173 url = ("{}/config/transportpce-portmapping:network/"
174 "nodes/ROADMA/mapping/SRG3-PP1-TXRX"
175 .format(self.restconf_baseurl))
176 headers = {'content-type': 'application/json'}
177 response = requests.request(
178 "GET", url, headers=headers, auth=('admin', 'admin'))
179 self.assertEqual(response.status_code, requests.codes.ok)
180 res = response.json()
182 {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0',
183 'logical-connection-point': 'SRG3-PP1-TXRX'},
186 def test_08_xpdr_device_connected(self):
187 url = ("{}/config/network-topology:"
188 "network-topology/topology/topology-netconf/node/XPDRA"
189 .format(self.restconf_baseurl))
192 "netconf-node-topology:username": "admin",
193 "netconf-node-topology:password": "admin",
194 "netconf-node-topology:host": "127.0.0.1",
195 "netconf-node-topology:port": "17831",
196 "netconf-node-topology:tcp-only": "false",
197 "netconf-node-topology:pass-through": {}}]}
198 headers = {'content-type': 'application/json'}
199 response = requests.request(
200 "PUT", url, data=json.dumps(data), headers=headers,
201 auth=('admin', 'admin'))
202 self.assertEqual(response.status_code, requests.codes.created)
205 def test_09_xpdr_device_connected(self):
206 url = ("{}/operational/network-topology:"
207 "network-topology/topology/topology-netconf/node/XPDRA"
208 .format(self.restconf_baseurl))
209 headers = {'content-type': 'application/json'}
210 response = requests.request(
211 "GET", url, headers=headers, auth=('admin', 'admin'))
212 self.assertEqual(response.status_code, requests.codes.ok)
213 res = response.json()
215 res['node'][0]['netconf-node-topology:connection-status'],
219 def test_10_xpdr_portmapping_NETWORK1(self):
220 url = ("{}/config/transportpce-portmapping:network/"
221 "nodes/XPDRA/mapping/XPDR1-NETWORK1"
222 .format(self.restconf_baseurl))
223 headers = {'content-type': 'application/json'}
224 response = requests.request(
225 "GET", url, headers=headers, auth=('admin', 'admin'))
226 self.assertEqual(response.status_code, requests.codes.ok)
227 res = response.json()
229 {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
230 'logical-connection-point': 'XPDR1-NETWORK1'},
233 def test_11_xpdr_portmapping_NETWORK2(self):
234 url = ("{}/config/transportpce-portmapping:network/"
235 "nodes/XPDRA/mapping/XPDR1-NETWORK2"
236 .format(self.restconf_baseurl))
237 headers = {'content-type': 'application/json'}
238 response = requests.request(
239 "GET", url, headers=headers, auth=('admin', 'admin'))
240 self.assertEqual(response.status_code, requests.codes.ok)
241 res = response.json()
243 {'supporting-port': '2', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
244 'logical-connection-point': 'XPDR1-NETWORK2'},
247 def test_12_xpdr_portmapping_CLIENT1(self):
248 url = ("{}/config/transportpce-portmapping:network/"
249 "nodes/XPDRA/mapping/XPDR1-CLIENT1"
250 .format(self.restconf_baseurl))
251 headers = {'content-type': 'application/json'}
252 response = requests.request(
253 "GET", url, headers=headers, auth=('admin', 'admin'))
254 self.assertEqual(response.status_code, requests.codes.ok)
255 res = response.json()
257 {'supporting-port': 'C1',
258 'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
259 'logical-connection-point': 'XPDR1-CLIENT1'},
262 def test_13_xpdr_portmapping_CLIENT2(self):
263 url = ("{}/config/transportpce-portmapping:network/"
264 "nodes/XPDRA/mapping/XPDR1-CLIENT2"
265 .format(self.restconf_baseurl))
266 headers = {'content-type': 'application/json'}
267 response = requests.request(
268 "GET", url, headers=headers, auth=('admin', 'admin'))
269 self.assertEqual(response.status_code, requests.codes.ok)
270 res = response.json()
272 {'supporting-port': 'C2',
273 'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT',
274 'logical-connection-point': 'XPDR1-CLIENT2'},
277 def test_14_xpdr_portmapping_CLIENT4(self):
278 url = ("{}/config/transportpce-portmapping:network/"
279 "nodes/XPDRA/mapping/XPDR1-CLIENT4"
280 .format(self.restconf_baseurl))
281 headers = {'content-type': 'application/json'}
282 response = requests.request(
283 "GET", url, headers=headers, auth=('admin', 'admin'))
284 self.assertEqual(response.status_code, requests.codes.ok)
285 res = response.json()
287 {'supporting-port': 'C4',
288 'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT',
289 'logical-connection-point': 'XPDR1-CLIENT4'},
292 def test_15_xpdr_device_disconnected(self):
293 url = ("{}/config/network-topology:"
294 "network-topology/topology/topology-netconf/node/XPDRA"
295 .format(self.restconf_baseurl))
296 headers = {'content-type': 'application/json'}
297 response = requests.request(
298 "DELETE", url, headers=headers,
299 auth=('admin', 'admin'))
300 self.assertEqual(response.status_code, requests.codes.ok)
303 def test_16_xpdr_device_disconnected(self):
304 url = ("{}/operational/network-topology:network-topology/topology/"
305 "topology-netconf/node/XPDRA".format(self.restconf_baseurl))
306 headers = {'content-type': 'application/json'}
307 response = requests.request(
308 "GET", url, headers=headers, auth=('admin', 'admin'))
309 self.assertEqual(response.status_code, requests.codes.not_found)
310 res = response.json()
312 {"error-type":"application", "error-tag":"data-missing",
313 "error-message":"Request could not be completed because the relevant data model content does not exist "},
314 res['errors']['error'])
316 def test_17_xpdr_device_disconnected(self):
317 url = ("{}/config/transportpce-portmapping:network/nodes/XPDRA".format(self.restconf_baseurl))
318 headers = {'content-type': 'application/json'}
319 response = requests.request(
320 "GET", url, headers=headers, auth=('admin', 'admin'))
321 self.assertEqual(response.status_code, requests.codes.not_found)
322 res = response.json()
324 {"error-type":"application", "error-tag":"data-missing",
325 "error-message":"Request could not be completed because the relevant data model content does not exist "},
326 res['errors']['error'])
328 def test_18_rdm_device_disconnected(self):
329 url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMA"
330 .format(self.restconf_baseurl))
331 headers = {'content-type': 'application/json'}
332 response = requests.request(
333 "DELETE", url, headers=headers,
334 auth=('admin', 'admin'))
335 self.assertEqual(response.status_code, requests.codes.ok)
338 def test_19_rdm_device_disconnected(self):
339 url = ("{}/operational/network-topology:network-topology/topology/topology-netconf/node/ROADMA"
340 .format(self.restconf_baseurl))
341 headers = {'content-type': 'application/json'}
342 response = requests.request(
343 "GET", url, headers=headers, auth=('admin', 'admin'))
344 self.assertEqual(response.status_code, requests.codes.not_found)
345 res = response.json()
347 {"error-type":"application", "error-tag":"data-missing",
348 "error-message":"Request could not be completed because the relevant data model content does not exist "},
349 res['errors']['error'])
351 def test_20_rdm_device_disconnected(self):
352 url = ("{}/config/transportpce-portmapping:network/nodes/ROADMA".format(self.restconf_baseurl))
353 headers = {'content-type': 'application/json'}
354 response = requests.request(
355 "GET", url, headers=headers, auth=('admin', 'admin'))
356 self.assertEqual(response.status_code, requests.codes.not_found)
357 res = response.json()
359 {"error-type":"application", "error-tag":"data-missing",
360 "error-message":"Request could not be completed because the relevant data model content does not exist "},
361 res['errors']['error'])
364 if __name__ == "__main__":
365 unittest.main(verbosity=2)