X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F1.2.1%2Ftest_gnpy.py;h=57d8935bdb62421ac93a161183ab7a8f222bf0cc;hb=c834356f10cb8bc04c8b0a9eb2a438b2e9c50632;hp=0a77c0ff9c0d4c915d14288346f0af68a85a4a9e;hpb=82ae34c05bd194c26ef4e30b2bdf1cf19093e19b;p=transportpce.git diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 0a77c0ff9..57d8935bd 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -17,7 +17,8 @@ import os import sys import time import requests -from common import test_utils +sys.path.append('transportpce_tests/common/') +import test_utils class TransportGNPYtesting(unittest.TestCase): @@ -25,10 +26,12 @@ class TransportGNPYtesting(unittest.TestCase): topo_cllinet_data = None topo_ordnet_data = None topo_ordtopo_data = None + port_mapping_data = None processes = None @classmethod def setUpClass(cls): + # pylint: disable=bare-except try: sample_files_parsed = False TOPO_CLLINET_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), @@ -45,6 +48,10 @@ class TransportGNPYtesting(unittest.TestCase): "..", "..", "sample_configs", "gnpy", "openroadmTopology.json") with open(TOPO_ORDTOPO_FILE, 'r') as topo_ordtopo: cls.topo_ordtopo_data = topo_ordtopo.read() + PORT_MAPPING_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), + "..", "..", "sample_configs", "gnpy", "gnpy_portmapping_121.json") + with open(PORT_MAPPING_FILE, 'r') as port_mapping: + cls.port_mapping_data = port_mapping.read() sample_files_parsed = True except PermissionError as err: print("Permission Error when trying to read sample files\n", err) @@ -63,6 +70,7 @@ class TransportGNPYtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -70,6 +78,12 @@ class TransportGNPYtesting(unittest.TestCase): def setUp(self): time.sleep(2) + # Load port mapping + def test_00_load_port_mapping(self): + response = test_utils.rawpost_request(test_utils.URL_FULL_PORTMAPPING, self.port_mapping_data) + self.assertEqual(response.status_code, requests.codes.no_content) + time.sleep(2) + # Mount the different topologies def test_01_connect_clliNetwork(self): response = test_utils.rawput_request(test_utils.URL_CONFIG_CLLI_NET, self.topo_cllinet_data) @@ -100,12 +114,12 @@ class TransportGNPYtesting(unittest.TestCase): self.assertEqual(res['output']['configuration-response-common'][ 'response-message'], 'Path is calculated by PCE') - self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], - 'A-to-Z') - self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True) self.assertEqual(res['output']['gnpy-response'][1]['path-dir'], - 'Z-to-A') + 'A-to-Z') self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True) + self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], + 'Z-to-A') + self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True) time.sleep(5) # Path computed by PCE is not feasible by GNPy and GNPy cannot find @@ -128,13 +142,13 @@ class TransportGNPYtesting(unittest.TestCase): self.assertEqual(res['output']['configuration-response-common'][ 'response-message'], 'No path available by PCE and GNPy ') - self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], + self.assertEqual(res['output']['gnpy-response'][1]['path-dir'], 'A-to-Z') - self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], + self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], False) - self.assertEqual(res['output']['gnpy-response'][1]['path-dir'], + self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], 'Z-to-A') - self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], + self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], False) time.sleep(5) @@ -156,12 +170,12 @@ class TransportGNPYtesting(unittest.TestCase): self.assertEqual(res['output']['configuration-response-common'][ 'response-message'], 'Path is calculated by GNPy') - self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], - 'A-to-Z') - self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True) self.assertEqual(res['output']['gnpy-response'][1]['path-dir'], - 'Z-to-A') + 'A-to-Z') self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True) + self.assertEqual(res['output']['gnpy-response'][0]['path-dir'], + 'Z-to-A') + self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True) time.sleep(5) # Not found path by PCE and GNPy cannot find another one @@ -202,6 +216,11 @@ class TransportGNPYtesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) + # Delete portmapping + def test_11_delete_port_mapping(self): + response = test_utils.delete_request(test_utils.URL_FULL_PORTMAPPING) + self.assertEqual(response.status_code, requests.codes.ok) + time.sleep(2) if __name__ == "__main__": # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)