fix assertDictContainsSubset deprecation warnings
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test_portmapping.py
index 6edac72f2a3daff3b3257ac020c7ba37a49fd542..99ed92574ecc6a1dc06df1b772904f70d18df0f4 100644 (file)
@@ -18,6 +18,7 @@ import shutil
 import subprocess
 import time
 import unittest
+import test_utils
 
 
 class TransportPCEPortMappingTesting(unittest.TestCase):
@@ -27,42 +28,21 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     odl_process = None
     restconf_baseurl = "http://localhost:8181/restconf"
 
-    @classmethod
-    def __start_honeynode1(cls):
-        executable = ("./honeynode/2.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, "17840", "sample_configs/openroadm/2.2.1/oper-XPDRA.xml"],
-                    stdout=outfile)
-
-    @classmethod
-    def __start_honeynode2(cls):
-        executable = ("./honeynode/2.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, "17841", "sample_configs/openroadm/2.2.1/oper-ROADMA.xml"],
-                    stdout=outfile)
-
-    @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))
-
     @classmethod
     def setUpClass(cls):
-        cls.__start_honeynode1()
+        print("starting honeynode1...")
+        cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
         time.sleep(20)
-        cls.__start_honeynode2()
+
+        print("starting honeynode2...")
+        cls.honeynode_process2 = test_utils.start_roadma_honeynode()
         time.sleep(20)
-        cls.__start_odl()
+        print("all honeynodes started")
+
+        print("starting opendaylight...")
+        cls.odl_process = test_utils.start_tpce()
         time.sleep(60)
+        print("opendaylight started")
 
     @classmethod
     def tearDownClass(cls):
@@ -83,13 +63,13 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         cls.honeynode_process2.wait()
 
     def setUp(self):
-        print ("execution of {}".format(self.id().split(".")[-1]))
+        print("execution of {}".format(self.id().split(".")[-1]))
         time.sleep(10)
 
     def test_01_rdm_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/ROADM-A1"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "ROADM-A1",
             "netconf-node-topology:username": "admin",
@@ -130,10 +110,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.11',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'model2'}},
+                            u'node-ip-address': u'127.0.0.11',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'model2'}},
             res)
         time.sleep(3)
 
@@ -198,7 +178,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     def test_08_xpdr_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/XPDR-A1"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "XPDR-A1",
             "netconf-node-topology:username": "admin",
@@ -239,10 +219,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertEqual(
             {u'node-info': {u'node-type': u'xpdr',
-             u'node-ip-address': u'1.2.3.4',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'model2'}},
+                            u'node-ip-address': u'1.2.3.4',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'2.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'model2'}},
             res)
         time.sleep(3)
 
@@ -256,9 +236,11 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
+            {'supported-interface-capability': ['org-openroadm-port-types:if-OCH'],
+             'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
-             'port-direction': 'bidirectional', 'associated-lcp': 'XPDR1-CLIENT1'},
+             'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1',
+             'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd941'},
             res['mapping'])
 
     def test_12_xpdr_portmapping_NETWORK2(self):
@@ -271,9 +253,11 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
+            {'supported-interface-capability': ['org-openroadm-port-types:if-OCH'],
+             'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
-             'associated-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network'},
+             'connection-map-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network',
+             'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd942'},
             res['mapping'])
 
     def test_13_xpdr_portmapping_CLIENT1(self):
@@ -286,10 +270,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {'supporting-port': 'C1',
+            {'supported-interface-capability': ['org-openroadm-port-types:if-100GE'],
+             'supporting-port': 'C1',
              'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
-             'associated-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client'},
+             'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
+             'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03d8'},
             res['mapping'])
 
     def test_14_xpdr_portmapping_CLIENT2(self):
@@ -302,20 +288,22 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {'supporting-port': 'C1',
-                 'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT',
-                 'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
-                 'associated-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client'},
+            {'supported-interface-capability': ['org-openroadm-port-types:if-100GE'],
+             'supporting-port': 'C1',
+             'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT',
+             'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
+             'connection-map-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client',
+             'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03db'},
             res['mapping'])
 
     def test_15_xpdr_device_disconnected(self):
         url = ("{}/config/network-topology:"
-                "network-topology/topology/topology-netconf/node/XPDR-A1"
+               "network-topology/topology/topology-netconf/node/XPDR-A1"
                .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)
 
@@ -328,8 +316,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_17_xpdr_device_disconnected(self):
@@ -340,8 +328,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_rdm_device_disconnected(self):
@@ -349,8 +337,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)
 
@@ -363,8 +351,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_20_rdm_device_disconnected(self):
@@ -375,8 +363,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'])