From f4d7679be9ffcc5ef14241cbfe9040c1c177b260 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Thu, 18 Jun 2020 12:43:04 +0200 Subject: [PATCH] Align 1.2.1 tests sims/tpce management to 2.2.1 - move 2.2.1 test_utils.py to a common folder to make it resuable in 1.2.1 tests - create 2 simulators.py files with version specific parameters to import them in test_utils - use symlinks to by pass python relative import beyond top-level issues - adapt functional tests code accordingly Signed-off-by: guillaume.lambert Change-Id: I81351ecc33a32bd7149bc9d16c4a8fa53bd4938c --- tests/transportpce_tests/1.2.1/common | 1 + tests/transportpce_tests/1.2.1/simulators.py | 27 +++++++++ .../transportpce_tests/1.2.1/test_end2end.py | 59 +++--------------- tests/transportpce_tests/1.2.1/test_gnpy.py | 21 +++---- tests/transportpce_tests/1.2.1/test_olm.py | 58 +++--------------- tests/transportpce_tests/1.2.1/test_pce.py | 21 +++---- .../1.2.1/test_portmapping.py | 39 +++--------- .../test_renderer_service_path_nominal.py | 39 +++--------- .../1.2.1/test_topoPortMapping.py | 39 +++--------- .../transportpce_tests/1.2.1/test_topology.py | 60 +++---------------- tests/transportpce_tests/1.2.1/test_utils.py | 58 ------------------ tests/transportpce_tests/2.2.1/common | 1 + tests/transportpce_tests/2.2.1/simulators.py | 28 +++++++++ .../transportpce_tests/2.2.1/test_end2end.py | 2 +- tests/transportpce_tests/2.2.1/test_olm.py | 2 +- .../2.2.1/test_otn_renderer.py | 2 +- .../2.2.1/test_otn_topology.py | 2 +- .../2.2.1/test_portmapping.py | 2 +- .../test_renderer_service_path_nominal.py | 2 +- tests/transportpce_tests/2.2.1/test_tapi.py | 2 +- .../2.2.1/test_topoPortMapping.py | 2 +- .../transportpce_tests/2.2.1/test_topology.py | 2 +- tests/transportpce_tests/common/simulators.py | 1 + .../{2.2.1 => common}/test_utils.py | 23 ++----- 24 files changed, 133 insertions(+), 360 deletions(-) create mode 120000 tests/transportpce_tests/1.2.1/common create mode 100644 tests/transportpce_tests/1.2.1/simulators.py delete mode 100644 tests/transportpce_tests/1.2.1/test_utils.py create mode 120000 tests/transportpce_tests/2.2.1/common create mode 100644 tests/transportpce_tests/2.2.1/simulators.py create mode 120000 tests/transportpce_tests/common/simulators.py rename tests/transportpce_tests/{2.2.1 => common}/test_utils.py (88%) diff --git a/tests/transportpce_tests/1.2.1/common b/tests/transportpce_tests/1.2.1/common new file mode 120000 index 000000000..83323993b --- /dev/null +++ b/tests/transportpce_tests/1.2.1/common @@ -0,0 +1 @@ +../common/ \ No newline at end of file diff --git a/tests/transportpce_tests/1.2.1/simulators.py b/tests/transportpce_tests/1.2.1/simulators.py new file mode 100644 index 000000000..a44c4660a --- /dev/null +++ b/tests/transportpce_tests/1.2.1/simulators.py @@ -0,0 +1,27 @@ +#!/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 + +sims = { + 'xpdra': {'port': '17830', 'configfile': 'oper-XPDRA.xml', 'logfile': 'oper-XPDRA.log'}, + 'roadma': {'port': '17831', 'configfile': 'oper-ROADMA.xml', 'logfile': 'oper-ROADMA.log'}, + 'roadmb': {'port': '17832', 'configfile': 'oper-ROADMB.xml', 'logfile': 'oper-ROADMB.log'}, + 'roadmc': {'port': '17833', 'configfile': 'oper-ROADMC.xml', 'logfile': 'oper-ROADMC.log'}, + 'xpdrc': {'port': '17834', 'configfile': 'oper-XPDRC.xml', 'logfile': 'oper-XPDRC.log'}, + 'roadma-full': {'port': '17821', 'configfile': 'oper-ROADMA-full.xml', 'logfile': 'oper-ROADMA.log'}, + 'roadmc-full': {'port': '17823', 'configfile': 'oper-ROADMC-full.xml', 'logfile': 'oper-ROADMC.log'} +} + +honeynode_executable = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "..", "honeynode", "1.2.1", "honeynode-simulator", "honeycomb-tpce") +samples_directory = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "..", "sample_configs", "openroadm", "1.2.1") diff --git a/tests/transportpce_tests/1.2.1/test_end2end.py b/tests/transportpce_tests/1.2.1/test_end2end.py index 3fad3d284..5afdb0e1e 100644 --- a/tests/transportpce_tests/1.2.1/test_end2end.py +++ b/tests/transportpce_tests/1.2.1/test_end2end.py @@ -16,74 +16,31 @@ import unittest import psutil import requests -import test_utils +from common import test_utils class TransportPCEFulltesting(unittest.TestCase): + headers = {'content-type': 'application/json'} - odl_process = 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 - # START_IGNORE_XTESTING + processes = None + restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma-full') - time.sleep(20) - - cls.sim_process3 = test_utils.start_sim('roadmc-full') - time.sleep(20) - - cls.sim_process4 = test_utils.start_sim('xpdrc') - time.sleep(20) - print("all sims started") - - cls.odl_process = test_utils.start_tpce() - time.sleep(80) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma-full', 'roadmc-full', 'xpdrc']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.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.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.sim_process4.send_signal(signal.SIGINT) - cls.sim_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) print("all processes killed") def setUp(self): # instruction executed before each test method print("execution of {}".format(self.id().split(".")[-1])) - # END_IGNORE_XTESTING - # connect netconf devices def test_01_connect_xpdrA(self): url = ("{}/config/network-topology:" diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 64a88194a..447e65f31 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -16,33 +16,28 @@ import requests import signal import time import unittest -import test_utils +from common import test_utils class TransportGNPYtesting(unittest.TestCase): - gnpy_process = None - odl_process = None - restconf_baseurl = "http://localhost:8181/restconf" - @classmethod def __init_logfile(cls): if os.path.isfile("./transportpce_tests/gnpy.log"): os.remove("transportpce_tests/gnpy.log") + processes = None + restconf_baseurl = "http://localhost:8181/restconf" + @classmethod def setUpClass(cls): - cls.odl_process = test_utils.start_tpce() - time.sleep(30) - print("opendaylight started") + cls.processes = test_utils.start_tpce() @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): time.sleep(2) diff --git a/tests/transportpce_tests/1.2.1/test_olm.py b/tests/transportpce_tests/1.2.1/test_olm.py index 956305635..7d4a7698a 100644 --- a/tests/transportpce_tests/1.2.1/test_olm.py +++ b/tests/transportpce_tests/1.2.1/test_olm.py @@ -19,73 +19,29 @@ import os import psutil import shutil from unittest.result import failfast -import test_utils +from common import test_utils class TransportOlmTesting(unittest.TestCase): - sim_process1 = None - sim_process2 = None - sim_process3 = None - sim_process4 = None - odl_process = None + processes = None restconf_baseurl = "http://localhost:8181/restconf" -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma-full') - time.sleep(20) - - cls.sim_process3 = test_utils.start_sim('roadmc-full') - time.sleep(20) - - cls.sim_process4 = test_utils.start_sim('xpdrc') - time.sleep(20) - print("all sims started") - - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma-full', 'roadmc-full', 'xpdrc']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.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.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.sim_process4.send_signal(signal.SIGINT) - cls.sim_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) time.sleep(1) -# END_IGNORE_XTESTING - def test_01_xpdrA_device_connected(self): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/XPDRA01" diff --git a/tests/transportpce_tests/1.2.1/test_pce.py b/tests/transportpce_tests/1.2.1/test_pce.py index 61f3b2ab6..8a87a9bb2 100644 --- a/tests/transportpce_tests/1.2.1/test_pce.py +++ b/tests/transportpce_tests/1.2.1/test_pce.py @@ -17,16 +17,14 @@ import shutil import subprocess import time import unittest -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): - odl_process = None simple_topo_bi_dir_data = None simple_topo_uni_dir_data = None complex_topo_uni_dir_data = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def _get_file(cls): @@ -46,20 +44,19 @@ class TransportPCEtesting(unittest.TestCase): with open(topo_uni_dir_complex_file, 'r') as topo_uni_dir_complex: cls.complex_topo_uni_dir_data = topo_uni_dir_complex.read() + processes = None + restconf_baseurl = "http://localhost:8181/restconf" + @classmethod - def setUpClass(cls): # a class method called before tests in an individual class run. + def setUpClass(cls): cls._get_file() - cls.odl_process = test_utils.start_tpce() - time.sleep(90) - print("opendaylight started") + cls.processes = test_utils.start_tpce() @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): # instruction executed before each test method time.sleep(1) diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index bf42eb9d5..d9f91e48b 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -15,54 +15,29 @@ import unittest import time import requests import psutil -import test_utils +from common import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): - sim_process1 = None - sim_process2 = None - odl_process = None + processes = None restconf_baseurl = "http://localhost:8181/restconf" -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma') - time.sleep(20) - - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.sim_process2.send_signal(signal.SIGINT) - cls.sim_process2.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) time.sleep(10) -# END_IGNORE_XTESTING - # def test_01_restconfAPI(self): # url = ("{}/operational/network-topology:network-topology/topology/" # "topology-netconf/node/controller-config".format(self.restconf_baseurl)) 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 796de915c..6ccec33b3 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 @@ -19,54 +19,29 @@ import os import psutil import shutil from unittest.result import failfast -import test_utils +from common import test_utils class TransportPCERendererTesting(unittest.TestCase): - sim_process1 = None - sim_process2 = None - odl_process = None + processes = None restconf_baseurl = "http://localhost:8181/restconf" -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma') - time.sleep(20) - - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.sim_process2.send_signal(signal.SIGINT) - cls.sim_process2.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) time.sleep(10) -# END_IGNORE_XTESTING - def test_01_rdm_device_connected(self): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/ROADMA01" diff --git a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py index ab46c0df9..2a41e52f8 100644 --- a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py @@ -15,53 +15,28 @@ import time import unittest import requests import psutil -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): - sim_process1 = None - sim_process2 = None - odl_process = None + processes = None restconf_baseurl = "http://localhost:8181/restconf" -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma') - time.sleep(20) - - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.sim_process2.send_signal(signal.SIGINT) - cls.sim_process2.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): time.sleep(10) -# END_IGNORE_XTESTING - # Connect the ROADMA def test_01_connect_rdm(self): # Config ROADMA diff --git a/tests/transportpce_tests/1.2.1/test_topology.py b/tests/transportpce_tests/1.2.1/test_topology.py index bade42ccf..bb3867ac3 100644 --- a/tests/transportpce_tests/1.2.1/test_topology.py +++ b/tests/transportpce_tests/1.2.1/test_topology.py @@ -15,74 +15,28 @@ import time import unittest import requests import psutil -import test_utils +from common import test_utils class TransportPCETopologyTesting(unittest.TestCase): - sim_process1 = None - sim_process2 = None - sim_process3 = None - sim_process4 = None - odl_process = None + processes = None restconf_baseurl = "http://localhost:8181/restconf" -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - time.sleep(20) - - cls.sim_process2 = test_utils.start_sim('roadma') - time.sleep(20) - - cls.sim_process3 = test_utils.start_sim('roadmb') - time.sleep(20) - - cls.sim_process4 = test_utils.start_sim('roadmc') - time.sleep(20) - print("all sims started") - - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma', 'roadmb', 'roadmc']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - 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.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.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.sim_process4.send_signal(signal.SIGINT) - cls.sim_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): time.sleep(5) -# END_IGNORE_XTESTING - def test_01_connect_ROADMA(self): # Config ROADMA url = ("{}/config/network-topology:" diff --git a/tests/transportpce_tests/1.2.1/test_utils.py b/tests/transportpce_tests/1.2.1/test_utils.py deleted file mode 100644 index 99a51023d..000000000 --- a/tests/transportpce_tests/1.2.1/test_utils.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/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") -samples_directory = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", "sample_configs", "openroadm", "1.2.1") - - -def start_sim(sim): - print("starting simulator for " + sim + "...") - if os.path.isfile(honeynode_executable): - with open(sim+'.log', 'w') as outfile: - return subprocess.Popen( - [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( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", "..", "lighty", "target", "tpce", - "clean-start-controller.sh") - with open('odl.log', 'w') as outfile: - return subprocess.Popen( - ["sh", executable], stdout=outfile, stderr=outfile, stdin=None) - else: - print("starting KARAF TransportPCE build...") - executable = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf") - with open('odl.log', 'w') as outfile: - return subprocess.Popen( - ["sh", executable, "server"], stdout=outfile, stderr=outfile, stdin=None) diff --git a/tests/transportpce_tests/2.2.1/common b/tests/transportpce_tests/2.2.1/common new file mode 120000 index 000000000..83323993b --- /dev/null +++ b/tests/transportpce_tests/2.2.1/common @@ -0,0 +1 @@ +../common/ \ No newline at end of file diff --git a/tests/transportpce_tests/2.2.1/simulators.py b/tests/transportpce_tests/2.2.1/simulators.py new file mode 100644 index 000000000..8892226c8 --- /dev/null +++ b/tests/transportpce_tests/2.2.1/simulators.py @@ -0,0 +1,28 @@ +#!/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 + +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_executable = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "..", "honeynode", "2.2.1", "honeynode-simulator", "honeycomb-tpce") +samples_directory = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "..", "sample_configs", "openroadm", "2.2.1") diff --git a/tests/transportpce_tests/2.2.1/test_end2end.py b/tests/transportpce_tests/2.2.1/test_end2end.py index 8e33de6aa..755d0c668 100644 --- a/tests/transportpce_tests/2.2.1/test_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_end2end.py @@ -18,7 +18,7 @@ import shutil import subprocess import time import unittest -import test_utils +from common import test_utils class TransportPCEFulltesting(unittest.TestCase): diff --git a/tests/transportpce_tests/2.2.1/test_olm.py b/tests/transportpce_tests/2.2.1/test_olm.py index d96b302aa..09b5e2ed3 100644 --- a/tests/transportpce_tests/2.2.1/test_olm.py +++ b/tests/transportpce_tests/2.2.1/test_olm.py @@ -19,7 +19,7 @@ import os import psutil import shutil from unittest.result import failfast -import test_utils +from common import test_utils class TransportOlmTesting(unittest.TestCase): 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 f1a617365..04f09c6d1 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_renderer.py @@ -19,7 +19,7 @@ import subprocess import time import unittest import logging -import test_utils +from common import test_utils def extract_a_from_b(a, b): 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 8fa8b8b87..89a2eef03 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_topology.py +++ b/tests/transportpce_tests/2.2.1/test_otn_topology.py @@ -19,7 +19,7 @@ import subprocess import time import unittest import logging -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index f532c4e23..14edf7096 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -18,7 +18,7 @@ import shutil import subprocess import time import unittest -import test_utils +from common import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): 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 213530692..c5c7ec229 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 @@ -19,7 +19,7 @@ import os import psutil import shutil from unittest.result import failfast -import test_utils +from common import test_utils class TransportPCERendererTesting(unittest.TestCase): diff --git a/tests/transportpce_tests/2.2.1/test_tapi.py b/tests/transportpce_tests/2.2.1/test_tapi.py index 6f7eb37a6..718b7404b 100644 --- a/tests/transportpce_tests/2.2.1/test_tapi.py +++ b/tests/transportpce_tests/2.2.1/test_tapi.py @@ -14,7 +14,7 @@ import unittest import requests -import test_utils +from common import test_utils RESTCONF_BASE_URL = "http://localhost:8181/restconf" diff --git a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py index b88f19991..f6285bafb 100644 --- a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py @@ -19,7 +19,7 @@ import subprocess import time import unittest import logging -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): diff --git a/tests/transportpce_tests/2.2.1/test_topology.py b/tests/transportpce_tests/2.2.1/test_topology.py index 54c172e87..c531cb25f 100644 --- a/tests/transportpce_tests/2.2.1/test_topology.py +++ b/tests/transportpce_tests/2.2.1/test_topology.py @@ -19,7 +19,7 @@ import subprocess import time import unittest import logging -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): diff --git a/tests/transportpce_tests/common/simulators.py b/tests/transportpce_tests/common/simulators.py new file mode 120000 index 000000000..18d5fb86a --- /dev/null +++ b/tests/transportpce_tests/common/simulators.py @@ -0,0 +1 @@ +../simulators.py \ No newline at end of file diff --git a/tests/transportpce_tests/2.2.1/test_utils.py b/tests/transportpce_tests/common/test_utils.py similarity index 88% rename from tests/transportpce_tests/2.2.1/test_utils.py rename to tests/transportpce_tests/common/test_utils.py index 5402eae5b..b94c9de01 100644 --- a/tests/transportpce_tests/2.2.1/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -16,15 +16,11 @@ 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'} -} +import simulators + +sims = simulators.sims +honeynode_executable = simulators.honeynode_executable +samples_directory = simulators.samples_directory HONEYNODE_OK_START_MSG = re.escape("Netconf SSH endpoint started successfully at 0.0.0.0") KARAF_OK_START_MSG = re.escape("Blueprint container for bundle " @@ -32,14 +28,6 @@ KARAF_OK_START_MSG = re.escape("Blueprint container for bundle " TYPE_APPLICATION_JSON = {'content-type': 'application/json'} -honeynode_executable = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", "honeynode", "2.2.1", "honeynode-simulator", "honeycomb-tpce") - -samples_directory = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", "sample_configs", "openroadm", "2.2.1") - log_directory = os.path.dirname(os.path.realpath(__file__)) karaf_log = os.path.join( @@ -48,6 +36,7 @@ karaf_log = os.path.join( process_list = [] + def start_sims(sims_list): for sim in sims_list: print("starting simulator for " + sim + "...") -- 2.36.6