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 ##############################################################################
12 # pylint: disable=no-member
13 # pylint: disable=too-many-public-methods
18 # pylint: disable=wrong-import-order
20 sys.path.append('transportpce_tests/common/')
21 # pylint: disable=wrong-import-position
22 # pylint: disable=import-error
23 import test_utils_rfc8040 # nopep8
26 class TransportPCEtesting(unittest.TestCase):
29 NODE_VERSION = '2.2.1'
33 cls.processes = test_utils_rfc8040.start_tpce()
34 cls.processes = test_utils_rfc8040.start_sims([('xpdra', cls.NODE_VERSION), ('roadma', cls.NODE_VERSION)])
37 def tearDownClass(cls):
38 # pylint: disable=not-an-iterable
39 for process in cls.processes:
40 test_utils_rfc8040.shutdown_process(process)
41 print("all processes killed")
47 def test_01_connect_rdm(self):
48 response = test_utils_rfc8040.mount_device("ROADM-A1", ('roadma', self.NODE_VERSION))
49 self.assertEqual(response.status_code, requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201)
51 # Verify the termination points of the ROADMA
52 def test_02_compareOpenroadmTopologyPortMapping_rdm(self):
53 responseTopo = test_utils_rfc8040.get_request(test_utils_rfc8040.URL_CONFIG_ORDM_TOPO)
54 resTopo = responseTopo.json()
55 firstEntry = resTopo['ietf-network:network'][0]['node']
58 for i in range(0, len(firstEntry)):
59 nodeId = firstEntry[i]['node-id']
60 # pylint: disable=consider-using-f-string
61 print("nodeId={}".format(nodeId))
62 nodeMapId = nodeId.split("-")[0] + "-" + nodeId.split("-")[1]
63 print("nodeMapId={}".format(nodeMapId))
64 response = test_utils_rfc8040.get_portmapping_node_info(nodeMapId)
65 self.assertEqual(response['status_code'], requests.codes.ok)
66 responseMapList = test_utils_rfc8040.get_portmapping(nodeMapId)
67 nbMappings = len(responseMapList['nodes'][0]['mapping']) - nbMapCumul
68 nbTp = len(firstEntry[i]['ietf-network-topology:termination-point'])
70 for j in range(0, nbTp):
71 tpId = firstEntry[i]['ietf-network-topology:termination-point'][j]['tp-id']
72 if (not "CP" in tpId) and (not "CTP" in tpId):
73 responseMap = test_utils_rfc8040.portmapping_request(nodeMapId, tpId)
74 self.assertEqual(responseMap['status_code'], requests.codes.ok)
75 if responseMap['status_code'] == requests.codes.ok:
77 nbMapCumul += nbMapCurrent
78 nbMappings -= nbMapCurrent
79 self.assertEqual(nbMappings, 0)
81 # Disconnect the ROADMA
82 def test_03_disconnect_rdm(self):
83 response = test_utils_rfc8040.unmount_device("ROADM-A1")
84 self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
87 def test_04_connect_xpdr(self):
88 response = test_utils_rfc8040.mount_device("XPDR-A1", ('xpdra', self.NODE_VERSION))
89 self.assertEqual(response.status_code, requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201)
91 # #Verify the termination points related to XPDR
92 def test_05_compareOpenroadmTopologyPortMapping_xpdr(self):
93 self.test_02_compareOpenroadmTopologyPortMapping_rdm()
95 # Disconnect the XPDRA
96 def test_06_disconnect_device(self):
97 response = test_utils_rfc8040.unmount_device("XPDR-A1")
98 self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
101 if __name__ == "__main__":
102 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
103 #logging.debug('I am there')
104 unittest.main(verbosity=2)