Bump lighty.io core and add tests support for it
[transportpce.git] / tests / transportpce_tests / 1.2.1 / test_olm.py
index 2ddfe7bc23a73dce3ad4506ef417f4072b977a7a..6acacd97198ab5c778d503c200e6e2ddd96bdf5c 100644 (file)
@@ -19,6 +19,7 @@ import os
 import psutil
 import shutil
 from unittest.result import failfast
+import test_utils
 
 
 class TransportOlmTesting(unittest.TestCase):
@@ -33,64 +34,28 @@ class TransportOlmTesting(unittest.TestCase):
 #START_IGNORE_XTESTING
 
     @classmethod
-    def __start_honeynode1(cls):
-        executable = ("./honeynode/2.1/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
-                      "/honeynode-distribution-1.18.01/honeycomb-tpce")
-        if os.path.isfile(executable):
-            with open('honeynode1.log', 'w') as outfile:
-                cls.honeynode_process1 = subprocess.Popen(
-                    [executable, "17830", "sample_configs/openroadm/2.1/oper-XPDRA.xml"],
-                    stdout=outfile)
+    def setUpClass(cls):
+        print ("starting honeynode1...")
+        cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
+        time.sleep(20)
 
-    @classmethod
-    def __start_honeynode2(cls):
-        executable = ("./honeynode/2.1/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
-                      "/honeynode-distribution-1.18.01/honeycomb-tpce")
-        if os.path.isfile(executable):
-            with open('honeynode2.log', 'w') as outfile:
-                cls.honeynode_process2 = subprocess.Popen(
-                    [executable, "17831", "sample_configs/openroadm/2.1/oper-ROADMA-full.xml"],
-                    stdout=outfile)
+        print ("starting honeynode2...")
+        cls.honeynode_process2 = test_utils.start_roadma_full_honeynode()
+        time.sleep(20)
 
-    @classmethod
-    def __start_honeynode3(cls):
-        executable = ("./honeynode/2.1/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
-                      "/honeynode-distribution-1.18.01/honeycomb-tpce")
-        if os.path.isfile(executable):
-            with open('honeynode3.log', 'w') as outfile:
-                cls.honeynode_process3 = subprocess.Popen(
-                    [executable, "17833", "sample_configs/openroadm/2.1/oper-ROADMC-full.xml"],
-                    stdout=outfile)
-    @classmethod
-    def __start_honeynode4(cls):
-        executable = ("./honeynode/2.1/honeynode-distribution/target/honeynode-distribution-1.18.01-hc"
-                      "/honeynode-distribution-1.18.01/honeycomb-tpce")
-        if os.path.isfile(executable):
-            with open('honeynode4.log', 'w') as outfile:
-                cls.honeynode_process4 = subprocess.Popen(
-                    [executable, "17834", "sample_configs/openroadm/2.1/oper-XPDRC.xml"],
-                    stdout=outfile)
+        print ("starting honeynode3...")
+        cls.honeynode_process3 = test_utils.start_roadmc_full_honeynode()
+        time.sleep(20)
 
-    @classmethod
-    def __start_odl(cls):
-        executable = "../karaf/target/assembly/bin/karaf"
-        with open('odl.log', 'w') as outfile:
-            cls.odl_process = subprocess.Popen(
-                ["bash", executable, "server"], stdout=outfile,
-                stdin=open(os.devnull))
+        print ("starting honeynode4...")
+        cls.honeynode_process4 = test_utils.start_xpdrc_honeynode()
+        time.sleep(20)
+        print ("all honeynodes started")
 
-    @classmethod
-    def setUpClass(cls):
-        cls.__start_honeynode1()
-        time.sleep(30)
-        cls.__start_honeynode2()
-        time.sleep(30)
-        cls.__start_honeynode3()
-        time.sleep(30)
-        cls.__start_honeynode4()
-        time.sleep(30)
-        cls.__start_odl()
+        print ("starting opendaylight...")
+        cls.odl_process = test_utils.start_tpce()
         time.sleep(60)
+        print ("opendaylight started")
 
     @classmethod
     def tearDownClass(cls):
@@ -173,7 +138,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": "17831",
+             "netconf-node-topology:port": "17821",
              "netconf-node-topology:tcp-only": "false",
              "netconf-node-topology:pass-through": {}}]}
         headers = {'content-type': 'application/json'}
@@ -192,7 +157,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": "17833",
+             "netconf-node-topology:port": "17823",
              "netconf-node-topology:tcp-only": "false",
              "netconf-node-topology:pass-through": {}}]}
         headers = {'content-type': 'application/json'}
@@ -496,7 +461,8 @@ class TransportOlmTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"])
-        time.sleep(40)
+        #time.sleep(40)
+        time.sleep(10)
 
     def test_18_servicePath_create_ZToA(self):
         url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl)
@@ -537,7 +503,8 @@ class TransportOlmTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"])
-        time.sleep(40)
+        #time.sleep(40)
+        time.sleep(10)
 
     def test_19_service_power_setup_XPDRA_XPDRC(self):
         url = "{}/operations/transportpce-olm:service-power-setup".format(self.restconf_baseurl)
@@ -892,7 +859,8 @@ class TransportOlmTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"])
-        time.sleep(40)
+        #time.sleep(40)
+        time.sleep(10)
 
     def test_34_get_interface_XPDRA_XPDR1_NETWORK2(self):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDRA/yang-ext:mount/"