rationalize functional tests sims starters
[transportpce.git] / tests / transportpce_tests / 1.2.1 / test_portmapping.py
index 424e6f7d6d723b059b963f61d569c954dfe3b9ee..bf42eb9d509ee41eed8b4353538cf000b20d25eb 100644 (file)
 ##############################################################################
 
 import json
-import os
-import psutil
-import requests
 import signal
-import shutil
-import subprocess
-import time
 import unittest
+import time
+import requests
+import psutil
 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"
 
-#START_IGNORE_XTESTING
+# START_IGNORE_XTESTING
 
     @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")
+        print("opendaylight started")
 
     @classmethod
     def tearDownClass(cls):
@@ -52,22 +46,22 @@ 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]))
+        print("execution of {}".format(self.id().split(".")[-1]))
         time.sleep(10)
 
-#END_IGNORE_XTESTING
+# END_IGNORE_XTESTING
 
 #    def test_01_restconfAPI(self):
 #        url = ("{}/operational/network-topology:network-topology/topology/"
@@ -88,19 +82,19 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
 #         res = response.json()
 #         self.assertIn(
 #             {"error-type":"application", "error-tag":"data-missing",
-#              "error-message":"Request could not be completed because the relevant data model content does not exist "},
+#             "error-message":"Request could not be completed because the relevant data model content does not exist "},
 #             res['errors']['error'])
 
     def test_01_rdm_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/ROADMA01"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "ROADMA01",
             "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'}
@@ -135,10 +129,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertEqual(
             {u'node-info': {u'node-type': u'rdm',
-             u'node-ip-address': u'127.0.0.12',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'2'}},
+                            u'node-ip-address': u'127.0.0.12',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'2'}},
             res)
         time.sleep(3)
 
@@ -187,13 +181,13 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     def test_07_xpdr_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/XPDRA01"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "XPDRA01",
             "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'}
@@ -228,10 +222,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertEqual(
             {u'node-info': {u'node-type': u'xpdr',
-             u'node-ip-address': u'127.0.0.10',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'1'}},
+                            u'node-ip-address': u'127.0.0.10',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'1'}},
             res)
         time.sleep(3)
 
@@ -247,7 +241,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertIn(
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
-             'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network'},
+             'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
+             'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7aa'},
             res['mapping'])
 
     def test_11_xpdr_portmapping_NETWORK2(self):
@@ -262,7 +257,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertIn(
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
-             'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network'},
+             'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network',
+             'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7a9'},
             res['mapping'])
 
     def test_12_xpdr_portmapping_CLIENT1(self):
@@ -278,7 +274,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': 'C1',
              'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
-             'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client'},
+             'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
+             'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae5'},
             res['mapping'])
 
     def test_13_xpdr_portmapping_CLIENT2(self):
@@ -294,7 +291,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': 'C2',
              'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
-             'port-qual': 'xpdr-client'},
+             'port-qual': 'xpdr-client',
+             'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae6'},
             res['mapping'])
 
     def test_14_xpdr_portmapping_CLIENT3(self):
@@ -311,7 +309,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/C3-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT3',
              'connection-map-lcp': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
-             'port-qual': 'xpdr-client'},
+             'port-qual': 'xpdr-client', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae7'},
             res['mapping'])
 
     def test_15_xpdr_portmapping_CLIENT4(self):
@@ -327,17 +325,17 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': 'C4',
              'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT4', 'port-direction': 'bidirectional',
-             'port-qual': 'xpdr-client'},
+             'port-qual': 'xpdr-client', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae0'},
             res['mapping'])
 
     def test_16_xpdr_device_disconnected(self):
         url = ("{}/config/network-topology:"
-                "network-topology/topology/topology-netconf/node/XPDRA01"
+               "network-topology/topology/topology-netconf/node/XPDRA01"
                .format(self.restconf_baseurl))
         headers = {'content-type': 'application/json'}
         response = requests.request(
-             "DELETE", url, headers=headers,
-             auth=('admin', 'admin'))
+            "DELETE", url, headers=headers,
+            auth=('admin', 'admin'))
         self.assertEqual(response.status_code, requests.codes.ok)
         time.sleep(20)
 
@@ -350,8 +348,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_18_xpdr_device_disconnected(self):
@@ -362,8 +360,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_19_rdm_device_disconnected(self):
@@ -371,8 +369,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
                .format(self.restconf_baseurl))
         headers = {'content-type': 'application/json'}
         response = requests.request(
-             "DELETE", url, headers=headers,
-             auth=('admin', 'admin'))
+            "DELETE", url, headers=headers,
+            auth=('admin', 'admin'))
         self.assertEqual(response.status_code, requests.codes.ok)
         time.sleep(20)
 
@@ -385,8 +383,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_21_rdm_device_disconnected(self):
@@ -397,8 +395,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])