X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F1.2.1%2Ftest_portmapping.py;h=301d745580541369f8c41242f6cfd5a6e97951a5;hb=1088f62da23159491f6d139e7ea5e51792d11f54;hp=d66c2e14133cf41d4129020d2d2028084960237e;hpb=166a4562d82e400ae1a2915d38ac6c8efeb8e56e;p=transportpce.git diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index d66c2e141..301d74558 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -10,14 +10,12 @@ ############################################################################## 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): @@ -27,44 +25,22 @@ class TransportPCEPortMappingTesting(unittest.TestCase): odl_process = None restconf_baseurl = "http://localhost:8181/restconf" -#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, "17831", "sample_configs/openroadm/2.1/oper-XPDRA.xml"], - stdout=outfile) - - @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, "17830", "sample_configs/openroadm/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)) +# START_IGNORE_XTESTING @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("starting opendaylight...") + cls.odl_process = test_utils.start_tpce() time.sleep(60) + print("opendaylight started") @classmethod def tearDownClass(cls): @@ -85,10 +61,10 @@ 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) -#END_IGNORE_XTESTING +# END_IGNORE_XTESTING # def test_01_restconfAPI(self): # url = ("{}/operational/network-topology:network-topology/topology/" @@ -109,19 +85,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/ROADMA" - .format(self.restconf_baseurl)) + "network-topology/topology/topology-netconf/node/ROADMA01" + .format(self.restconf_baseurl)) data = {"node": [{ - "node-id": "ROADMA", + "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": "17830", + "netconf-node-topology:port": "17831", "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -133,7 +109,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_02_rdm_device_connected(self): url = ("{}/operational/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA" + "network-topology/topology/topology-netconf/node/ROADMA01" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -145,9 +121,27 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'connected') time.sleep(10) - def test_03_rdm_portmapping_DEG1_TTP_TXRX(self): + def test_03_rdm_portmapping_info(self): + url = ("{}/config/transportpce-portmapping:network/" + "nodes/ROADMA01/node-info" + .format(self.restconf_baseurl)) + headers = {'content-type': 'application/json'} + response = requests.request( + "GET", url, headers=headers, auth=('admin', 'admin')) + self.assertEqual(response.status_code, requests.codes.ok) + 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'}}, + res) + time.sleep(3) + + def test_04_rdm_portmapping_DEG1_TTP_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADMA/mapping/DEG1-TTP-TXRX" + "nodes/ROADMA01/mapping/DEG1-TTP-TXRX" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -156,12 +150,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0', - 'logical-connection-point': 'DEG1-TTP-TXRX'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, res['mapping']) - def test_04_rdm_portmapping_SRG1_PP7_TXRX(self): + def test_05_rdm_portmapping_SRG1_PP7_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADMA/mapping/SRG1-PP7-TXRX" + "nodes/ROADMA01/mapping/SRG1-PP7-TXRX" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -170,12 +164,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0', - 'logical-connection-point': 'SRG1-PP7-TXRX'}, + 'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional'}, res['mapping']) - def test_05_rdm_portmapping_SRG3_PP1_TXRX(self): + def test_06_rdm_portmapping_SRG3_PP1_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADMA/mapping/SRG3-PP1-TXRX" + "nodes/ROADMA01/mapping/SRG3-PP1-TXRX" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -184,19 +178,19 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0', - 'logical-connection-point': 'SRG3-PP1-TXRX'}, + 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, res['mapping']) - def test_06_xpdr_device_connected(self): + def test_07_xpdr_device_connected(self): url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA" - .format(self.restconf_baseurl)) + "network-topology/topology/topology-netconf/node/XPDRA01" + .format(self.restconf_baseurl)) data = {"node": [{ - "node-id": "XPDRA", + "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": "17831", + "netconf-node-topology:port": "17830", "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} headers = {'content-type': 'application/json'} @@ -206,9 +200,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.created) time.sleep(20) - def test_07_xpdr_device_connected(self): + def test_08_xpdr_device_connected(self): url = ("{}/operational/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA" + "network-topology/topology/topology-netconf/node/XPDRA01" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -220,9 +214,27 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'connected') time.sleep(10) - def test_08_xpdr_portmapping_NETWORK1(self): + def test_09_xpdr_portmapping_info(self): + url = ("{}/config/transportpce-portmapping:network/" + "nodes/XPDRA01/node-info" + .format(self.restconf_baseurl)) + headers = {'content-type': 'application/json'} + response = requests.request( + "GET", url, headers=headers, auth=('admin', 'admin')) + self.assertEqual(response.status_code, requests.codes.ok) + 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'}}, + res) + time.sleep(3) + + def test_10_xpdr_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDRA/mapping/XPDR1-NETWORK1" + "nodes/XPDRA01/mapping/XPDR1-NETWORK1" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -231,12 +243,14 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', - 'logical-connection-point': 'XPDR1-NETWORK1'}, + 'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional', + 'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network', + 'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7aa'}, res['mapping']) - def test_09_xpdr_portmapping_NETWORK2(self): + def test_11_xpdr_portmapping_NETWORK2(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDRA/mapping/XPDR1-NETWORK2" + "nodes/XPDRA01/mapping/XPDR1-NETWORK2" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -245,12 +259,14 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET', - 'logical-connection-point': 'XPDR1-NETWORK2'}, + 'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional', + 'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network', + 'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7a9'}, res['mapping']) - def test_10_xpdr_portmapping_CLIENT1(self): + def test_12_xpdr_portmapping_CLIENT1(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDRA/mapping/XPDR1-CLIENT1" + "nodes/XPDRA01/mapping/XPDR1-CLIENT1" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -260,12 +276,14 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT', - 'logical-connection-point': 'XPDR1-CLIENT1'}, + 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', + 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', + 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae5'}, res['mapping']) - def test_11_xpdr_portmapping_CLIENT2(self): + def test_13_xpdr_portmapping_CLIENT2(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDRA/mapping/XPDR1-CLIENT2" + "nodes/XPDRA01/mapping/XPDR1-CLIENT2" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -274,13 +292,32 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C2', - 'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT', - 'logical-connection-point': 'XPDR1-CLIENT2'}, + 'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT', + 'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional', + 'port-qual': 'xpdr-client', + 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae6'}, res['mapping']) - def test_12_xpdr_portmapping_CLIENT4(self): + def test_14_xpdr_portmapping_CLIENT3(self): url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDRA/mapping/XPDR1-CLIENT4" + "nodes/XPDRA01/mapping/XPDR1-CLIENT3" + .format(self.restconf_baseurl)) + headers = {'content-type': 'application/json'} + response = requests.request( + "GET", url, headers=headers, auth=('admin', 'admin')) + self.assertEqual(response.status_code, requests.codes.ok) + res = response.json() + self.assertIn( + {'supporting-port': 'C3', + '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', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae7'}, + res['mapping']) + + def test_15_xpdr_portmapping_CLIENT4(self): + url = ("{}/config/transportpce-portmapping:network/" + "nodes/XPDRA01/mapping/XPDR1-CLIENT4" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -290,57 +327,58 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertIn( {'supporting-port': 'C4', 'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT', - 'logical-connection-point': 'XPDR1-CLIENT4'}, + 'logical-connection-point': 'XPDR1-CLIENT4', 'port-direction': 'bidirectional', + 'port-qual': 'xpdr-client', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae0'}, res['mapping']) - def test_13_xpdr_device_disconnected(self): + def test_16_xpdr_device_disconnected(self): url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA" + "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) - def test_14_xpdr_device_disconnected(self): + def test_17_xpdr_device_disconnected(self): url = ("{}/operational/network-topology:network-topology/topology/" - "topology-netconf/node/XPDRA".format(self.restconf_baseurl)) + "topology-netconf/node/XPDRA01".format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( "GET", url, headers=headers, auth=('admin', 'admin')) 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_15_xpdr_device_disconnected(self): - url = ("{}/config/transportpce-portmapping:network/nodes/XPDRA".format(self.restconf_baseurl)) + def test_18_xpdr_device_disconnected(self): + url = ("{}/config/transportpce-portmapping:network/nodes/XPDRA01".format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( "GET", url, headers=headers, auth=('admin', 'admin')) 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_16_rdm_device_disconnected(self): - url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMA" + def test_19_rdm_device_disconnected(self): + url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMA01" .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) - def test_17_rdm_device_disconnected(self): - url = ("{}/operational/network-topology:network-topology/topology/topology-netconf/node/ROADMA" + def test_20_rdm_device_disconnected(self): + url = ("{}/operational/network-topology:network-topology/topology/topology-netconf/node/ROADMA01" .format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( @@ -348,20 +386,20 @@ 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): - url = ("{}/config/transportpce-portmapping:network/nodes/ROADMA".format(self.restconf_baseurl)) + def test_21_rdm_device_disconnected(self): + url = ("{}/config/transportpce-portmapping:network/nodes/ROADMA01".format(self.restconf_baseurl)) headers = {'content-type': 'application/json'} response = requests.request( "GET", url, headers=headers, auth=('admin', 'admin')) 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'])