2 ##############################################################################
3 # Copyright (c) 2020 Orange, Inc. and others. All rights reserved.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 # pylint: disable=no-member
12 # pylint: disable=too-many-public-methods
13 # some pylint false positives specific to tapi test
14 # pylint: disable=unsubscriptable-object
15 # pylint: disable=unsupported-assignment-operation
24 from common import test_utils
27 CREATED_SUCCESSFULLY = 'Result message should contain Xponder Roadm Link created successfully'
29 class TransportTapitesting(unittest.TestCase):
33 cr_serv_sample_data = {"input": {
34 "sdnc-request-header": {
35 "request-id": "request-1",
36 "rpc-action": "service-create",
37 "request-system-id": "appname"
39 "service-name": "service1-OCH-OTU4",
40 "common-id": "commonId",
41 "connection-type": "infrastructure",
43 "service-rate": "100",
44 "node-id": "SPDR-SA1",
45 "service-format": "OTU",
46 "otu-service-rate": "org-openroadm-otn-common-types:OTU4",
50 "committed-info-rate": "100000",
51 "committed-burst-size": "64"
56 "port-device-name": "SPDR-SA1-XPDR1",
58 "port-name": "XPDR1-NETWORK1",
59 "port-rack": "000000.00",
60 "port-shelf": "Chassis#1"
63 "lgx-device-name": "Some lgx-device-name",
64 "lgx-port-name": "Some lgx-port-name",
65 "lgx-port-rack": "000000.00",
66 "lgx-port-shelf": "00"
71 "port-device-name": "SPDR-SA1-XPDR1",
73 "port-name": "XPDR1-NETWORK1",
74 "port-rack": "000000.00",
75 "port-shelf": "Chassis#1"
78 "lgx-device-name": "Some lgx-device-name",
79 "lgx-port-name": "Some lgx-port-name",
80 "lgx-port-rack": "000000.00",
81 "lgx-port-shelf": "00"
87 "service-rate": "100",
88 "node-id": "SPDR-SC1",
89 "service-format": "OTU",
90 "otu-service-rate": "org-openroadm-otn-common-types:OTU4",
94 "committed-info-rate": "100000",
95 "committed-burst-size": "64"
100 "port-device-name": "SPDR-SC1-XPDR1",
101 "port-type": "fixed",
102 "port-name": "XPDR1-NETWORK1",
103 "port-rack": "000000.00",
104 "port-shelf": "Chassis#1"
107 "lgx-device-name": "Some lgx-device-name",
108 "lgx-port-name": "Some lgx-port-name",
109 "lgx-port-rack": "000000.00",
110 "lgx-port-shelf": "00"
115 "port-device-name": "SPDR-SC1-XPDR1",
116 "port-type": "fixed",
117 "port-name": "XPDR1-NETWORK1",
118 "port-rack": "000000.00",
119 "port-shelf": "Chassis#1"
122 "lgx-device-name": "Some lgx-device-name",
123 "lgx-port-name": "Some lgx-port-name",
124 "lgx-port-rack": "000000.00",
125 "lgx-port-shelf": "00"
130 "due-date": "2018-06-15T00:00:01Z",
131 "operator-contact": "pw1234"
137 cls.init_failed = False
138 os.environ['JAVA_MIN_MEM'] = '1024M'
139 os.environ['JAVA_MAX_MEM'] = '4096M'
140 cls.processes = test_utils.start_tpce()
141 # TAPI feature is not installed by default in Karaf
142 if "USE_LIGHTY" not in os.environ or os.environ['USE_LIGHTY'] != 'True':
143 print("installing tapi feature...")
144 result = test_utils.install_karaf_feature("odl-transportpce-tapi")
145 if result.returncode != 0:
146 cls.init_failed = True
147 print("Restarting OpenDaylight...")
148 test_utils.shutdown_process(cls.processes[0])
149 cls.processes[0] = test_utils.start_karaf()
150 test_utils.process_list[0] = cls.processes[0]
151 cls.init_failed = not test_utils.wait_until_log_contains(
152 test_utils.KARAF_LOG, test_utils.KARAF_OK_START_MSG, time_to_wait=60)
154 print("tapi installation feature failed...")
155 test_utils.shutdown_process(cls.processes[0])
157 cls.processes = test_utils.start_sims(['xpdra', 'roadma', 'roadmb', 'roadmc', 'xpdrc', 'spdra', 'spdrc'])
160 def tearDownClass(cls):
161 # pylint: disable=not-an-iterable
162 for process in cls.processes:
163 test_utils.shutdown_process(process)
164 print("all processes killed")
166 def setUp(self): # instruction executed before each test method
168 self.fail('Feature installation failed')
169 print("execution of {}".format(self.id().split(".")[-1]))
171 def test_01_get_tapi_topology_T100G(self):
172 url = "{}/operations/tapi-topology:get-topology-details"
174 "tapi-topology:input": {
175 "tapi-topology:topology-id-or-name": "Transponder 100GE"
178 response = test_utils.post_request(url, data)
179 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
180 res = response.json()
181 self.assertEqual(len(res["output"]["topology"]["node"]), 1, 'Topology should contain 1 node')
182 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
183 self.assertNotIn("owned-node-edge-point", res["output"]["topology"]["node"][0],
184 'Node should contain no owned-node-edge-points')
185 self.assertEqual("Tpdr100g over WDM node", res["output"]["topology"]["node"][0]["name"][0]["value"],
186 'node name should be: Tpdr100g over WDM node')
187 self.assertIn("ETH", res["output"]["topology"]["node"][0]["layer-protocol-name"],
188 'Node layer protocol should contain ETH')
189 self.assertEqual(1, len(res["output"]["topology"]["node"][0]["node-rule-group"]),
190 'node should contain 1 node rule group')
192 def test_02_get_tapi_topology_T0(self):
193 url = "{}/operations/tapi-topology:get-topology-details"
195 "tapi-topology:input": {
196 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
199 response = test_utils.post_request(url, data)
200 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
201 res = response.json()
202 self.assertNotIn("node", res["output"]["topology"], 'Topology should contain no node')
203 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
205 def test_03_connect_rdmb(self):
206 response = test_utils.mount_device("ROADM-B1", 'roadmb')
207 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
210 def test_04_check_tapi_topos(self):
211 url = "{}/operations/tapi-topology:get-topology-details"
213 "tapi-topology:input": {
214 "tapi-topology:topology-id-or-name": "Transponder 100GE"
217 response = test_utils.post_request(url, data)
218 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
219 res = response.json()
220 self.assertEqual(len(res["output"]["topology"]["node"]), 1, 'Topology should contain 1 node')
221 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
223 url = "{}/operations/tapi-topology:get-topology-details"
225 "tapi-topology:input": {
226 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
229 response = test_utils.post_request(url, data)
230 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
231 res = response.json()
232 self.assertNotIn("node", res["output"]["topology"], 'Topology should contain no node')
233 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
235 def test_05_disconnect_roadmb(self):
236 response = test_utils.unmount_device("ROADM-B1")
237 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
240 def test_06_connect_xpdra(self):
241 response = test_utils.mount_device("XPDR-A1", 'xpdra')
242 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
245 def test_07_check_tapi_topos(self):
246 self.test_04_check_tapi_topos()
248 def test_08_connect_rdma(self):
249 response = test_utils.mount_device("ROADM-A1", 'roadma')
250 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
253 def test_09_connect_rdmc(self):
254 response = test_utils.mount_device("ROADM-C1", 'roadmc')
255 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
258 def test_10_check_tapi_topos(self):
259 self.test_01_get_tapi_topology_T100G()
261 url = "{}/operations/tapi-topology:get-topology-details"
263 "tapi-topology:input": {
264 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
267 response = test_utils.post_request(url, data)
268 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
269 res = response.json()
270 self.assertEqual(1, len(res["output"]["topology"]["node"]), 'Topology should contain 1 node')
271 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
272 self.assertEqual("ROADM-infra", res["output"]["topology"]["node"][0]["name"][0]["value"],
273 'node name should be: ROADM-infra')
274 self.assertIn("PHOTONIC_MEDIA", res["output"]["topology"]["node"][0]["layer-protocol-name"],
275 'Node layer protocol should contain PHOTONIC_MEDIA')
276 self.assertEqual(1, len(res["output"]["topology"]["node"][0]["node-rule-group"]),
277 'node should contain 1 node rule group')
279 def test_11_connect_xprda_n1_to_roadma_pp1(self):
280 response = test_utils.connect_xpdr_to_rdm_request("XPDR-A1", "1", "1",
281 "ROADM-A1", "1", "SRG1-PP1-TXRX")
282 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
283 res = response.json()
284 self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"],
285 CREATED_SUCCESSFULLY)
288 def test_12_connect_roadma_pp1_to_xpdra_n1(self):
289 response = test_utils.connect_rdm_to_xpdr_request("XPDR-A1", "1", "1",
290 "ROADM-A1", "1", "SRG1-PP1-TXRX")
291 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
292 res = response.json()
293 self.assertIn('Roadm Xponder links created successfully', res["output"]["result"],
294 CREATED_SUCCESSFULLY)
297 def test_13_check_tapi_topology_T100G(self):
298 url = "{}/operations/tapi-topology:get-topology-details"
300 "tapi-topology:input": {
301 "tapi-topology:topology-id-or-name": "Transponder 100GE"
304 response = test_utils.post_request(url, data)
305 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
306 res = response.json()
307 self.assertEqual(1, len(res["output"]["topology"]["node"][0]["owned-node-edge-point"]),
308 'Node should contain 1 owned-node-edge-points')
309 self.assertEqual("XPDR1-CLIENT1",
310 res["output"]["topology"]["node"][0]["owned-node-edge-point"][0]["name"][0]["value"],
311 'name of owned-node-edge-points should be XPDR1-CLIENT1')
313 def test_14_check_tapi_topology_T0(self):
314 url = "{}/operations/tapi-topology:get-topology-details"
316 "tapi-topology:input": {
317 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
320 response = test_utils.post_request(url, data)
321 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
322 res = response.json()
323 nodes = res["output"]["topology"]["node"]
324 links = res["output"]["topology"]["link"]
325 self.assertEqual(3, len(nodes), 'Topology should contain 3 nodes')
326 self.assertEqual(2, len(links), 'Topology should contain 2 links')
327 self.assertEqual(2, count_object_with_double_key(nodes, "name", "value-name", "otsi node name"),
328 'Topology should contain 2 otsi nodes')
329 self.assertEqual(1, count_object_with_double_key(nodes, "name", "value-name", "dsr/odu node name"),
330 'Topology should contain 1 dsr node')
331 self.assertEqual(1, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
332 'Topology should contain 1 transitional link')
333 self.assertEqual(1, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
334 'Topology should contain 1 oms link')
336 def test_15_connect_xpdrc(self):
337 response = test_utils.mount_device("XPDR-C1", 'xpdrc')
338 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
341 def test_16_connect_xprdc_n1_to_roadmc_pp1(self):
342 response = test_utils.connect_xpdr_to_rdm_request("XPDR-C1", "1", "1",
343 "ROADM-C1", "1", "SRG1-PP1-TXRX")
344 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
345 res = response.json()
346 self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"],
347 CREATED_SUCCESSFULLY)
350 def test_17_connect_roadmc_pp1_to_xpdrc_n1(self):
351 response = test_utils.connect_rdm_to_xpdr_request("XPDR-C1", "1", "1",
352 "ROADM-C1", "1", "SRG1-PP1-TXRX")
353 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
354 res = response.json()
355 self.assertIn('Roadm Xponder links created successfully', res["output"]["result"],
356 CREATED_SUCCESSFULLY)
359 def test_18_check_tapi_topology_T100G(self):
360 url = "{}/operations/tapi-topology:get-topology-details"
362 "tapi-topology:input": {
363 "tapi-topology:topology-id-or-name": "Transponder 100GE"
366 response = test_utils.post_request(url, data)
367 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
368 res = response.json()
369 self.assertEqual(2, len(res["output"]["topology"]["node"][0]["owned-node-edge-point"]),
370 'Node should contain 2 owned-node-edge-points')
371 self.assertEqual("XPDR1-CLIENT1",
372 res["output"]["topology"]["node"][0]["owned-node-edge-point"][0]["name"][0]["value"],
373 'name of owned-node-edge-points should be XPDR1-CLIENT1')
374 self.assertEqual("XPDR1-CLIENT1",
375 res["output"]["topology"]["node"][0]["owned-node-edge-point"][1]["name"][0]["value"],
376 'name of owned-node-edge-points should be XPDR1-CLIENT1')
378 def test_19_check_tapi_topology_T0(self):
379 url = "{}/operations/tapi-topology:get-topology-details"
381 "tapi-topology:input": {
382 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
385 response = test_utils.post_request(url, data)
386 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
387 res = response.json()
388 nodes = res["output"]["topology"]["node"]
389 links = res["output"]["topology"]["link"]
390 self.assertEqual(5, len(nodes), 'Topology should contain 5 nodes')
391 self.assertEqual(4, len(links), 'Topology should contain 4 links')
392 self.assertEqual(3, count_object_with_double_key(nodes, "name", "value-name", "otsi node name"),
393 'Topology should contain 3 otsi nodes')
394 self.assertEqual(2, count_object_with_double_key(nodes, "name", "value-name", "dsr/odu node name"),
395 'Topology should contain 2 dsr nodes')
396 self.assertEqual(2, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
397 'Topology should contain 2 transitional links')
398 self.assertEqual(2, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
399 'Topology should contain 2 oms links')
401 def test_20_connect_spdr_sa1(self):
402 response = test_utils.mount_device("SPDR-SA1", 'spdra')
403 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
405 # TODO replace connect and disconnect timers with test_utils.wait_until_log_contains
407 def test_21_connect_spdr_sc1(self):
408 response = test_utils.mount_device("SPDR-SC1", 'spdrc')
409 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
411 # TODO replace connect and disconnect timers with test_utils.wait_until_log_contains
413 def test_22_check_tapi_topology_T100G(self):
414 self.test_18_check_tapi_topology_T100G()
416 def test_23_check_tapi_topology_T0(self):
417 self.test_19_check_tapi_topology_T0()
419 def test_24_connect_sprda_n1_to_roadma_pp2(self):
420 response = test_utils.connect_xpdr_to_rdm_request("SPDR-SA1", "1", "1",
421 "ROADM-A1", "1", "SRG1-PP2-TXRX")
422 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
423 res = response.json()
424 self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"],
425 CREATED_SUCCESSFULLY)
428 def test_25_connect_roadma_pp2_to_spdra_n1(self):
429 response = test_utils.connect_rdm_to_xpdr_request("SPDR-SA1", "1", "1",
430 "ROADM-A1", "1", "SRG1-PP2-TXRX")
431 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
432 res = response.json()
433 self.assertIn('Roadm Xponder links created successfully', res["output"]["result"],
434 CREATED_SUCCESSFULLY)
437 def test_26_connect_sprdc_n1_to_roadmc_pp2(self):
438 response = test_utils.connect_xpdr_to_rdm_request("SPDR-SC1", "1", "1",
439 "ROADM-C1", "1", "SRG1-PP2-TXRX")
440 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
441 res = response.json()
442 self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"],
443 CREATED_SUCCESSFULLY)
446 def test_27_connect_roadmc_pp2_to_spdrc_n1(self):
447 response = test_utils.connect_rdm_to_xpdr_request("SPDR-SC1", "1", "1",
448 "ROADM-C1", "1", "SRG1-PP2-TXRX")
449 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
450 res = response.json()
451 self.assertIn('Roadm Xponder links created successfully', res["output"]["result"],
452 CREATED_SUCCESSFULLY)
455 def test_28_check_tapi_topology_T100G(self):
456 self.test_18_check_tapi_topology_T100G()
458 def test_29_check_tapi_topology_T0(self):
459 url = "{}/operations/tapi-topology:get-topology-details"
461 "tapi-topology:input": {
462 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
465 response = test_utils.post_request(url, data)
466 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
467 res = response.json()
468 nodes = res["output"]["topology"]["node"]
469 links = res["output"]["topology"]["link"]
470 self.assertEqual(9, len(nodes), 'Topology should contain 9 nodes')
471 self.assertEqual(8, len(links), 'Topology should contain 8 links')
472 self.assertEqual(5, count_object_with_double_key(nodes, "name", "value-name", "otsi node name"),
473 'Topology should contain 5 otsi nodes')
474 self.assertEqual(4, count_object_with_double_key(nodes, "name", "value-name", "dsr/odu node name"),
475 'Topology should contain 4 dsr nodes')
476 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
477 'Topology should contain 4 transitional links')
478 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
479 'Topology should contain 4 oms links')
481 def test_30_add_oms_attributes(self):
482 # Config ROADMA-ROADMC oms-attributes
485 "auto-spanloss": "true",
486 "spanloss-base": 11.4,
487 "spanloss-current": 12,
488 "engineered-spanloss": 12.2,
489 "link-concatenation": [{
492 "SRLG-length": 100000,
494 response = test_utils.add_oms_attr_request("ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX", data)
495 self.assertEqual(response.status_code, requests.codes.created)
496 # Config ROADMC-ROADMA oms-attributes
499 "auto-spanloss": "true",
500 "spanloss-base": 11.4,
501 "spanloss-current": 12,
502 "engineered-spanloss": 12.2,
503 "link-concatenation": [{
506 "SRLG-length": 100000,
508 response = test_utils.add_oms_attr_request("ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX", data)
509 self.assertEqual(response.status_code, requests.codes.created)
511 def test_31_create_OCH_OTU4_service(self):
512 response = test_utils.service_create_request(self.cr_serv_sample_data)
513 self.assertEqual(response.status_code, requests.codes.ok)
514 res = response.json()
515 self.assertIn('PCE calculation in progress',
516 res['output']['configuration-response-common']['response-message'])
517 time.sleep(self.WAITING)
519 def test_32_check_tapi_topology_T0(self):
520 url = "{}/operations/tapi-topology:get-topology-details"
522 "tapi-topology:input": {
523 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
526 response = test_utils.post_request(url, data)
527 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
528 res = response.json()
529 nodes = res["output"]["topology"]["node"]
530 links = res["output"]["topology"]["link"]
531 self.assertEqual(9, len(nodes), 'Topology should contain 9 nodes')
532 self.assertEqual(9, len(links), 'Topology should contain 9 links')
533 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
534 'Topology should contain 4 transitional links')
535 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
536 'Topology should contain 4 oms links')
537 self.assertEqual(1, count_object_with_double_key(links, "name", "value-name", "otn link name"),
538 'Topology should contain 1 otn link')
540 if link["name"][0]["value"] == "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1":
541 self.assertEqual(100000, link["available-capacity"]["total-size"]["value"],
542 'OTU4 link should have an available capacity of 100 000 Mbps')
543 elif link["name"][0]["value-name"] == "transitional link name":
544 self.assertEqual(100, link["available-capacity"]["total-size"]["value"],
545 'link should have an available capacity of 100 Gbps')
546 self.assertEqual(2, len(link["node-edge-point"]), 'link should have 2 neps')
548 def test_33_create_ODU4_service(self):
549 self.cr_serv_sample_data["input"]["service-name"] = "service1-ODU4"
550 self.cr_serv_sample_data["input"]["service-a-end"]["service-format"] = "ODU"
551 del self.cr_serv_sample_data["input"]["service-a-end"]["otu-service-rate"]
552 self.cr_serv_sample_data["input"]["service-a-end"]["odu-service-rate"] = "org-openroadm-otn-common-types:ODU4"
553 self.cr_serv_sample_data["input"]["service-z-end"]["service-format"] = "ODU"
554 del self.cr_serv_sample_data["input"]["service-z-end"]["otu-service-rate"]
555 self.cr_serv_sample_data["input"]["service-z-end"]["odu-service-rate"] = "org-openroadm-otn-common-types:ODU4"
557 response = test_utils.service_create_request(self.cr_serv_sample_data)
558 self.assertEqual(response.status_code, requests.codes.ok)
559 res = response.json()
560 self.assertIn('PCE calculation in progress',
561 res['output']['configuration-response-common']['response-message'])
562 time.sleep(self.WAITING)
564 def test_34_check_tapi_topology_T0(self):
565 url = "{}/operations/tapi-topology:get-topology-details"
567 "tapi-topology:input": {
568 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
571 response = test_utils.post_request(url, data)
572 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
573 res = response.json()
574 nodes = res["output"]["topology"]["node"]
575 links = res["output"]["topology"]["link"]
576 self.assertEqual(9, len(nodes), 'Topology should contain 9 nodes')
577 self.assertEqual(10, len(links), 'Topology should contain 10 links')
578 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
579 'Topology should contain 4 transitional links')
580 self.assertEqual(4, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
581 'Topology should contain 4 oms links')
582 self.assertEqual(2, count_object_with_double_key(links, "name", "value-name", "otn link name"),
583 'Topology should contain 2 otn links')
585 if link["name"][0]["value"] == "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1":
586 self.assertEqual(0, link["available-capacity"]["total-size"]["value"],
587 'OTU4 link should have an available capacity of 0 Mbps')
588 elif link["name"][0]["value"] == "ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1":
589 self.assertEqual(100000, link["available-capacity"]["total-size"]["value"],
590 'ODU4 link should have an available capacity of 100 000 Mbps')
591 elif link["name"][0]["value-name"] == "transitional link name":
592 self.assertEqual(100, link["available-capacity"]["total-size"]["value"],
593 'link should have an available capacity of 100 Gbps')
594 self.assertEqual(2, len(link["node-edge-point"]), 'link should have 2 neps')
596 def test_35_connect_sprda_2_n2_to_roadma_pp3(self):
597 response = test_utils.connect_xpdr_to_rdm_request("SPDR-SA1", "2", "2",
598 "ROADM-A1", "1", "SRG1-PP3-TXRX")
599 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
600 res = response.json()
601 self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"],
602 CREATED_SUCCESSFULLY)
605 def test_36_connect_roadma_pp3_to_spdra_2_n2(self):
606 response = test_utils.connect_rdm_to_xpdr_request("SPDR-SA1", "2", "2",
607 "ROADM-A1", "1", "SRG1-PP3-TXRX")
608 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
609 res = response.json()
610 self.assertIn('Roadm Xponder links created successfully', res["output"]["result"],
611 CREATED_SUCCESSFULLY)
614 def test_37_check_tapi_topology_T0(self):
615 url = "{}/operations/tapi-topology:get-topology-details"
617 "tapi-topology:input": {
618 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
621 response = test_utils.post_request(url, data)
622 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
623 res = response.json()
624 nodes = res["output"]["topology"]["node"]
625 links = res["output"]["topology"]["link"]
626 self.assertEqual(11, len(nodes), 'Topology should contain 11 nodes')
627 self.assertEqual(12, len(links), 'Topology should contain 12 links')
628 self.assertEqual(6, count_object_with_double_key(nodes, "name", "value-name", "otsi node name"),
629 'Topology should contain 6 otsi nodes')
630 self.assertEqual(5, count_object_with_double_key(nodes, "name", "value-name", "dsr/odu node name"),
631 'Topology should contain 5 dsr nodes')
632 self.assertEqual(5, count_object_with_double_key(links, "name", "value-name", "transitional link name"),
633 'Topology should contain 5 transitional links')
634 self.assertEqual(5, count_object_with_double_key(links, "name", "value-name", "OMS link name"),
635 'Topology should contain 5 oms links')
636 self.assertEqual(2, count_object_with_double_key(links, "name", "value-name", "otn link name"),
637 'Topology should contain 2 otn links')
639 def test_38_delete_ODU4_service(self):
640 response = test_utils.service_delete_request("service1-ODU4")
641 self.assertEqual(response.status_code, requests.codes.ok)
642 res = response.json()
643 self.assertIn('Renderer service delete in progress',
644 res['output']['configuration-response-common']['response-message'])
647 def test_39_delete_OCH_OTU4_service(self):
648 response = test_utils.service_delete_request("service1-OCH-OTU4")
649 self.assertEqual(response.status_code, requests.codes.ok)
650 res = response.json()
651 self.assertIn('Renderer service delete in progress',
652 res['output']['configuration-response-common']['response-message'])
655 def test_40_check_tapi_topology_T0(self):
656 url = "{}/operations/tapi-topology:get-topology-details"
658 "tapi-topology:input": {
659 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
662 response = test_utils.post_request(url, data)
663 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
664 res = response.json()
665 nodes = res["output"]["topology"]["node"]
666 links = res["output"]["topology"]["link"]
667 self.assertEqual(11, len(nodes), 'Topology should contain 11 nodes')
668 self.assertEqual(10, len(links), 'Topology should contain 10 links')
669 self.assertEqual(0, count_object_with_double_key(links, "name", "value-name", "otn link name"),
670 'Topology should contain 0 otn link')
672 def test_41_disconnect_xponders_from_roadm(self):
673 url = "{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:link/"
674 response = test_utils.get_ordm_topo_request("")
675 self.assertEqual(response.status_code, requests.codes.ok)
676 res = response.json()
677 links = res['network'][0]['ietf-network-topology:link']
679 if (link["org-openroadm-common-network:link-type"] == "XPONDER-OUTPUT" or
680 link["org-openroadm-common-network:link-type"] == "XPONDER-INPUT"):
681 link_name = link["link-id"]
682 response = test_utils.delete_request(url+link_name)
683 self.assertEqual(response.status_code, requests.codes.ok)
685 def test_42_check_tapi_topology_T0(self):
686 url = "{}/operations/tapi-topology:get-topology-details"
688 "tapi-topology:input": {
689 "tapi-topology:topology-id-or-name": "T0 - Multi-layer topology"
692 response = test_utils.post_request(url, data)
693 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
694 res = response.json()
695 nodes = res["output"]["topology"]["node"]
696 self.assertEqual(1, len(nodes), 'Topology should contain 1 node')
697 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
698 self.assertEqual("ROADM-infra", res["output"]["topology"]["node"][0]["name"][0]["value"],
699 'node name should be: ROADM-infra')
701 def test_43_get_tapi_topology_T100G(self):
702 url = "{}/operations/tapi-topology:get-topology-details"
704 "tapi-topology:input": {
705 "tapi-topology:topology-id-or-name": "Transponder 100GE"
708 response = test_utils.post_request(url, data)
709 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
710 res = response.json()
711 self.assertEqual(len(res["output"]["topology"]["node"]), 1, 'Topology should contain 1 node')
712 self.assertNotIn("link", res["output"]["topology"], 'Topology should contain no link')
713 self.assertNotIn("owned-node-edge-point", res["output"]["topology"]["node"][0],
714 'Node should contain no owned-node-edge-points')
716 def test_44_disconnect_roadma(self):
717 response = test_utils.unmount_device("ROADM-A1")
718 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
721 def test_45_disconnect_roadmc(self):
722 response = test_utils.unmount_device("ROADM-C1")
723 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
726 def test_46_check_tapi_topos(self):
727 self.test_01_get_tapi_topology_T100G()
728 self.test_02_get_tapi_topology_T0()
730 def test_47_disconnect_xpdra(self):
731 response = test_utils.unmount_device("XPDR-A1")
732 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
735 def test_48_disconnect_xpdrc(self):
736 response = test_utils.unmount_device("XPDR-C1")
737 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
740 def test_49_disconnect_spdr_sa1(self):
741 response = test_utils.unmount_device("SPDR-SA1")
742 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
745 def test_50_disconnect_spdr_sc1(self):
746 response = test_utils.unmount_device("SPDR-SC1")
747 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
750 def find_object_with_key(list_dicts, key, value):
751 for dict_ in list_dicts:
752 if dict_[key] == value:
756 def count_object_with_double_key(list_dicts, key1, key2, value):
758 for dict in list_dicts:
759 if dict[key1][0][key2] == value:
764 if __name__ == "__main__":
765 unittest.main(verbosity=2)