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 resTopo = test_utils_rfc8040.get_ietf_network_request('openroadm-topology', 'config')
54 self.assertEqual(resTopo['status_code'], requests.codes.ok)
57 for val in resTopo['network'][0]['node']:
58 nodeId = val['node-id']
59 # pylint: disable=consider-using-f-string
60 print("nodeId={}".format(nodeId))
61 nodeMapId = nodeId.split("-")[0] + "-" + nodeId.split("-")[1]
62 print("nodeMapId={}".format(nodeMapId))
63 response = test_utils_rfc8040.get_portmapping_node_info(nodeMapId)
64 self.assertEqual(response['status_code'], requests.codes.ok)
65 responseMapList = test_utils_rfc8040.get_portmapping(nodeMapId)
66 nbMappings = len(responseMapList['nodes'][0]['mapping']) - nbMapCumul
68 for val2 in val['ietf-network-topology:termination-point']:
70 if (not "CP" in tpId) and (not "CTP" in tpId):
71 responseMap = test_utils_rfc8040.portmapping_request(nodeMapId, tpId)
72 self.assertEqual(responseMap['status_code'], requests.codes.ok)
73 if responseMap['status_code'] == requests.codes.ok:
75 nbMapCumul += nbMapCurrent
76 nbMappings -= nbMapCurrent
77 self.assertEqual(nbMappings, 0)
79 # Disconnect the ROADMA
80 def test_03_disconnect_rdm(self):
81 response = test_utils_rfc8040.unmount_device("ROADM-A1")
82 self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
85 def test_04_connect_xpdr(self):
86 response = test_utils_rfc8040.mount_device("XPDR-A1", ('xpdra', self.NODE_VERSION))
87 self.assertEqual(response.status_code, requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201)
89 # #Verify the termination points related to XPDR
90 def test_05_compareOpenroadmTopologyPortMapping_xpdr(self):
91 self.test_02_compareOpenroadmTopologyPortMapping_rdm()
93 # Disconnect the XPDRA
94 def test_06_disconnect_device(self):
95 response = test_utils_rfc8040.unmount_device("XPDR-A1")
96 self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
99 if __name__ == "__main__":
100 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
101 #logging.debug('I am there')
102 unittest.main(verbosity=2)