From: guillaume.lambert Date: Mon, 15 Jun 2020 11:05:16 +0000 (+0200) Subject: rationalize functional tests sims starters X-Git-Tag: 2.0.0~86^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=f9bb9e323c48640b14908cbc4101c2ad41b1de60 rationalize functional tests sims starters in test_utils.py: - centralize sims ports and config/log files in one associative array - based on this, use one method start_sim(sim) for every sims - remove obsolete dedicated-per-sim methods - centralize messages printed at sims and tpce start-up in tests files - replace harcoded port values by the corresponding array value - replace the term "honeynode" by "sim" which is more generic - remove obsolete sims timers in 2.2.1 tests Signed-off-by: guillaume.lambert Change-Id: I99c29be7cfcccbce28748cf79ddcf40d148641ef --- diff --git a/tests/transportpce_tests/1.2.1/test_end2end.py b/tests/transportpce_tests/1.2.1/test_end2end.py index cacde4386..3fad3d284 100644 --- a/tests/transportpce_tests/1.2.1/test_end2end.py +++ b/tests/transportpce_tests/1.2.1/test_end2end.py @@ -22,10 +22,10 @@ import test_utils class TransportPCEFulltesting(unittest.TestCase): headers = {'content-type': 'application/json'} odl_process = None - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None restconf_baseurl = "http://localhost:8181/restconf" WAITING = 20 # nominal value is 300 @@ -33,24 +33,19 @@ class TransportPCEFulltesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_full_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma-full') time.sleep(20) - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_full_honeynode() + cls.sim_process3 = test_utils.start_sim('roadmc-full') time.sleep(20) - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() + cls.sim_process4 = test_utils.start_sim('xpdrc') time.sleep(20) - print("all honeynodes started") + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(80) print("opendaylight started") @@ -62,26 +57,26 @@ class TransportPCEFulltesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() print("all processes killed") def setUp(self): # instruction executed before each test method @@ -99,7 +94,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -118,7 +113,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17834", + "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -137,7 +132,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17821", + "netconf-node-topology:port": test_utils.sims['roadma-full']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -156,7 +151,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17823", + "netconf-node-topology:port": test_utils.sims['roadmc-full']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 6fbe52ffd..64a88194a 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -32,7 +32,6 @@ class TransportGNPYtesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(30) print("opendaylight started") diff --git a/tests/transportpce_tests/1.2.1/test_olm.py b/tests/transportpce_tests/1.2.1/test_olm.py index a6059ecb3..956305635 100644 --- a/tests/transportpce_tests/1.2.1/test_olm.py +++ b/tests/transportpce_tests/1.2.1/test_olm.py @@ -24,10 +24,10 @@ import test_utils class TransportOlmTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -35,24 +35,19 @@ class TransportOlmTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_full_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma-full') time.sleep(20) - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_full_honeynode() + cls.sim_process3 = test_utils.start_sim('roadmc-full') time.sleep(20) - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() + cls.sim_process4 = test_utils.start_sim('xpdrc') time.sleep(20) - print("all honeynodes started") + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -64,26 +59,26 @@ class TransportOlmTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -100,7 +95,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -119,7 +114,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17834", + "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -138,7 +133,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17821", + "netconf-node-topology:port": test_utils.sims['roadma-full']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -157,7 +152,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17823", + "netconf-node-topology:port": test_utils.sims['roadmc-full']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_pce.py b/tests/transportpce_tests/1.2.1/test_pce.py index f97dda23a..5375dabc7 100644 --- a/tests/transportpce_tests/1.2.1/test_pce.py +++ b/tests/transportpce_tests/1.2.1/test_pce.py @@ -46,7 +46,6 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def setUpClass(cls): # a class method called before tests in an individual class run. cls._get_file() - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(90) print("opendaylight started") diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index 301d74558..bf42eb9d5 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -20,8 +20,8 @@ import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -29,15 +29,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma') time.sleep(20) - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -49,16 +46,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -97,7 +94,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17831", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -190,7 +187,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py index 1cee5f143..796de915c 100644 --- a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py @@ -24,8 +24,8 @@ import test_utils class TransportPCERendererTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -33,15 +33,12 @@ class TransportPCERendererTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma') time.sleep(20) - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -53,16 +50,16 @@ class TransportPCERendererTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -79,7 +76,7 @@ class TransportPCERendererTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17831", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -98,7 +95,7 @@ class TransportPCERendererTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py index b9b4bccd7..ab46c0df9 100644 --- a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py @@ -20,8 +20,8 @@ import test_utils class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -29,15 +29,12 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma') time.sleep(20) - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -49,16 +46,16 @@ class TransportPCEtesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): time.sleep(10) @@ -76,7 +73,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17831", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -143,7 +140,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_topology.py b/tests/transportpce_tests/1.2.1/test_topology.py index b017b40f8..bade42ccf 100644 --- a/tests/transportpce_tests/1.2.1/test_topology.py +++ b/tests/transportpce_tests/1.2.1/test_topology.py @@ -20,10 +20,10 @@ import test_utils class TransportPCETopologyTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -31,24 +31,19 @@ class TransportPCETopologyTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') time.sleep(20) - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma') time.sleep(20) - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmb_honeynode() + cls.sim_process3 = test_utils.start_sim('roadmb') time.sleep(20) - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_roadmc_honeynode() + cls.sim_process4 = test_utils.start_sim('roadmc') time.sleep(20) - print("all honeynodes started") + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -60,28 +55,28 @@ class TransportPCETopologyTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() def setUp(self): time.sleep(5) @@ -98,7 +93,7 @@ class TransportPCETopologyTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17831", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -249,7 +244,7 @@ class TransportPCETopologyTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17830", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -482,7 +477,7 @@ class TransportPCETopologyTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17833", + "netconf-node-topology:port": test_utils.sims['roadmc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -795,7 +790,7 @@ class TransportPCETopologyTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17832", + "netconf-node-topology:port": test_utils.sims['roadmb']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/1.2.1/test_utils.py b/tests/transportpce_tests/1.2.1/test_utils.py index d63109516..99a51023d 100644 --- a/tests/transportpce_tests/1.2.1/test_utils.py +++ b/tests/transportpce_tests/1.2.1/test_utils.py @@ -1,6 +1,25 @@ +#!/usr/bin/env python +############################################################################## +# Copyright (c) 2020 Orange, Inc. and others. All rights reserved. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import os import subprocess +sims = { + 'xpdra': {'port': '17830', 'configfile': 'oper-XPDRA.xml'}, + 'roadma': {'port': '17831', 'configfile': 'oper-ROADMA.xml'}, + 'roadmb': {'port': '17832', 'configfile': 'oper-ROADMB.xml'}, + 'roadmc': {'port': '17833', 'configfile': 'oper-ROADMC.xml'}, + 'xpdrc': {'port': '17834', 'configfile': 'oper-XPDRC.xml'}, + 'roadma-full': {'port': '17821', 'configfile': 'oper-ROADMA-full.xml'}, + 'roadmc-full': {'port': '17823', 'configfile': 'oper-ROADMC-full.xml'} +} + honeynode_executable = os.path.join( os.path.dirname(os.path.realpath(__file__)), "..", "..", "honeynode", "1.2.1", "honeynode-simulator", "honeycomb-tpce") @@ -9,63 +28,17 @@ samples_directory = os.path.join( "..", "..", "sample_configs", "openroadm", "1.2.1") -def start_xpdra_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode1.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17830", os.path.join(samples_directory, "oper-XPDRA.xml")], - stdout=outfile, stderr=outfile) - - -def start_roadma_full_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode2.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17821", os.path.join(samples_directory, "oper-ROADMA-full.xml")], - stdout=outfile, stderr=outfile) - - -def start_roadma_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode2.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17831", os.path.join(samples_directory, "oper-ROADMA.xml")], - stdout=outfile, stderr=outfile) - - -def start_roadmb_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode3.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17832", os.path.join(samples_directory, "oper-ROADMB.xml")], - stdout=outfile, stderr=outfile) - - -def start_roadmc_full_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode3.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17823", os.path.join(samples_directory, "oper-ROADMC-full.xml")], - stdout=outfile, stderr=outfile) - - -def start_roadmc_honeynode(): - if os.path.isfile(honeynode_executable): - with open('honeynode4.log', 'w') as outfile: - return subprocess.Popen( - [honeynode_executable, "17833", os.path.join(samples_directory, "oper-ROADMC.xml")], - stdout=outfile, stderr=outfile) - - -def start_xpdrc_honeynode(): +def start_sim(sim): + print("starting simulator for " + sim + "...") if os.path.isfile(honeynode_executable): - with open('honeynode4.log', 'w') as outfile: + with open(sim+'.log', 'w') as outfile: return subprocess.Popen( - [honeynode_executable, "17834", os.path.join(samples_directory, "oper-XPDRC.xml")], + [honeynode_executable, sims[sim]['port'], os.path.join(samples_directory, sims[sim]['configfile'])], stdout=outfile, stderr=outfile) def start_tpce(): + print("starting opendaylight...") if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True': print("starting LIGHTY.IO TransportPCE build...") executable = os.path.join( @@ -74,8 +47,7 @@ def start_tpce(): "clean-start-controller.sh") with open('odl.log', 'w') as outfile: return subprocess.Popen( - ["sh", executable], stdout=outfile, stderr=outfile, - stdin=open(os.devnull)) + ["sh", executable], stdout=outfile, stderr=outfile, stdin=None) else: print("starting KARAF TransportPCE build...") executable = os.path.join( @@ -83,5 +55,4 @@ def start_tpce(): "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf") with open('odl.log', 'w') as outfile: return subprocess.Popen( - ["sh", executable, "server"], stdout=outfile, stderr=outfile, - stdin=open(os.devnull)) + ["sh", executable, "server"], stdout=outfile, stderr=outfile, stdin=None) diff --git a/tests/transportpce_tests/2.2.1/test_end2end.py b/tests/transportpce_tests/2.2.1/test_end2end.py index 83d938e8b..1b1aab3db 100644 --- a/tests/transportpce_tests/2.2.1/test_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_end2end.py @@ -24,10 +24,10 @@ import test_utils class TransportPCEFulltesting(unittest.TestCase): odl_process = None - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None restconf_baseurl = "http://localhost:8181/restconf" WAITING = 20 # nominal value is 300 @@ -35,24 +35,15 @@ class TransportPCEFulltesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) + cls.sim_process2 = test_utils.start_sim('roadma') - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_honeynode() - time.sleep(20) + cls.sim_process3 = test_utils.start_sim('roadmc') - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() - time.sleep(20) - print("all honeynodes started") + cls.sim_process4 = test_utils.start_sim('xpdrc') + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(80) print("opendaylight started") @@ -64,26 +55,26 @@ class TransportPCEFulltesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() print("all processes killed") def setUp(self): # instruction executed before each test method @@ -101,7 +92,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -120,7 +111,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17844", + "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -139,7 +130,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -158,7 +149,7 @@ class TransportPCEFulltesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17843", + "netconf-node-topology:port": test_utils.sims['roadmc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_olm.py b/tests/transportpce_tests/2.2.1/test_olm.py index 8a0068335..edca444ca 100644 --- a/tests/transportpce_tests/2.2.1/test_olm.py +++ b/tests/transportpce_tests/2.2.1/test_olm.py @@ -24,10 +24,10 @@ import test_utils class TransportOlmTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -35,25 +35,16 @@ class TransportOlmTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) + cls.sim_process2 = test_utils.start_sim('roadma') - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_honeynode() - time.sleep(20) + cls.sim_process3 = test_utils.start_sim('roadmc') - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() - time.sleep(20) + cls.sim_process4 = test_utils.start_sim('xpdrc') - print("all honeynodes started") + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -65,26 +56,26 @@ class TransportOlmTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -101,7 +92,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -120,7 +111,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17844", + "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -139,7 +130,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -158,7 +149,7 @@ class TransportOlmTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17843", + "netconf-node-topology:port": test_utils.sims['roadmc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_otn_renderer.py b/tests/transportpce_tests/2.2.1/test_otn_renderer.py index 27f09cd00..97a6983da 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_renderer.py @@ -28,17 +28,14 @@ def extract_a_from_b(a, b): class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None + sim_process1 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_spdra_honeynode() - time.sleep(30) + cls.sim_process1 = test_utils.start_sim('spdrav2') - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -50,11 +47,11 @@ class TransportPCEtesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() def setUp(self): time.sleep(5) @@ -68,7 +65,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17845", + "netconf-node-topology:port": test_utils.sims['spdrav2']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_otn_topology.py b/tests/transportpce_tests/2.2.1/test_otn_topology.py index 0e0390fa2..062c0d9c4 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_topology.py +++ b/tests/transportpce_tests/2.2.1/test_otn_topology.py @@ -24,17 +24,14 @@ import test_utils class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None + sim_process1 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_spdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('spdrav2') - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -46,11 +43,11 @@ class TransportPCEtesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() def setUp(self): time.sleep(5) @@ -64,7 +61,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17845", + "netconf-node-topology:port": test_utils.sims['spdrav2']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index 99ed92574..5bed24b53 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -23,23 +23,18 @@ import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) - print("all honeynodes started") + cls.sim_process2 = test_utils.start_sim('roadma') + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -51,16 +46,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -75,7 +70,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -184,7 +179,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py index 57b90df4d..df0cc32de 100644 --- a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py @@ -24,8 +24,8 @@ import test_utils class TransportPCERendererTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -33,14 +33,10 @@ class TransportPCERendererTesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) - print("all honeynodes started") + cls.sim_process2 = test_utils.start_sim('roadma') + print("all sims started") print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() @@ -54,16 +50,16 @@ class TransportPCERendererTesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) @@ -80,7 +76,7 @@ class TransportPCERendererTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -101,7 +97,7 @@ class TransportPCERendererTesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_tapi.py b/tests/transportpce_tests/2.2.1/test_tapi.py index ed2ec846f..4594085e8 100644 --- a/tests/transportpce_tests/2.2.1/test_tapi.py +++ b/tests/transportpce_tests/2.2.1/test_tapi.py @@ -27,11 +27,11 @@ CREATED_SUCCESSFULLY = 'Result message should contain Xponder Roadm Link created class TransportTapitesting(unittest.TestCase): odl_process = None - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None - honeynode_process5 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None + sim_process5 = None # START_IGNORE_XTESTING @@ -39,7 +39,6 @@ class TransportTapitesting(unittest.TestCase): def setUpClass(cls): cls.init_failed = False - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() if "USE_LIGHTY" not in os.environ or os.environ['USE_LIGHTY'] != 'True': karaf_log = os.path.join( @@ -61,30 +60,25 @@ class TransportTapitesting(unittest.TestCase): found = test_utils.wait_until_log_contains(karaf_log, searched_expr, time_to_wait=60) cls.init_failed = not found if not cls.init_failed: - print("starting XPDRA...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting ROADMA...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() + cls.sim_process2 = test_utils.start_sim('roadma') - print("starting ROADMC...") - cls.honeynode_process3 = test_utils.start_roadmc_honeynode() + cls.sim_process3 = test_utils.start_sim('roadmc') - print("starting XPDRC...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() + cls.sim_process4 = test_utils.start_sim('xpdrc') - print("starting SPDRA...") - cls.honeynode_process5 = test_utils.start_spdra_honeynode() - print("all honeynodes started") + cls.sim_process5 = test_utils.start_sim('spdrav2') + print("all sims started") @classmethod def tearDownClass(cls): test_utils.shutdown_process(cls.odl_process) - test_utils.shutdown_process(cls.honeynode_process1) - test_utils.shutdown_process(cls.honeynode_process2) - test_utils.shutdown_process(cls.honeynode_process3) - test_utils.shutdown_process(cls.honeynode_process4) - test_utils.shutdown_process(cls.honeynode_process5) + test_utils.shutdown_process(cls.sim_process1) + test_utils.shutdown_process(cls.sim_process2) + test_utils.shutdown_process(cls.sim_process3) + test_utils.shutdown_process(cls.sim_process4) + test_utils.shutdown_process(cls.sim_process5) print("all processes killed") def setUp(self): # instruction executed before each test method @@ -99,7 +93,7 @@ class TransportTapitesting(unittest.TestCase): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/SPDR-SA1" .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("SPDR-SA1", "17845") + data = test_utils.generate_connect_data("SPDR-SA1", test_utils.sims['spdrav2']['port']) response = test_utils.put_request(url, data, 'admin', 'admin') self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member time.sleep(10) @@ -108,7 +102,7 @@ class TransportTapitesting(unittest.TestCase): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/XPDR-A1" .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("XPDR-A1", "17840") + data = test_utils.generate_connect_data("XPDR-A1", test_utils.sims['xpdra']['port']) response = test_utils.put_request(url, data, 'admin', 'admin') self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member time.sleep(10) @@ -117,7 +111,7 @@ class TransportTapitesting(unittest.TestCase): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/XPDR-C1" .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("XPDR-C1", "17844") + data = test_utils.generate_connect_data("XPDR-C1", test_utils.sims['xpdrc']['port']) response = test_utils.put_request(url, data, 'admin', 'admin') self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member time.sleep(10) @@ -126,7 +120,7 @@ class TransportTapitesting(unittest.TestCase): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/ROADM-A1" .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("ROADM-A1", "17841") + data = test_utils.generate_connect_data("ROADM-A1", test_utils.sims['roadma']['port']) response = test_utils.put_request(url, data, 'admin', 'admin') self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member time.sleep(20) @@ -135,7 +129,7 @@ class TransportTapitesting(unittest.TestCase): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/ROADM-C1" .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("ROADM-C1", "17843") + data = test_utils.generate_connect_data("ROADM-C1", test_utils.sims['roadmc']['port']) response = test_utils.put_request(url, data, 'admin', 'admin') self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member time.sleep(20) diff --git a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py index 58c0b9dc6..7f23aee79 100644 --- a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py @@ -24,8 +24,8 @@ import test_utils class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None + sim_process1 = None + sim_process2 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -33,16 +33,11 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) - print("all honeynodes started") + cls.sim_process2 = test_utils.start_sim('roadma') + print("all sims started") - print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() time.sleep(60) print("opendaylight started") @@ -54,16 +49,16 @@ class TransportPCEtesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() def setUp(self): time.sleep(10) @@ -81,7 +76,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -153,7 +148,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_topology.py b/tests/transportpce_tests/2.2.1/test_topology.py index 54762d248..a00733479 100644 --- a/tests/transportpce_tests/2.2.1/test_topology.py +++ b/tests/transportpce_tests/2.2.1/test_topology.py @@ -24,10 +24,10 @@ import test_utils class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None + sim_process1 = None + sim_process2 = None + sim_process3 = None + sim_process4 = None odl_process = None restconf_baseurl = "http://localhost:8181/restconf" @@ -35,22 +35,14 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) + cls.sim_process1 = test_utils.start_sim('xpdra') - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) + cls.sim_process2 = test_utils.start_sim('roadma') - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmb_honeynode() - time.sleep(20) + cls.sim_process3 = test_utils.start_sim('roadmb') - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_roadmc_honeynode() - time.sleep(20) - print("all honeynodes started") + cls.sim_process4 = test_utils.start_sim('roadmc') + print("all sims started") print("starting opendaylight...") cls.odl_process = test_utils.start_tpce() @@ -64,26 +56,26 @@ class TransportPCEtesting(unittest.TestCase): child.wait() cls.odl_process.send_signal(signal.SIGINT) cls.odl_process.wait() - for child in psutil.Process(cls.honeynode_process1.pid).children(): + for child in psutil.Process(cls.sim_process1.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): + cls.sim_process1.send_signal(signal.SIGINT) + cls.sim_process1.wait() + for child in psutil.Process(cls.sim_process2.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): + cls.sim_process2.send_signal(signal.SIGINT) + cls.sim_process2.wait() + for child in psutil.Process(cls.sim_process3.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): + cls.sim_process3.send_signal(signal.SIGINT) + cls.sim_process3.wait() + for child in psutil.Process(cls.sim_process4.pid).children(): child.send_signal(signal.SIGINT) child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + cls.sim_process4.send_signal(signal.SIGINT) + cls.sim_process4.wait() def setUp(self): time.sleep(5) @@ -100,7 +92,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17841", + "netconf-node-topology:port": test_utils.sims['roadma']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -257,7 +249,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17840", + "netconf-node-topology:port": test_utils.sims['xpdra']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -492,7 +484,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17843", + "netconf-node-topology:port": test_utils.sims['roadmc']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -805,7 +797,7 @@ class TransportPCEtesting(unittest.TestCase): "netconf-node-topology:username": "admin", "netconf-node-topology:password": "admin", "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17842", + "netconf-node-topology:port": test_utils.sims['roadmb']['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} diff --git a/tests/transportpce_tests/2.2.1/test_utils.py b/tests/transportpce_tests/2.2.1/test_utils.py index 0275d05d4..e6b6f9209 100644 --- a/tests/transportpce_tests/2.2.1/test_utils.py +++ b/tests/transportpce_tests/2.2.1/test_utils.py @@ -16,6 +16,16 @@ import subprocess import psutil import requests +sims = { + 'xpdra': {'port': '17840', 'configfile': 'oper-XPDRA.xml', 'logfile': 'oper-XPDRA.log'}, + 'roadma': {'port': '17841', 'configfile': 'oper-ROADMA.xml', 'logfile': 'oper-ROADMA.log'}, + 'roadmb': {'port': '17842', 'configfile': 'oper-ROADMB.xml', 'logfile': 'oper-ROADMB.log'}, + 'roadmc': {'port': '17843', 'configfile': 'oper-ROADMC.xml', 'logfile': 'oper-ROADMC.log'}, + 'xpdrc': {'port': '17844', 'configfile': 'oper-XPDRC.xml', 'logfile': 'oper-XPDRC.log'}, + 'spdrav2': {'port': '17845', 'configfile': 'oper-SPDRAv2.xml', 'logfile': 'oper-SPDRAv2.log'}, + 'spdrav1': {'port': '17846', 'configfile': 'oper-SPDRAv1.xml', 'logfile': 'oper-SPDRAv1.log'} +} + HONEYNODE_OK_START_MSG = re.escape("Netconf SSH endpoint started successfully at 0.0.0.0") TYPE_APPLICATION_JSON = {'content-type': 'application/json'} @@ -30,49 +40,19 @@ samples_directory = os.path.join( log_directory = os.path.dirname(os.path.realpath(__file__)) -def start_xpdra_honeynode(): - log_file = os.path.join(log_directory, "oper-XPDRA.log") - process = start_node(log_file, "17840", "oper-XPDRA.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) - return process - - -def start_roadma_honeynode(): - log_file = os.path.join(log_directory, "oper-ROADMA.log") - process = start_node(log_file, "17841", "oper-ROADMA.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) - return process - - -def start_roadmb_honeynode(): - log_file = os.path.join(log_directory, "oper-ROADMB.log") - process = start_node(log_file, "17842", "oper-ROADMB.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) - return process - - -def start_roadmc_honeynode(): - log_file = os.path.join(log_directory, "oper-ROADMC.log") - process = start_node(log_file, "17843", "oper-ROADMC.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) - return process - - -def start_xpdrc_honeynode(): - log_file = os.path.join(log_directory, "oper-XPDRC.log") - process = start_node(log_file, "17844", "oper-XPDRC.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) - return process - - -def start_spdra_honeynode(): - log_file = os.path.join(log_directory, "oper-SPDRAv2.log") - process = start_node(log_file, "17845", "oper-SPDRAv2.xml") - wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000) +def start_sim(sim): + print("starting simulator for " + sim + "...") + log_file = os.path.join(log_directory, sims[sim]['logfile']) + process = start_node(log_file, sims[sim]['port'], sims[sim]['configfile']) + if wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 5000): + print("simulator for " + sim + " started") + else: + print("simulator for " + sim + "failed to start") return process def start_tpce(): + print("starting opendaylight...") if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True': print("starting LIGHTY.IO TransportPCE build...") executable = os.path.join( @@ -81,8 +61,7 @@ def start_tpce(): "clean-start-controller.sh") with open('odl.log', 'w') as outfile: return subprocess.Popen( - ["sh", executable], stdout=outfile, stderr=outfile, - stdin=open(os.devnull)) + ["sh", executable], stdout=outfile, stderr=outfile, stdin=None) else: print("starting KARAF TransportPCE build...") executable = os.path.join( @@ -90,8 +69,7 @@ def start_tpce(): "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf") with open('odl.log', 'w') as outfile: return subprocess.Popen( - ["sh", executable, "server"], stdout=outfile, stderr=outfile, - stdin=open(os.devnull)) + ["sh", executable, "server"], stdout=outfile, stderr=outfile, stdin=None) def install_karaf_feature(feature_name: str):