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
20 from common import test_utils
23 class TransportGNPYtesting(unittest.TestCase):
25 topo_cllinet_data = None
26 topo_ordnet_data = None
27 topo_ordtopo_data = None
32 # pylint: disable=bare-except
34 sample_files_parsed = False
35 TOPO_CLLINET_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
36 "..", "..", "sample_configs", "gnpy", "clliNetwork.json")
37 with open(TOPO_CLLINET_FILE, 'r') as topo_cllinet:
38 cls.topo_cllinet_data = topo_cllinet.read()
40 TOPO_ORDNET_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
41 "..", "..", "sample_configs", "gnpy", "openroadmNetwork.json")
42 with open(TOPO_ORDNET_FILE, 'r') as topo_ordnet:
43 cls.topo_ordnet_data = topo_ordnet.read()
45 TOPO_ORDTOPO_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
46 "..", "..", "sample_configs", "gnpy", "openroadmTopology.json")
47 with open(TOPO_ORDTOPO_FILE, 'r') as topo_ordtopo:
48 cls.topo_ordtopo_data = topo_ordtopo.read()
49 sample_files_parsed = True
50 except PermissionError as err:
51 print("Permission Error when trying to read sample files\n", err)
53 except FileNotFoundError as err:
54 print("File Not found Error when trying to read sample files\n", err)
57 print("Unexpected error when trying to read sample files\n", sys.exc_info()[0])
60 if sample_files_parsed:
61 print("sample files content loaded")
63 cls.processes = test_utils.start_tpce()
66 def tearDownClass(cls):
67 # pylint: disable=not-an-iterable
68 for process in cls.processes:
69 test_utils.shutdown_process(process)
70 print("all processes killed")
75 # Mount the different topologies
76 def test_01_connect_clliNetwork(self):
77 response = test_utils.rawput_request(test_utils.URL_CONFIG_CLLI_NET, self.topo_cllinet_data)
78 self.assertEqual(response.status_code, requests.codes.ok)
81 def test_02_connect_openroadmNetwork(self):
82 response = test_utils.rawput_request(test_utils.URL_CONFIG_ORDM_NET, self.topo_ordnet_data)
83 self.assertEqual(response.status_code, requests.codes.ok)
86 def test_03_connect_openroadmTopology(self):
87 response = test_utils.rawput_request(test_utils.URL_CONFIG_ORDM_TOPO, self.topo_ordtopo_data)
88 self.assertEqual(response.status_code, requests.codes.ok)
91 # Path computed by PCE is feasible according to Gnpy
92 def test_04_path_computation_FeasibleWithPCE(self):
93 response = test_utils.path_computation_request("request-1", "service-1",
94 {"node-id": "XPONDER-1", "service-rate": "100",
95 "service-format": "Ethernet", "clli": "Node1"},
96 {"node-id": "XPONDER-5", "service-rate": "100",
97 "service-format": "Ethernet", "clli": "Node5"})
98 self.assertEqual(response.status_code, requests.codes.ok)
100 self.assertEqual(res['output']['configuration-response-common'][
101 'response-code'], '200')
102 self.assertEqual(res['output']['configuration-response-common'][
104 'Path is calculated by PCE')
105 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
107 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
108 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
110 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
113 # Path computed by PCE is not feasible by GNPy and GNPy cannot find
114 # another one (low SNR)
115 def test_05_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
116 response = test_utils.path_computation_request("request-2", "service-2",
117 {"node-id": "XPONDER-1", "service-rate": "100",
118 "service-format": "Ethernet", "clli": "Node1"},
119 {"node-id": "XPONDER-5", "service-rate": "100",
120 "service-format": "Ethernet", "clli": "Node5"},
121 {"include_": {"ordered-hops": [
122 {"hop-number": "0", "hop-type": {"node-id": "OpenROADM-2"}},
123 {"hop-number": "1", "hop-type": {"node-id": "OpenROADM-3"}},
124 {"hop-number": "2", "hop-type": {"node-id": "OpenROADM-4"}}]}
126 self.assertEqual(response.status_code, requests.codes.ok)
127 res = response.json()
128 self.assertEqual(res['output']['configuration-response-common'][
129 'response-code'], '500')
130 self.assertEqual(res['output']['configuration-response-common'][
132 'No path available by PCE and GNPy ')
133 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
135 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'],
137 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
139 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'],
143 # #PCE cannot find a path while GNPy finds a feasible one
144 def test_06_path_computation_NotFoundByPCE_FoundByGNPy(self):
145 response = test_utils.path_computation_request("request-3", "service-3",
146 {"node-id": "XPONDER-1", "service-rate": "100",
147 "service-format": "Ethernet", "clli": "Node1"},
148 {"node-id": "XPONDER-4", "service-rate": "100",
149 "service-format": "Ethernet", "clli": "Node5"},
150 {"include_": {"ordered-hops": [
151 {"hop-number": "0", "hop-type": {"node-id": "OpenROADM-2"}},
152 {"hop-number": "1", "hop-type": {"node-id": "OpenROADM-3"}}]}
154 self.assertEqual(response.status_code, requests.codes.ok)
155 res = response.json()
156 self.assertEqual(res['output']['configuration-response-common'][
157 'response-code'], '200')
158 self.assertEqual(res['output']['configuration-response-common'][
160 'Path is calculated by GNPy')
161 self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
163 self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
164 self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
166 self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
169 # Not found path by PCE and GNPy cannot find another one
170 def test_07_path_computation_FoundByPCE_NotFeasibleByGnpy(self):
171 response = test_utils.path_computation_request("request-4", "service-4",
172 {"node-id": "XPONDER-1", "service-rate": "100",
173 "service-format": "Ethernet", "clli": "Node1"},
174 {"node-id": "XPONDER-4", "service-rate": "100",
175 "service-format": "Ethernet", "clli": "Node5"},
176 {"include_": {"ordered-hops": [
177 {"hop-number": "0", "hop-type": {"node-id": "OpenROADM-2"}},
178 {"hop-number": "1", "hop-type": {"node-id": "OpenROADM-3"}},
179 {"hop-number": "2", "hop-type": {"node-id": "OpenROADM-4"}},
180 {"hop-number": "3", "hop-type": {"node-id": "OpenROADM-3"}}]}
182 self.assertEqual(response.status_code, requests.codes.ok)
183 res = response.json()
184 self.assertEqual(res['output']['configuration-response-common'][
185 'response-code'], '500')
186 self.assertEqual(res['output']['configuration-response-common'][
188 'No path available by PCE and GNPy ')
191 # Disconnect the different topologies
192 def test_08_disconnect_openroadmTopology(self):
193 response = test_utils.delete_request(test_utils.URL_CONFIG_ORDM_TOPO)
194 self.assertEqual(response.status_code, requests.codes.ok)
197 def test_09_disconnect_openroadmNetwork(self):
198 response = test_utils.delete_request(test_utils.URL_CONFIG_ORDM_NET)
199 self.assertEqual(response.status_code, requests.codes.ok)
202 def test_10_disconnect_clliNetwork(self):
203 response = test_utils.delete_request(test_utils.URL_CONFIG_CLLI_NET)
204 self.assertEqual(response.status_code, requests.codes.ok)
208 if __name__ == "__main__":
209 # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
210 unittest.main(verbosity=2)