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):
- topo_bi_dir_file = "sample_configs/honeynode-topo.xml"
+ topo_bi_dir_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "sample_configs", "honeynode-topo.xml")
if os.path.isfile(topo_bi_dir_file):
with open(topo_bi_dir_file, 'r') as topo_bi_dir:
cls.simple_topo_bi_dir_data = topo_bi_dir.read()
- topo_uni_dir_file = "sample_configs/NW-simple-topology.xml"
+ topo_uni_dir_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "sample_configs", "NW-simple-topology.xml")
if os.path.isfile(topo_uni_dir_file):
with open(topo_uni_dir_file, 'r') as topo_uni_dir:
cls.simple_topo_uni_dir_data = topo_uni_dir.read()
- topo_uni_dir_complex_file = "sample_configs/NW-for-test-5-4.xml"
+ topo_uni_dir_complex_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "sample_configs", "NW-for-test-5-4.xml")
if os.path.isfile(topo_uni_dir_complex_file):
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()
- print("starting opendaylight...")
- 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)