review sims/tpce process management in 2.2.1 tests
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test_end2end.py
index 83d938e8b62b72111e7e09cf5021c7fc64ead7e2..8e33de6aac192c59d80178feeefaf31cea286ef2 100644 (file)
@@ -23,74 +23,24 @@ import test_utils
 
 class TransportPCEFulltesting(unittest.TestCase):
 
-    odl_process = None
-    honeynode_process1 = None
-    honeynode_process2 = None
-    honeynode_process3 = None
-    honeynode_process4 = None
+    processes = None
     restconf_baseurl = "http://localhost:8181/restconf"
     WAITING = 20  # nominal value is 300
 
-# START_IGNORE_XTESTING
-
     @classmethod
     def setUpClass(cls):
-        print("starting honeynode1...")
-        cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
-        time.sleep(20)
-
-        print("starting honeynode2...")
-        cls.honeynode_process2 = test_utils.start_roadma_honeynode()
-        time.sleep(20)
-
-        print("starting honeynode3...")
-        cls.honeynode_process3 = test_utils.start_roadmc_honeynode()
-        time.sleep(20)
-
-        print("starting honeynode4...")
-        cls.honeynode_process4 = test_utils.start_xpdrc_honeynode()
-        time.sleep(20)
-        print("all honeynodes started")
-
-        print("starting opendaylight...")
-        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', 'roadmc', '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.honeynode_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():
-            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():
-            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():
-            child.send_signal(signal.SIGINT)
-            child.wait()
-        cls.honeynode_process4.send_signal(signal.SIGINT)
-        cls.honeynode_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:"
@@ -101,7 +51,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 +70,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 +89,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 +108,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'}