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 ##############################################################################
15 from common import test_utils
18 class TransportPCEtesting(unittest.TestCase):
24 cls.processes = test_utils.start_tpce()
25 cls.processes = test_utils.start_sims(['xpdra', 'roadma'])
28 def tearDownClass(cls):
29 for process in cls.processes:
30 test_utils.shutdown_process(process)
31 print("all processes killed")
37 def test_01_connect_rdm(self):
38 response = test_utils.mount_device("ROADMA01", 'roadma')
39 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
41 # Verify the termination points of the ROADMA
42 def test_02_compareOpenroadmTopologyPortMapping_rdm(self):
43 urlTopo = "{}/config/ietf-network:networks/network/openroadm-topology"
44 responseTopo = test_utils.get_request(urlTopo)
45 resTopo = responseTopo.json()
46 nbNode = len(resTopo['network'][0]['node'])
49 for i in range(0, nbNode):
50 nodeId = resTopo['network'][0]['node'][i]['node-id']
51 nodeMapId = nodeId.split("-")[0]
52 urlMapList = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId
53 responseMapList = test_utils.get_request(urlMapList)
54 resMapList = responseMapList.json()
55 nbMappings = len(resMapList['nodes'][0]['mapping']) - nbMapCumul
56 nbTp = len(resTopo['network'][0]['node'][i]['ietf-network-topology:termination-point'])
58 for j in range(0, nbTp):
59 tpId = resTopo['network'][0]['node'][i]['ietf-network-topology:termination-point'][j]['tp-id']
60 if((not "CP" in tpId) and (not "CTP" in tpId)):
61 urlMap = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId + "/mapping/" + tpId
62 responseMap = test_utils.get_request(urlMap)
64 # Disconnect the ROADMA
65 def test_03_disconnect_rdm(self):
66 response = test_utils.unmount_device("ROADMA01")
67 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
70 def test_04_connect_xpdr(self):
71 response = test_utils.mount_device("XPDRA01", 'xpdra')
72 self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
74 # #Verify the termination points related to XPDR
75 def test_05_compareOpenroadmTopologyPortMapping_xpdr(self):
76 self.test_02_compareOpenroadmTopologyPortMapping_rdm()
78 # Disconnect the XPDRA
79 def test_06_disconnect_device(self):
80 response = test_utils.unmount_device("XPDRA01")
81 self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
84 if __name__ == "__main__":
85 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
86 #logging.debug('I am there')
87 unittest.main(verbosity=2)