Code Review
/
transportpce.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Change way to start simulators
[transportpce.git]
/
tests
/
transportpce_tests
/
1.2.1
/
test_gnpy.py
diff --git
a/tests/transportpce_tests/1.2.1/test_gnpy.py
b/tests/transportpce_tests/1.2.1/test_gnpy.py
index 0a77c0ff9c0d4c915d14288346f0af68a85a4a9e..57d8935bdb62421ac93a161183ab7a8f222bf0cc 100644
(file)
--- 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
import sys
import time
import requests
-from common import test_utils
+sys.path.append('transportpce_tests/common/')
+import test_utils
class TransportGNPYtesting(unittest.TestCase):
class TransportGNPYtesting(unittest.TestCase):
@@
-25,10
+26,12
@@
class TransportGNPYtesting(unittest.TestCase):
topo_cllinet_data = None
topo_ordnet_data = None
topo_ordtopo_data = None
topo_cllinet_data = None
topo_ordnet_data = None
topo_ordtopo_data = None
+ port_mapping_data = None
processes = None
@classmethod
def setUpClass(cls):
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__)),
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()
"..", "..", "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)
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):
@classmethod
def tearDownClass(cls):
+ # pylint: disable=not-an-iterable
for process in cls.processes:
test_utils.shutdown_process(process)
print("all processes killed")
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)
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)
# 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']['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'],
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'][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
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']['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')
'A-to-Z')
- self.assertEqual(res['output']['gnpy-response'][
0
]['feasibility'],
+ self.assertEqual(res['output']['gnpy-response'][
1
]['feasibility'],
False)
False)
- self.assertEqual(res['output']['gnpy-response'][
1
]['path-dir'],
+ self.assertEqual(res['output']['gnpy-response'][
0
]['path-dir'],
'Z-to-A')
'Z-to-A')
- self.assertEqual(res['output']['gnpy-response'][
1
]['feasibility'],
+ self.assertEqual(res['output']['gnpy-response'][
0
]['feasibility'],
False)
time.sleep(5)
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']['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'],
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'][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
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)
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)
if __name__ == "__main__":
# logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)