X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F2.2.1%2Ftest_portmapping.py;h=831cf0d99c514285deee720d23b7b3578025d5cd;hb=15197bf3dcde69a90f01963ffa524fbf6354555c;hp=68d59d5434068f6a15db22ed31a0a072b536491e;hpb=c8bd98e0844257ae2e40e01d54546a40596df26d;p=transportpce.git diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index 68d59d543..831cf0d99 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -9,15 +9,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import json -import os -import psutil -import requests -import signal -import shutil -import subprocess -import time +# pylint: disable=no-member +# pylint: disable=too-many-public-methods + import unittest +import time +import requests from common import test_utils @@ -32,6 +29,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -45,11 +43,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_rdm_device_connected(self): - url = ("{}/operational/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.get_netconf_oper_request("ROADM-A1") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -58,11 +52,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): time.sleep(10) def test_03_rdm_portmapping_info(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADM-A1/node-info" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("ROADM-A1/node-info") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -75,57 +65,45 @@ class TransportPCEPortMappingTesting(unittest.TestCase): time.sleep(3) def test_04_rdm_portmapping_DEG1_TTP_TXRX(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADM-A1/mapping/DEG1-TTP-TXRX" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("ROADM-A1/mapping/DEG1-TTP-TXRX") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0', - 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_05_rdm_portmapping_DEG2_TTP_TXRX_with_ots_oms(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADM-A1/mapping/DEG2-TTP-TXRX" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("ROADM-A1/mapping/DEG2-TTP-TXRX") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0', 'logical-connection-point': 'DEG2-TTP-TXRX', 'supporting-oms': 'OMS-DEG2-TTP-TXRX', 'supporting-ots': 'OTS-DEG2-TTP-TXRX', - 'port-direction': 'bidirectional'}, + 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_06_rdm_portmapping_SRG1_PP3_TXRX(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADM-A1/mapping/SRG1-PP3-TXRX" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("ROADM-A1/mapping/SRG1-PP3-TXRX") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0', - 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_07_rdm_portmapping_SRG3_PP1_TXRX(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/ROADM-A1/mapping/SRG3-PP1-TXRX" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("ROADM-A1/mapping/SRG3-PP1-TXRX") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0', - 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_08_xpdr_device_connection(self): @@ -133,11 +111,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_09_xpdr_device_connected(self): - url = ("{}/operational/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.get_netconf_oper_request("XPDR-A1") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -146,11 +120,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): time.sleep(10) def test_10_xpdr_portmapping_info(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDR-A1/node-info" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("XPDR-A1/node-info") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -163,11 +133,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): time.sleep(3) def test_11_xpdr_portmapping_NETWORK1(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDR-A1/mapping/XPDR1-NETWORK1" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("XPDR-A1/mapping/XPDR1-NETWORK1") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -175,15 +141,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1', - 'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd941'}, + 'lcp-hash-val': 'AMkDwQ7xTmRI', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_12_xpdr_portmapping_NETWORK2(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDR-A1/mapping/XPDR1-NETWORK2" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("XPDR-A1/mapping/XPDR1-NETWORK2") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -191,15 +154,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network', - 'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd942'}, + 'lcp-hash-val': 'AMkDwQ7xTmRL', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_13_xpdr_portmapping_CLIENT1(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDR-A1/mapping/XPDR1-CLIENT1" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("XPDR-A1/mapping/XPDR1-CLIENT1") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -208,15 +168,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', - 'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03d8'}, + 'lcp-hash-val': 'AJUUr6I5fALj', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_14_xpdr_portmapping_CLIENT2(self): - url = ("{}/config/transportpce-portmapping:network/" - "nodes/XPDR-A1/mapping/XPDR1-CLIENT2" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) + response = test_utils.portmapping_request("XPDR-A1/mapping/XPDR1-CLIENT2") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -225,7 +182,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): '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'}, + 'lcp-hash-val': 'AJUUr6I5fALg', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_15_xpdr_device_disconnection(self): @@ -233,11 +191,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_16_xpdr_device_disconnected(self): - url = ("{}/operational/network-topology:network-topology/topology/" - "topology-netconf/node/XPDR-A1".format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) - self.assertEqual(response.status_code, requests.codes.not_found) + response = test_utils.get_netconf_oper_request("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.conflict) res = response.json() self.assertIn( {"error-type": "application", "error-tag": "data-missing", @@ -245,10 +200,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res['errors']['error']) def test_17_xpdr_device_not_connected(self): - url = ("{}/config/transportpce-portmapping:network/nodes/XPDR-A1".format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) - self.assertEqual(response.status_code, requests.codes.not_found) + response = test_utils.portmapping_request("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.conflict) res = response.json() self.assertIn( {"error-type": "application", "error-tag": "data-missing", @@ -260,11 +213,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_19_rdm_device_disconnected(self): - url = ("{}/operational/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1" - .format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) - self.assertEqual(response.status_code, requests.codes.not_found) + response = test_utils.get_netconf_oper_request("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.conflict) res = response.json() self.assertIn( {"error-type": "application", "error-tag": "data-missing", @@ -272,10 +222,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res['errors']['error']) def test_20_rdm_device_not_connected(self): - url = ("{}/config/transportpce-portmapping:network/nodes/ROADM-A1".format(test_utils.RESTCONF_BASE_URL)) - response = requests.request( - "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) - self.assertEqual(response.status_code, requests.codes.not_found) + response = test_utils.portmapping_request("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.conflict) res = response.json() self.assertIn( {"error-type": "application", "error-tag": "data-missing",