From: guillaume.lambert Date: Mon, 22 Jun 2020 08:22:23 +0000 (+0200) Subject: improve devices connection methods in tests X-Git-Tag: 2.0.0~80 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=c8bd98e0844257ae2e40e01d54546a40596df26d improve devices connection methods in tests - improve log parser output - move some constants to common/test_utils: - RESTconf base URL - ODL and nodes credentials - json and XML application-type headers - improve functions to mount or unmount devices onto ODL - centralize them in common/test_utils to use the same ones in all tests and speed up tests by removing some timers TODO in next other changes: - use test_utils get/post/del/put_requests methods in all tests - replace the other timers with the log parser - find an alternative to calling 'tail -f' host command - address pylint issues Change-Id: I2b97700e363a3773dcc1606448eedae57c8c6696 Signed-off-by: guillaume.lambert --- diff --git a/tests/transportpce_tests/1.2.1/test_end2end.py b/tests/transportpce_tests/1.2.1/test_end2end.py index 5afdb0e1e..03481040a 100644 --- a/tests/transportpce_tests/1.2.1/test_end2end.py +++ b/tests/transportpce_tests/1.2.1/test_end2end.py @@ -21,11 +21,9 @@ from common import test_utils class TransportPCEFulltesting(unittest.TestCase): - headers = {'content-type': 'application/json'} WAITING = 20 # nominal value is 300 processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -43,84 +41,24 @@ class TransportPCEFulltesting(unittest.TestCase): # connect netconf devices def test_01_connect_xpdrA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_connect_xpdrC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDRC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRC01", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_connect_rdmA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .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": test_utils.sims['roadma-full']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMA01", 'roadma-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_04_connect_rdmC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADMC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc-full']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMC01", 'roadmc-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_05_connect_xprdA_N1_to_roadmA_PP1(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -133,10 +71,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', @@ -145,7 +82,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_06_connect_roadmA_PP1_to_xpdrA_N1(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -158,10 +95,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', @@ -170,7 +106,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_07_connect_xprdC_N1_to_roadmC_PP1(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -183,10 +119,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', @@ -195,7 +130,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_08_connect_roadmC_PP1_to_xpdrC_N1(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -208,10 +143,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', @@ -226,7 +160,7 @@ class TransportPCEFulltesting(unittest.TestCase): "link/ROADMA01-DEG1-DEG1-TTP-TXRXtoROADMC01-DEG2-DEG2-TTP-TXRX/" "org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "clfi": "fiber1", "auto-spanloss": "true", @@ -238,10 +172,9 @@ class TransportPCEFulltesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_10_add_omsAttributes_ROADMC_ROADMA(self): @@ -252,7 +185,7 @@ class TransportPCEFulltesting(unittest.TestCase): "link/ROADMC01-DEG2-DEG2-TTP-TXRXtoROADMA01-DEG1-DEG1-TTP-TXRX/" "org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "clfi": "fiber1", "auto-spanloss": "true", @@ -264,16 +197,15 @@ class TransportPCEFulltesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) # test service-create for Eth service from xpdr to xpdr def test_11_create_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -372,11 +304,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -386,11 +316,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_12_get_eth_service1(self): url = ("{}/operational/org-openroadm-service:service-list/services/" - "service1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + "service1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -411,10 +339,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -442,10 +369,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMC01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -470,9 +396,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -498,9 +424,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -522,9 +448,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -548,7 +474,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_18_connect_xprdA_N2_to_roadmA_PP2(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -561,10 +487,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', @@ -573,7 +498,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_19_connect_roadmA_PP2_to_xpdrA_N2(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -586,10 +511,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', @@ -598,7 +522,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_20_connect_xprdC_N2_to_roadmC_PP2(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -611,10 +535,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', @@ -623,7 +546,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_21_connect_roadmC_PP2_to_xpdrC_N2(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -636,10 +559,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', @@ -648,7 +570,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_22_create_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -747,11 +669,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -762,11 +682,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_23_get_eth_service2(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -787,10 +705,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/DEG1-TTP-TXRX-SRG1-PP2-TXRX-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -813,9 +730,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -841,9 +758,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0][ @@ -879,9 +796,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0][ @@ -911,7 +828,7 @@ class TransportPCEFulltesting(unittest.TestCase): # creation service test on a non-available resource def test_28_create_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1010,11 +927,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -1029,7 +944,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_29_delete_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1044,10 +959,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Service \'service3\' does not exist in datastore', @@ -1059,7 +973,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_30_delete_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1074,10 +988,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1087,7 +1000,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_31_delete_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1102,10 +1015,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1119,9 +1031,9 @@ class TransportPCEFulltesting(unittest.TestCase): "network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, auth=('admin', 'admin')) + "GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertEqual(response.status_code, requests.codes.ok) self.assertNotIn('roadm-connections', @@ -1132,9 +1044,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -1160,9 +1072,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0][ @@ -1186,9 +1098,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0][ @@ -1210,7 +1122,7 @@ class TransportPCEFulltesting(unittest.TestCase): # test service-create for Optical Channel (OC) service from srg-pp to srg-pp def test_36_create_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1309,11 +1221,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -1324,11 +1234,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_37_get_oc_service1(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -1349,10 +1257,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1380,10 +1287,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMC01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1406,7 +1312,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_40_create_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1505,11 +1411,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -1520,11 +1424,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_41_get_oc_service2(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -1545,10 +1447,9 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP2-TXRX-DEG1-TTP-TXRX-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1576,7 +1477,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_44_delete_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1591,10 +1492,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1604,7 +1504,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_45_delete_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1619,10 +1519,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1633,11 +1532,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_46_get_no_oc_services(self): print("start test") url = ("{}/operational/org-openroadm-service:service-list" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -1657,11 +1554,9 @@ class TransportPCEFulltesting(unittest.TestCase): "network-topology/topology/topology-netconf" "/node/ROADMA01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn(['roadm-connections'][0], res['org-openroadm-device']) @@ -1686,11 +1581,11 @@ class TransportPCEFulltesting(unittest.TestCase): def test_50_loop_create_oc_service(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service1" - .format(self.restconf_baseurl)) - response = requests.request("GET", url, auth=('admin', 'admin')) + .format(test_utils.RESTCONF_BASE_URL)) + response = requests.request("GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) if response.status_code != 404: url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1705,10 +1600,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} requests.request("POST", url, data=json.dumps(data), - headers=headers, - auth=('admin', 'admin') + headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD) ) time.sleep(5) @@ -1724,48 +1618,20 @@ class TransportPCEFulltesting(unittest.TestCase): self.test_44_delete_oc_service1() def test_51_disconnect_XPDRA(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_52_disconnect_XPDRC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDRC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_53_disconnect_ROADMA(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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_54_disconnect_ROADMC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADMC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 447e65f31..e7f3a4849 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -27,7 +27,6 @@ class TransportGNPYtesting(unittest.TestCase): os.remove("transportpce_tests/gnpy.log") processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -45,50 +44,47 @@ class TransportGNPYtesting(unittest.TestCase): # Mount the different topologies def test_01_connect_clliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) topo_cllinet_file = "sample_configs/gnpy/clliNetwork.json" if os.path.isfile(topo_cllinet_file): with open(topo_cllinet_file, 'r') as clli_net: body = clli_net.read() - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) def test_02_connect_openroadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) topo_ordnet_file = "sample_configs/gnpy/openroadmNetwork.json" if os.path.isfile(topo_ordnet_file): with open(topo_ordnet_file, 'r') as ord_net: body = ord_net.read() - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) def test_03_connect_openroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) topo_ordtopo_file = "sample_configs/gnpy/openroadmTopology.json" if os.path.isfile(topo_ordtopo_file): with open(topo_ordtopo_file, 'r') as ord_topo: body = ord_topo.read() - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) # Path computed by PCE is feasible according to Gnpy def test_04_path_computation_FeasibleWithPCE(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = { "input": { "service-name": "service-1", @@ -111,11 +107,9 @@ class TransportGNPYtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -135,7 +129,7 @@ class TransportGNPYtesting(unittest.TestCase): # another one (low SNR) def test_05_path_computation_FoundByPCE_NotFeasibleByGnpy(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = { "input": { "service-name": "service-2", @@ -182,11 +176,9 @@ class TransportGNPYtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -207,7 +199,7 @@ class TransportGNPYtesting(unittest.TestCase): # #PCE cannot find a path while GNPy finds a feasible one def test_06_path_computation_NotFoundByPCE_FoundByGNPy(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = { "input": { "service-name": "service-3", @@ -248,11 +240,9 @@ class TransportGNPYtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -271,7 +261,7 @@ class TransportGNPYtesting(unittest.TestCase): # Not found path by PCE and GNPy cannot find another one def test_07_path_computation_FoundByPCE_NotFeasibleByGnpy(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = { "input": { "service-name": "service-4", @@ -324,11 +314,9 @@ class TransportGNPYtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -341,34 +329,31 @@ class TransportGNPYtesting(unittest.TestCase): # Disconnect the different topologies def test_08_disconnect_openroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) def test_09_disconnect_openroadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) def test_10_disconnect_clliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(3) diff --git a/tests/transportpce_tests/1.2.1/test_olm.py b/tests/transportpce_tests/1.2.1/test_olm.py index 7d4a7698a..1f5b736dd 100644 --- a/tests/transportpce_tests/1.2.1/test_olm.py +++ b/tests/transportpce_tests/1.2.1/test_olm.py @@ -25,7 +25,6 @@ from common import test_utils class TransportOlmTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -43,83 +42,23 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(1) def test_01_xpdrA_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_xpdrC_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDRC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRC01", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_rdmA_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .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": test_utils.sims['roadma-full']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMA01", 'roadma-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_04_rdmC_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADMC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc-full']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMC01", 'roadmc-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_05_connect_xprdA_to_roadmA(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -132,16 +71,15 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_06_connect_roadmA_to_xpdrA(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -154,16 +92,15 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_07_connect_xprdC_to_roadmC(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -176,16 +113,15 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_08_connect_roadmC_to_xpdrC(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -198,50 +134,47 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_09_create_OTS_ROADMA(self): - url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADMA01", "logical-connection-point": "DEG1-TTP-TXRX" } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Interfaces OTS-DEG1-TTP-TXRX - OMS-DEG1-TTP-TXRX successfully created on node ROADMA01', res["output"]["result"]) def test_10_create_OTS_ROADMC(self): - url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADMC01", "logical-connection-point": "DEG2-TTP-TXRX" } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Interfaces OTS-DEG2-TTP-TXRX - OMS-DEG2-TTP-TXRX successfully created on node ROADMC01', res["output"]["result"]) def test_11_get_PM_ROADMA(self): - url = "{}/operations/transportpce-olm:get-pm".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:get-pm".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADMA01", @@ -252,10 +185,9 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({ @@ -272,7 +204,7 @@ class TransportOlmTesting(unittest.TestCase): }, res["output"]["measurements"]) def test_12_get_PM_ROADMC(self): - url = "{}/operations/transportpce-olm:get-pm".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:get-pm".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADMC01", @@ -283,10 +215,9 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({ @@ -303,17 +234,16 @@ class TransportOlmTesting(unittest.TestCase): }, res["output"]["measurements"]) def test_13_calculate_span_loss_base_ROADMA_ROADMC(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "src-type": "link", "link-id": "ROADMA01-DEG1-DEG1-TTP-TXRXtoROADMC01-DEG2-DEG2-TTP-TXRX" } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -325,16 +255,15 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(5) def test_14_calculate_span_loss_base_all(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "src-type": "all" } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -352,10 +281,9 @@ class TransportOlmTesting(unittest.TestCase): def test_15_get_OTS_DEG1_TTP_TXRX_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/interface/OTS-DEG1-TTP-TXRX/" - "org-openroadm-optical-transport-interfaces:ots".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "org-openroadm-optical-transport-interfaces:ots".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(5.7, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) @@ -364,17 +292,16 @@ class TransportOlmTesting(unittest.TestCase): def test_16_get_OTS_DEG2_TTP_TXRX_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMC01/yang-ext:mount/org-openroadm-device:org-openroadm-device/interface/OTS-DEG2-TTP-TXRX/" - "org-openroadm-optical-transport-interfaces:ots".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "org-openroadm-optical-transport-interfaces:ots".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(15.1, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) self.assertEqual(5.7, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-receive']) def test_17_servicePath_create_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -405,10 +332,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -416,7 +342,7 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(10) def test_18_servicePath_create_ZToA(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -447,10 +373,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -458,7 +383,7 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(10) def test_19_service_power_setup_XPDRA_XPDRC(self): - url = "{}/operations/transportpce-olm:service-power-setup".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-setup".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -487,10 +412,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -498,10 +422,9 @@ class TransportOlmTesting(unittest.TestCase): def test_20_get_interface_XPDRA_XPDR1_NETWORK1(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDRA01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK1-1/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(0, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) @@ -510,10 +433,9 @@ class TransportOlmTesting(unittest.TestCase): def test_21_get_roadmconnection_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMA01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("gainLoss", res['roadm-connections'][0]['opticalControlMode']) @@ -522,16 +444,15 @@ class TransportOlmTesting(unittest.TestCase): def test_22_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMC01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "DEG2-TTP-TXRX-SRG1-PP1-TXRX-1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "DEG2-TTP-TXRX-SRG1-PP1-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("power", res['roadm-connections'][0]['opticalControlMode']) def test_23_service_power_setup_XPDRC_XPDRA(self): - url = "{}/operations/transportpce-olm:service-power-setup".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-setup".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -560,10 +481,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -571,10 +491,9 @@ class TransportOlmTesting(unittest.TestCase): def test_24_get_interface_XPDRC_XPDR1_NETWORK1(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDRC01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK1-1/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(0, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) @@ -583,17 +502,16 @@ class TransportOlmTesting(unittest.TestCase): def test_25_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMC01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("gainLoss", res['roadm-connections'][0]['opticalControlMode']) self.assertEqual(2, res['roadm-connections'][0]['target-output-power']) def test_26_service_power_turndown_XPDRA_XPDRC(self): - url = "{}/operations/transportpce-olm:service-power-turndown".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-turndown".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -622,10 +540,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -633,10 +550,9 @@ class TransportOlmTesting(unittest.TestCase): def test_27_get_roadmconnection_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMA01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("off", res['roadm-connections'][0]['opticalControlMode']) @@ -645,16 +561,15 @@ class TransportOlmTesting(unittest.TestCase): def test_28_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADMC01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "DEG2-TTP-TXRX-SRG1-PP1-TXRX-1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "DEG2-TTP-TXRX-SRG1-PP1-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("off", res['roadm-connections'][0]['opticalControlMode']) def test_29_servicePath_delete_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -685,17 +600,16 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) def test_30_servicePath_delete_ZToA(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -726,10 +640,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) @@ -738,7 +651,7 @@ class TransportOlmTesting(unittest.TestCase): """to test case where SRG where the xpdr is connected to has no optical range data""" def test_31_connect_xprdA_to_roadmA(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -751,16 +664,15 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_32_connect_roadmA_to_xpdrA(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -773,16 +685,15 @@ class TransportOlmTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_33_servicePath_create_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test2", @@ -803,10 +714,9 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -816,17 +726,16 @@ class TransportOlmTesting(unittest.TestCase): def test_34_get_interface_XPDRA_XPDR1_NETWORK2(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDRA01/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK2-2/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(-5, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) self.assertEqual(2, res['org-openroadm-optical-channel-interfaces:och']['wavelength-number']) def test_35_servicePath_delete_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -847,42 +756,26 @@ class TransportOlmTesting(unittest.TestCase): ] } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) def test_36_xpdrA_device_disconnected(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_37_xpdrC_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDRC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_38_calculate_span_loss_current(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-current".format(self.restconf_baseurl) - headers = {'content-type': 'application/json'} + url = "{}/operations/transportpce-olm:calculate-spanloss-current".format(test_utils.RESTCONF_BASE_URL) response = requests.request( - "POST", url, headers=headers, auth=('admin', 'admin')) + "POST", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -890,26 +783,12 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(5) def test_39_rdmA_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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_40_rdmC_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADMC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/1.2.1/test_pce.py b/tests/transportpce_tests/1.2.1/test_pce.py index 8a87a9bb2..fb824f80d 100644 --- a/tests/transportpce_tests/1.2.1/test_pce.py +++ b/tests/transportpce_tests/1.2.1/test_pce.py @@ -45,7 +45,6 @@ class TransportPCEtesting(unittest.TestCase): cls.complex_topo_uni_dir_data = topo_uni_dir_complex.read() processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -64,24 +63,20 @@ class TransportPCEtesting(unittest.TestCase): # Load simple bidirectional topology def test_01_load_simple_topology_bi(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = self.simple_topo_bi_dir_data - headers = {'content-type': 'application/xml', - "Accept": "application/xml"} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_XML, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) # Get existing nodeId def test_02_get_nodeId(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -91,11 +86,9 @@ class TransportPCEtesting(unittest.TestCase): # Get existing linkId def test_03_get_linkId(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/link/XPDRA01-XPDR1-XPDR1-NETWORK1toROADMA01-SRG1-SRG1-PP1-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -106,7 +99,7 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_04_path_computation_xpdr_bi(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service-1", "resource-reserve": "true", @@ -128,11 +121,9 @@ class TransportPCEtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -142,7 +133,7 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_05_path_computation_rdm_bi(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service-1", "resource-reserve": "true", @@ -164,11 +155,9 @@ class TransportPCEtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -178,46 +167,38 @@ class TransportPCEtesting(unittest.TestCase): # Delete topology def test_06_delete_simple_topology_bi(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/xml', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "DELETE", url, headers=headers, auth=('admin', 'admin')) + "DELETE", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) # Test deleted topology def test_07_test_topology_simple_bi_deleted(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, 404) time.sleep(1) # Load simple bidirectional topology def test_08_load_simple_topology_uni(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = self.simple_topo_uni_dir_data - headers = {'content-type': 'application/xml', - "Accept": "application/xml"} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_XML, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, 201) time.sleep(2) # Get existing nodeId def test_09_get_nodeId(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPONDER-1-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -228,11 +209,9 @@ class TransportPCEtesting(unittest.TestCase): # Get existing linkId def test_10_get_linkId(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/link/XPONDER-1-2XPDR-NW1-TX-toOpenROADM-1-2-SRG1-SRG1-PP1-RX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -243,7 +222,7 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_11_path_computation_xpdr_uni(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service-1", "resource-reserve": "true", @@ -265,11 +244,9 @@ class TransportPCEtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -279,7 +256,7 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_12_path_computation_rdm_uni(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service1", "resource-reserve": "true", @@ -301,11 +278,9 @@ class TransportPCEtesting(unittest.TestCase): "pce-metric": "hop-count" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -327,46 +302,38 @@ class TransportPCEtesting(unittest.TestCase): # Delete topology def test_13_delete_simple_topology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/xml', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "DELETE", url, headers=headers, auth=('admin', 'admin')) + "DELETE", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) # Test deleted topology def test_14_test_topology_simple_deleted(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPONDER-1-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, 404) time.sleep(1) # Load complex topology def test_15_load_complex_topology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = self.complex_topo_uni_dir_data - headers = {'content-type': 'application/xml', - "Accept": "application/json"} response = requests.request( - "PUT", url, data=body, headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=body, headers=test_utils.TYPE_APPLICATION_XML, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, 201) time.sleep(2) # Get existing nodeId def test_16_get_nodeId(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPONDER-3-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -377,18 +344,16 @@ class TransportPCEtesting(unittest.TestCase): # Test failed path computation def test_17_fail_path_computation(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-handler-header": { "request-id": "request-1" } } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Service Name is not set', @@ -398,7 +363,7 @@ class TransportPCEtesting(unittest.TestCase): # Test1 success path computation def test_18_success1_path_computation(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service1", "resource-reserve": "true", @@ -485,11 +450,9 @@ class TransportPCEtesting(unittest.TestCase): "locally-protected-links": "true" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -499,7 +462,7 @@ class TransportPCEtesting(unittest.TestCase): # Test2 success path computation with path description def test_19_success2_path_computation(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service 1", "resource-reserve": "true", @@ -521,11 +484,9 @@ class TransportPCEtesting(unittest.TestCase): "pce-metric": "hop-count" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -539,7 +500,7 @@ class TransportPCEtesting(unittest.TestCase): # Test3 success path computation with hard-constraints exclude def test_20_success3_path_computation(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service 1", "resource-reserve": "true", @@ -566,11 +527,9 @@ class TransportPCEtesting(unittest.TestCase): "pce-metric": "hop-count" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -584,7 +543,7 @@ class TransportPCEtesting(unittest.TestCase): # Path computation before deleting oms-attribute of the link :openroadm1-3 to openroadm1-2 def test_21_path_computation_before_oms_attribute_deletion(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service 1", "resource-reserve": "true", @@ -606,11 +565,9 @@ class TransportPCEtesting(unittest.TestCase): "pce-metric": "hop-count" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -631,18 +588,16 @@ class TransportPCEtesting(unittest.TestCase): def test_22_delete_oms_attribute_in_openroadm13toopenroadm12_link(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:link/" "OpenROADM-1-3-DEG2-to-OpenROADM-1-2-DEG2/org-openroadm-network-topology:OMS-attributes/span" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/xml', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "DELETE", url, headers=headers, auth=('admin', 'admin')) + "DELETE", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) # Path computation after deleting oms-attribute of the link :openroadm1-3 to openroadm1-2 def test_23_path_computation_after_oms_attribute_deletion(self): url = ("{}/operations/transportpce-pce:path-computation-request" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) body = {"input": { "service-name": "service 1", "resource-reserve": "true", @@ -664,11 +619,9 @@ class TransportPCEtesting(unittest.TestCase): "pce-metric": "hop-count" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(body), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -688,22 +641,18 @@ class TransportPCEtesting(unittest.TestCase): # Delete complex topology def test_24_delete_complex_topology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/xml', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "DELETE", url, headers=headers, auth=('admin', 'admin')) + "DELETE", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) # Test deleted complex topology def test_25_test_topology_complex_deleted(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPONDER-3-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, 404) time.sleep(1) diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index d9f91e48b..68b74d413 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -21,7 +21,6 @@ from common import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -40,19 +39,17 @@ class TransportPCEPortMappingTesting(unittest.TestCase): # def test_01_restconfAPI(self): # url = ("{}/operational/network-topology:network-topology/topology/" -# "topology-netconf/node/controller-config".format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json'} -# response = requests.request("GET", url, headers=headers, auth=('admin', 'admin')) +# "topology-netconf/node/controller-config".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.ok) # res = response.json() # self.assertEqual(res['node'] [0] ['netconf-node-topology:connection-status'], # 'connected') # def test_02_restconfAPI(self): -# url = ("{}/config/transportpce-portmapping:network/nodes/controller-config".format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json'} +# url = ("{}/config/transportpce-portmapping:network/nodes/controller-config".format(test_utils.RESTCONF_BASE_URL)) # response = requests.request( -# "GET", url, headers=headers, auth=('admin', 'admin')) +# "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) # res = response.json() # self.assertIn( @@ -60,32 +57,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): # "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)) - 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": test_utils.sims['roadma']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + def test_01_rdm_device_connection(self): + response = test_utils.mount_device("ROADMA01", 'roadma') + 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/ROADMA01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -96,10 +77,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 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'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -114,10 +94,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_04_rdm_portmapping_DEG1_TTP_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADMA01/mapping/DEG1-TTP-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -128,10 +107,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_05_rdm_portmapping_SRG1_PP7_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADMA01/mapping/SRG1-PP7-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -142,10 +120,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_06_rdm_portmapping_SRG3_PP1_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADMA01/mapping/SRG3-PP1-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -153,32 +130,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, res['mapping']) - def test_07_xpdr_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + def test_07_xpdr_device_connection(self): + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_08_xpdr_device_connected(self): url = ("{}/operational/network-topology:" "network-topology/topology/topology-netconf/node/XPDRA01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -189,10 +150,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 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'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -207,10 +167,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_10_xpdr_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01/mapping/XPDR1-NETWORK1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -223,10 +182,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_11_xpdr_portmapping_NETWORK2(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01/mapping/XPDR1-NETWORK2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -239,10 +197,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_12_xpdr_portmapping_CLIENT1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01/mapping/XPDR1-CLIENT1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -256,10 +213,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_13_xpdr_portmapping_CLIENT2(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01/mapping/XPDR1-CLIENT2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -273,10 +229,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_14_xpdr_portmapping_CLIENT3(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01/mapping/XPDR1-CLIENT3" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -290,10 +245,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 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'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -303,23 +257,15 @@ class TransportPCEPortMappingTesting(unittest.TestCase): '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" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + def test_16_xpdr_device_disconnection(self): + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_17_xpdr_device_disconnected(self): url = ("{}/operational/network-topology:network-topology/topology/" - "topology-netconf/node/XPDRA01".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "topology-netconf/node/XPDRA01".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -327,11 +273,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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): - url = ("{}/config/transportpce-portmapping:network/nodes/XPDRA01".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + def test_18_xpdr_device_not_connected(self): + url = ("{}/config/transportpce-portmapping:network/nodes/XPDRA01".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -339,22 +284,15 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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): - 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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + def test_19_rdm_device_disconnection(self): + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) 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'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -362,11 +300,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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): - url = ("{}/config/transportpce-portmapping:network/nodes/ROADMA01".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + def test_21_rdm_device_not_connected(self): + url = ("{}/config/transportpce-portmapping:network/nodes/ROADMA01".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( diff --git a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py index 6ccec33b3..8d2d33de5 100644 --- a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py @@ -25,7 +25,6 @@ from common import test_utils class TransportPCERendererTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -43,50 +42,19 @@ class TransportPCERendererTesting(unittest.TestCase): time.sleep(10) def test_01_rdm_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .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": test_utils.sims['roadma']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMA01", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_xpdr_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_rdm_portmapping(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADMA01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -101,10 +69,9 @@ class TransportPCERendererTesting(unittest.TestCase): def test_04_xpdr_portmapping(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDRA01" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -122,7 +89,7 @@ class TransportPCERendererTesting(unittest.TestCase): res['nodes'][0]['mapping']) def test_05_service_path_create(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "renderer:service-name": "service_test", "renderer:wave-number": "7", @@ -135,10 +102,9 @@ class TransportPCERendererTesting(unittest.TestCase): {"renderer:node-id": "XPDRA01", "renderer:src-tp": "XPDR1-CLIENT1", "renderer:dest-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes: ROADMA01', res["output"]["result"]) @@ -147,10 +113,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -172,10 +137,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP7-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -197,10 +161,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP7-TXRX-DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -223,10 +186,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -251,10 +213,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -278,10 +239,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the 2 following statements replace self.assertDictContainsSubset deprecated in python 3.2 @@ -310,10 +270,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -339,16 +298,15 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-NET" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('not-reserved-inuse', res['circuit-packs'][0]["equipment-state"]) def test_14_service_path_delete(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "renderer:service-name": "service_test", "renderer:wave-number": "7", @@ -360,10 +318,9 @@ class TransportPCERendererTesting(unittest.TestCase): {"renderer:node-id": "XPDRA01", "renderer:src-tp": "XPDR1-CLIENT1", "renderer:dest-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) self.assertEqual(response.json(), { 'output': {'result': 'Request processed', 'success': True}}) @@ -372,10 +329,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -387,10 +343,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP7-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -402,10 +357,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP7-TXRX-DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -417,10 +371,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-7" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -432,10 +385,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -447,10 +399,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -462,10 +413,9 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -477,35 +427,20 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-NET" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual('not-reserved-available', res["circuit-packs"][0]['equipment-state']) def test_23_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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_24_xpdr_device_disconnected(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py index 2a41e52f8..369cea38f 100644 --- a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py @@ -21,7 +21,6 @@ from common import test_utils class TransportPCEtesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -39,31 +38,15 @@ class TransportPCEtesting(unittest.TestCase): # Connect the ROADMA def test_01_connect_rdm(self): - # Config ROADMA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .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": test_utils.sims['roadma']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMA01", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # Verify the termination points of the ROADMA def test_02_compareOpenroadmTopologyPortMapping_rdm(self): urlTopo = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - responseTopo = requests.request("GET", urlTopo, headers=headers, auth=('admin', 'admin')) + .format(test_utils.RESTCONF_BASE_URL)) + responseTopo = requests.request("GET", urlTopo, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) resTopo = responseTopo.json() nbNode = len(resTopo['network'][0]['node']) nbMapCumul = 0 @@ -72,8 +55,9 @@ class TransportPCEtesting(unittest.TestCase): nodeId = resTopo['network'][0]['node'][i]['node-id'] nodeMapId = nodeId.split("-")[0] urlMapList = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId - urlMapListFull = urlMapList.format(self.restconf_baseurl) - responseMapList = requests.request("GET", urlMapListFull, headers=headers, auth=('admin', 'admin')) + urlMapListFull = urlMapList.format(test_utils.RESTCONF_BASE_URL) + responseMapList = requests.request("GET", urlMapListFull, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) resMapList = responseMapList.json() nbMappings = len(resMapList['nodes'][0]['mapping']) - nbMapCumul @@ -83,8 +67,9 @@ class TransportPCEtesting(unittest.TestCase): tpId = resTopo['network'][0]['node'][i]['ietf-network-topology:termination-point'][j]['tp-id'] if((not "CP" in tpId) and (not "CTP" in tpId)): urlMap = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId + "/mapping/" + tpId - urlMapFull = urlMap.format(self.restconf_baseurl) - responseMap = requests.request("GET", urlMapFull, headers=headers, auth=('admin', 'admin')) + urlMapFull = urlMap.format(test_utils.RESTCONF_BASE_URL) + responseMap = requests.request("GET", urlMapFull, headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(responseMap.status_code, requests.codes.ok) if responseMap.status_code == requests.codes.ok: nbMapCurrent += 1 @@ -94,36 +79,13 @@ class TransportPCEtesting(unittest.TestCase): # Disconnect the ROADMA def test_03_disconnect_rdm(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # #Connect the XPDRA def test_04_connect_xpdr(self): - # Config XPDRA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # #Verify the termination points related to XPDR def test_05_compareOpenroadmTopologyPortMapping_xpdr(self): @@ -131,15 +93,8 @@ class TransportPCEtesting(unittest.TestCase): # Disconnect the XPDRA def test_06_disconnect_device(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/1.2.1/test_topology.py b/tests/transportpce_tests/1.2.1/test_topology.py index bb3867ac3..5f5d5abf7 100644 --- a/tests/transportpce_tests/1.2.1/test_topology.py +++ b/tests/transportpce_tests/1.2.1/test_topology.py @@ -21,7 +21,6 @@ from common import test_utils class TransportPCETopologyTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -38,31 +37,14 @@ class TransportPCETopologyTesting(unittest.TestCase): time.sleep(5) def test_01_connect_ROADMA(self): - # Config ROADMA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .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": test_utils.sims['roadma']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMA01", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'NodeA') @@ -70,10 +52,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_03_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'ROADMA01') @@ -84,10 +65,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_04_getLinks_OpenroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -121,9 +101,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_05_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request("GET", url, headers=headers, auth=('admin', 'admin')) + .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)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -190,29 +170,14 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_06_connect_XPDRA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .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": test_utils.sims['xpdra']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(30) + response = test_utils.mount_device("XPDRA01", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_07_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request("GET", url, headers=headers, auth=('admin', 'admin')) + .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.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'NodeA') @@ -220,10 +185,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_08_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -243,10 +207,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_09_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -332,7 +295,7 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_10_connect_tail_xpdr_rdm(self): # Connect the tail: XPDRA to ROADMA url = ("{}/operations/transportpce-networkutils:init-xpdr-rdm-links" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"networkutils:input": { "networkutils:links-input": { "networkutils:xpdr-node": "XPDRA01", @@ -344,16 +307,15 @@ class TransportPCETopologyTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_11_connect_tail_rdm_xpdr(self): # Connect the tail: ROADMA to XPDRA url = ("{}/operations/transportpce-networkutils:init-rdm-xpdr-links" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"networkutils:input": { "networkutils:links-input": { "networkutils:xpdr-node": "XPDRA01", @@ -365,18 +327,16 @@ class TransportPCETopologyTesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_12_getLinks_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -422,31 +382,15 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(XPDR_OUT), 0) def test_13_connect_ROADMC(self): - # Config ROADMC - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADMC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMC01", 'roadmc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_14_omsAttributes_ROADMA_ROADMC(self): # Config ROADMA01-ROADMC01 oms-attributes url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMA01-DEG1-DEG1-TTP-TXRXtoROADMC01-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -455,10 +399,9 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_15_omsAttributes_ROADMC_ROADMA(self): @@ -466,7 +409,7 @@ class TransportPCETopologyTesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMC01-DEG2-DEG2-TTP-TXRXtoROADMA01-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -475,18 +418,16 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_16_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -505,10 +446,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_17_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -538,10 +478,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_18_getROADMLinkOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -597,10 +536,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_19_getLinkOmsAttributesOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -625,10 +563,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_20_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -736,30 +673,15 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_21_connect_ROADMB(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMB01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADMB01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmb']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADMB01", 'roadmb') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_22_omsAttributes_ROADMA_ROADMB(self): # Config ROADMA01-ROADMB01 oms-attributes url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMA01-DEG2-DEG2-TTP-TXRXtoROADMB01-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -768,10 +690,9 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_23_omsAttributes_ROADMB_ROADMA(self): @@ -779,7 +700,7 @@ class TransportPCETopologyTesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMB01-DEG1-DEG1-TTP-TXRXtoROADMA01-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -788,10 +709,9 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_24_omsAttributes_ROADMB_ROADMC(self): @@ -799,7 +719,7 @@ class TransportPCETopologyTesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMB01-DEG2-DEG2-TTP-TXRXtoROADMC01-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -808,10 +728,9 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_25_omsAttributes_ROADMC_ROADMB(self): @@ -819,7 +738,7 @@ class TransportPCETopologyTesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMC01-DEG1-DEG1-TTP-TXRXtoROADMB01-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -828,18 +747,16 @@ class TransportPCETopologyTesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_26_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -859,10 +776,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_27_verifyDegree(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -880,10 +796,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_28_verifyOppositeLinkTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -897,9 +812,9 @@ class TransportPCETopologyTesting(unittest.TestCase): oppLink_id = res['network'][0]['ietf-network-topology:link'][i]['org-openroadm-common-network:opposite-link'] # Find the opposite link url_oppLink = "{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:link/"+oppLink_id - url = (url_oppLink.format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response_oppLink = requests.request("GET", url, headers=headers, auth=('admin', 'admin')) + url = (url_oppLink.format(test_utils.RESTCONF_BASE_URL)) + response_oppLink = requests.request( + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response_oppLink.status_code, requests.codes.ok) res_oppLink = response_oppLink.json() self.assertEqual(res_oppLink['ietf-network-topology:link'][0] @@ -922,10 +837,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_29_getLinkOmsAttributesOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) @@ -952,52 +866,34 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_30_disconnect_ROADMB(self): # Delete in the topology-netconf - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMB01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADMB01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeB" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_31_disconnect_ROADMC(self): - # Delete in the topology-netconf - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADMC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeC" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_32_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -1077,10 +973,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_33_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1091,10 +986,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_34_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1103,22 +997,14 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertNotEqual(res['network'][0]['node'][1]['org-openroadm-clli-network:clli'], 'NodeC') def test_35_disconnect_XPDRA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRA01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_36_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1127,10 +1013,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_37_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1140,10 +1025,9 @@ class TransportPCETopologyTesting(unittest.TestCase): def test_38_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -1197,30 +1081,27 @@ class TransportPCETopologyTesting(unittest.TestCase): # Link-1 url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/XPDRA01-XPDR1-XPDR1-NETWORK1toROADMA01-SRG1-SRG1-PP1-TXRX" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) # Link-2 url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADMA01-SRG1-SRG1-PP1-TXRXtoXPDRA01-XPDR1-XPDR1-NETWORK1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_40_getLinks_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) @@ -1261,51 +1142,40 @@ class TransportPCETopologyTesting(unittest.TestCase): ['org-openroadm-common-network:link-type'], 'XPONDER-INPUT') def test_41_disconnect_ROADMA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMA01" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeA" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_42_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_43_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_44_check_roadm2roadm_link_persistence(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) diff --git a/tests/transportpce_tests/2.2.1/test_end2end.py b/tests/transportpce_tests/2.2.1/test_end2end.py index 755d0c668..dd92540c4 100644 --- a/tests/transportpce_tests/2.2.1/test_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_end2end.py @@ -24,7 +24,6 @@ from common import test_utils class TransportPCEFulltesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" WAITING = 20 # nominal value is 300 @classmethod @@ -41,85 +40,24 @@ class TransportPCEFulltesting(unittest.TestCase): def setUp(self): # instruction executed before each test method print("execution of {}".format(self.id().split(".")[-1])) -# connect netconf devices def test_01_connect_xpdrA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_connect_xpdrC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-C1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDR-C1", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_connect_rdmA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_04_connect_rdmC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-C1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-C1", 'roadmc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_05_connect_xprdA_N1_to_roadmA_PP1(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -132,17 +70,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) time.sleep(2) def test_06_connect_roadmA_PP1_to_xpdrA_N1(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -155,17 +92,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) time.sleep(2) def test_07_connect_xprdC_N1_to_roadmC_PP1(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -178,17 +114,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) time.sleep(2) def test_08_connect_roadmC_PP1_to_xpdrC_N1(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -201,10 +136,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) @@ -215,7 +149,7 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "spanloss-base": 11.4, @@ -226,10 +160,9 @@ class TransportPCEFulltesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_10_add_omsAttributes_ROADMC_ROADMA(self): @@ -237,7 +170,7 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "spanloss-base": 11.4, @@ -248,16 +181,15 @@ class TransportPCEFulltesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) # test service-create for Eth service from xpdr to xpdr def test_11_create_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -346,11 +278,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -359,11 +289,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_12_get_eth_service1(self): url = ("{}/operational/org-openroadm-service:service-list/services/service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -380,10 +308,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -407,10 +334,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-C1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -432,9 +358,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_15_check_topo_XPDRA(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPDR-A1-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -451,9 +377,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_16_check_topo_ROADMA_SRG1(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -470,9 +396,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_17_check_topo_ROADMA_DEG1(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-DEG2" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -490,7 +416,7 @@ class TransportPCEFulltesting(unittest.TestCase): time.sleep(3) def test_18_connect_xprdA_N2_to_roadmA_PP2(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -503,17 +429,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) time.sleep(2) def test_19_connect_roadmA_PP2_to_xpdrA_N2(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -526,17 +451,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) time.sleep(2) def test_20_connect_xprdC_N2_to_roadmC_PP2(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -549,17 +473,16 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) time.sleep(2) def test_21_connect_roadmC_PP2_to_xpdrC_N2(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -572,10 +495,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) @@ -583,7 +505,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_22_create_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -672,11 +594,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -685,11 +605,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_23_get_eth_service2(self): url = ("{}/operational/org-openroadm-service:service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -707,10 +625,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/DEG2-TTP-TXRX-SRG1-PP2-TXRX-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -730,9 +647,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_25_check_topo_XPDRA(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPDR-A1-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -751,9 +668,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_26_check_topo_ROADMA_SRG1(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0] @@ -781,9 +698,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_27_check_topo_ROADMA_DEG2(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-DEG2" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0] @@ -809,7 +726,7 @@ class TransportPCEFulltesting(unittest.TestCase): # creation service test on a non-available resource def test_28_create_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -898,11 +815,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -913,7 +828,7 @@ class TransportPCEFulltesting(unittest.TestCase): # add a test that check the openroadm-service-list still only contains 2 elements def test_29_delete_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -927,10 +842,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Service \'service3\' does not exist in datastore', @@ -940,7 +854,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_30_delete_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -954,10 +868,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -966,7 +879,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_31_delete_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -980,10 +893,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -993,9 +905,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_32_check_no_xc_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, auth=('admin', 'admin')) + "GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertEqual(response.status_code, requests.codes.ok) self.assertNotIn('roadm-connections', dict.keys(res['org-openroadm-device'])) @@ -1003,9 +915,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_33_check_topo_XPDRA(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/XPDR-A1-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -1021,9 +933,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_34_check_topo_ROADMA_SRG1(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0] @@ -1040,9 +952,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_35_check_topo_ROADMA_DEG2(self): url1 = ("{}/config/ietf-network:networks/network/openroadm-topology/node/ROADM-A1-DEG2" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0] @@ -1060,7 +972,7 @@ class TransportPCEFulltesting(unittest.TestCase): # test service-create for Optical Channel (OC) service from srg-pp to srg-pp def test_36_create_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1149,11 +1061,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -1162,11 +1072,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_37_get_oc_service1(self): url = ("{}/operational/org-openroadm-service:service-list/services/service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -1184,10 +1092,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1211,10 +1118,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-C1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1236,7 +1142,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_40_create_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1325,11 +1231,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('PCE calculation in progress', @@ -1338,11 +1242,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_41_get_oc_service2(self): url = ("{}/operational/org-openroadm-service:service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -1360,10 +1262,9 @@ class TransportPCEFulltesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP2-TXRX-DEG2-TTP-TXRX-2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -1390,7 +1291,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_44_delete_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1404,10 +1305,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1416,7 +1316,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_45_delete_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1430,10 +1330,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Renderer service delete in progress', @@ -1443,11 +1342,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_46_get_no_oc_services(self): print("start test") url = ("{}/operational/org-openroadm-service:service-list" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -1459,11 +1356,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_47_get_no_xc_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf" "/node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn(['roadm-connections'][0], res['org-openroadm-device']) @@ -1487,11 +1382,11 @@ class TransportPCEFulltesting(unittest.TestCase): def test_50_loop_create_oc_service(self): url = ("{}/operational/org-openroadm-service:service-list/services/service1" - .format(self.restconf_baseurl)) - response = requests.request("GET", url, auth=('admin', 'admin')) + .format(test_utils.RESTCONF_BASE_URL)) + response = requests.request("GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) if response.status_code != 404: url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1505,8 +1400,8 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} - requests.request("POST", url, data=json.dumps(data), headers=headers, auth=('admin', 'admin')) + requests.request("POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(5) for i in range(1, 6): @@ -1521,48 +1416,20 @@ class TransportPCEFulltesting(unittest.TestCase): self.test_44_delete_oc_service1() def test_51_disconnect_XPDRA(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_52_disconnect_XPDRC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDR-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_53_disconnect_ROADMA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_54_disconnect_ROADMC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADM-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/2.2.1/test_olm.py b/tests/transportpce_tests/2.2.1/test_olm.py index 09b5e2ed3..f52325bfe 100644 --- a/tests/transportpce_tests/2.2.1/test_olm.py +++ b/tests/transportpce_tests/2.2.1/test_olm.py @@ -25,7 +25,6 @@ from common import test_utils class TransportOlmTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -43,83 +42,23 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(1) def test_01_xpdrA_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_xpdrC_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-C1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['xpdrc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDR-C1", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_rdmA_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_04_rdmC_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-C1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-C1", 'roadmc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_05_connect_xprdA_to_roadmA(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -135,13 +74,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_06_connect_roadmA_to_xpdrA(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -157,13 +96,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_07_connect_xprdC_to_roadmC(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -179,13 +118,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_08_connect_roadmC_to_xpdrC(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -201,13 +140,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_09_create_OTS_ROADMA(self): - url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADM-A1", @@ -217,7 +156,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(10) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -225,7 +164,7 @@ class TransportOlmTesting(unittest.TestCase): res["output"]["result"]) def test_10_create_OTS_ROADMC(self): - url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:create-ots-oms".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADM-C1", @@ -235,14 +174,14 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Interfaces OTS-DEG2-TTP-TXRX - OMS-DEG2-TTP-TXRX successfully created on node ROADM-C1', res["output"]["result"]) def test_11_get_PM_ROADMA(self): - url = "{}/operations/transportpce-olm:get-pm".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:get-pm".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADM-A1", @@ -256,7 +195,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({ @@ -273,7 +212,7 @@ class TransportOlmTesting(unittest.TestCase): }, res["output"]["measurements"]) def test_12_get_PM_ROADMC(self): - url = "{}/operations/transportpce-olm:get-pm".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:get-pm".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "node-id": "ROADM-C1", @@ -287,7 +226,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({ @@ -304,7 +243,7 @@ class TransportOlmTesting(unittest.TestCase): }, res["output"]["measurements"]) def test_13_calculate_span_loss_base_ROADMA_ROADMC(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "src-type": "link", @@ -314,7 +253,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -326,7 +265,7 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(5) def test_14_calculate_span_loss_base_all(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:calculate-spanloss-base".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "src-type": "all" @@ -335,7 +274,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -353,10 +292,10 @@ class TransportOlmTesting(unittest.TestCase): def test_15_get_OTS_DEG2_TTP_TXRX_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/interface/OTS-DEG2-TTP-TXRX/" - "org-openroadm-optical-transport-interfaces:ots".format(self.restconf_baseurl)) + "org-openroadm-optical-transport-interfaces:ots".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(17.6, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) @@ -365,17 +304,17 @@ class TransportOlmTesting(unittest.TestCase): def test_16_get_OTS_DEG1_TTP_TXRX_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-C1/yang-ext:mount/org-openroadm-device:org-openroadm-device/interface/OTS-DEG1-TTP-TXRX/" - "org-openroadm-optical-transport-interfaces:ots".format(self.restconf_baseurl)) + "org-openroadm-optical-transport-interfaces:ots".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(25.7, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) self.assertEqual(17.6, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-receive']) def test_17_servicePath_create_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -409,7 +348,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -417,7 +356,7 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(10) def test_18_servicePath_create_ZToA(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -451,7 +390,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -459,7 +398,7 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(10) def test_19_service_power_setup_XPDRA_XPDRC(self): - url = "{}/operations/transportpce-olm:service-power-setup".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-setup".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -491,7 +430,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -499,10 +438,10 @@ class TransportOlmTesting(unittest.TestCase): def test_20_get_interface_XPDRA_XPDR1_NETWORK1(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDR-A1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK1-1/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(-5, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) @@ -511,10 +450,10 @@ class TransportOlmTesting(unittest.TestCase): def test_21_get_roadmconnection_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(self.restconf_baseurl)) + "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("gainLoss", res['roadm-connections'][0]['opticalControlMode']) @@ -523,16 +462,16 @@ class TransportOlmTesting(unittest.TestCase): def test_22_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-C1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "DEG1-TTP-TXRX-SRG1-PP1-TXRX-1".format(self.restconf_baseurl)) + "DEG1-TTP-TXRX-SRG1-PP1-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("power", res['roadm-connections'][0]['opticalControlMode']) def test_23_service_power_setup_XPDRC_XPDRA(self): - url = "{}/operations/transportpce-olm:service-power-setup".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-setup".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -564,7 +503,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -572,10 +511,10 @@ class TransportOlmTesting(unittest.TestCase): def test_24_get_interface_XPDRC_XPDR1_NETWORK1(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDR-C1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK1-1/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(-5, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) @@ -584,17 +523,17 @@ class TransportOlmTesting(unittest.TestCase): def test_25_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-C1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(self.restconf_baseurl)) + "SRG1-PP1-TXRX-DEG1-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("gainLoss", res['roadm-connections'][0]['opticalControlMode']) self.assertEqual(2.0, res['roadm-connections'][0]['target-output-power']) def test_26_service_power_turndown_XPDRA_XPDRC(self): - url = "{}/operations/transportpce-olm:service-power-turndown".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:service-power-turndown".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -626,7 +565,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', res["output"]["result"]) @@ -634,10 +573,10 @@ class TransportOlmTesting(unittest.TestCase): def test_27_get_roadmconnection_ROADMA(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(self.restconf_baseurl)) + "SRG1-PP1-TXRX-DEG2-TTP-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("off", res['roadm-connections'][0]['opticalControlMode']) @@ -646,16 +585,16 @@ class TransportOlmTesting(unittest.TestCase): def test_28_get_roadmconnection_ROADMC(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-C1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/roadm-connections/" - "DEG1-TTP-TXRX-SRG1-PP1-TXRX-1".format(self.restconf_baseurl)) + "DEG1-TTP-TXRX-SRG1-PP1-TXRX-1".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual("off", res['roadm-connections'][0]['opticalControlMode']) def test_29_servicePath_delete_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -689,14 +628,14 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) def test_30_servicePath_delete_ZToA(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -730,7 +669,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) @@ -739,7 +678,7 @@ class TransportOlmTesting(unittest.TestCase): """to test case where SRG where the xpdr is connected to has no optical range data""" def test_31_connect_xprdA_to_roadmA(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -755,13 +694,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) def test_32_connect_roadmA_to_xpdrA(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(self.restconf_baseurl) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -777,13 +716,13 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) def test_33_servicePath_create_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test2", @@ -807,7 +746,7 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes', res["output"]["result"]) @@ -817,17 +756,17 @@ class TransportOlmTesting(unittest.TestCase): def test_34_get_interface_XPDRA_XPDR1_NETWORK2(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/XPDR-A1/yang-ext:mount/" "org-openroadm-device:org-openroadm-device/interface/XPDR1-NETWORK2-2/" - "org-openroadm-optical-channel-interfaces:och".format(self.restconf_baseurl)) + "org-openroadm-optical-channel-interfaces:och".format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(-5, res['org-openroadm-optical-channel-interfaces:och']['transmit-power']) # self.assertEqual(2, res['org-openroadm-optical-channel-interfaces:och']['wavelength-number']) def test_35_servicePath_delete_AToZ(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = { "input": { "service-name": "test", @@ -851,39 +790,25 @@ class TransportOlmTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) def test_36_xpdrA_device_disconnected(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_37_xpdrC_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("XPDR-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_38_calculate_span_loss_current(self): - url = "{}/operations/transportpce-olm:calculate-spanloss-current".format(self.restconf_baseurl) + url = "{}/operations/transportpce-olm:calculate-spanloss-current".format(test_utils.RESTCONF_BASE_URL) headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, headers=headers, auth=('admin', 'admin')) + "POST", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Success', @@ -891,26 +816,12 @@ class TransportOlmTesting(unittest.TestCase): time.sleep(5) def test_39_rdmA_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_40_rdmC_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(10) + response = test_utils.unmount_device("ROADM-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/2.2.1/test_otn_renderer.py b/tests/transportpce_tests/2.2.1/test_otn_renderer.py index 04f09c6d1..6b72ede01 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_renderer.py @@ -29,7 +29,6 @@ def extract_a_from_b(a, b): class TransportPCEtesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -46,28 +45,15 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) def test_01_connect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "SPDR-SA1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['spdrav2']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) + response = test_utils.mount_device("SPDR-SA1", 'spdrav2') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) + url = ("{}/operational/network-topology:" "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -77,10 +63,9 @@ class TransportPCEtesting(unittest.TestCase): def test_02_get_portmapping_CLIENT1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/SPDR-SA1/mapping/XPDR1-CLIENT1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -99,10 +84,9 @@ class TransportPCEtesting(unittest.TestCase): def test_03_get_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/SPDR-SA1/mapping/XPDR1-NETWORK1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -119,7 +103,7 @@ class TransportPCEtesting(unittest.TestCase): res['mapping']) def test_04_service_path_create_OCH_OTU4(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service_ODU4", "wave-number": "1", @@ -128,10 +112,9 @@ class TransportPCEtesting(unittest.TestCase): "nodes": [ {"node-id": "SPDR-SA1", "dest-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -145,10 +128,9 @@ class TransportPCEtesting(unittest.TestCase): def test_05_get_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/SPDR-SA1/mapping/XPDR1-NETWORK1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -168,10 +150,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -201,10 +182,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() input_dict = {'name': 'XPDR1-NETWORK1-OTU', @@ -231,7 +211,7 @@ class TransportPCEtesting(unittest.TestCase): res['interface'][0]['org-openroadm-otn-otu-interfaces:otu']) def test_08_otn_service_path_create_ODU4(self): - url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service_ODU4", "operation": "create", @@ -240,10 +220,9 @@ class TransportPCEtesting(unittest.TestCase): "nodes": [ {"node-id": "SPDR-SA1", "network-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -256,10 +235,9 @@ class TransportPCEtesting(unittest.TestCase): def test_09_get_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/SPDR-SA1/mapping/XPDR1-NETWORK1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -281,10 +259,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU4" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU4', 'administrative-state': 'inService', @@ -318,7 +295,7 @@ class TransportPCEtesting(unittest.TestCase): res['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu']) def test_11_otn_service_path_create_10GE(self): - url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service1", "operation": "create", @@ -331,10 +308,9 @@ class TransportPCEtesting(unittest.TestCase): {"node-id": "SPDR-SA1", "client-tp": "XPDR1-CLIENT1", "network-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -350,10 +326,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET10G" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() input_dict = {'name': 'XPDR1-CLIENT1-ETHERNET10G', @@ -380,10 +355,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -425,10 +399,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU2e-service1', 'administrative-state': 'inService', @@ -482,10 +455,9 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "odu-connection/XPDR1-CLIENT1-ODU2e-service1-x-XPDR1-NETWORK1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() input_dict_1 = { @@ -509,7 +481,7 @@ class TransportPCEtesting(unittest.TestCase): res['odu-connection'][0]['source']) def test_16_otn_service_path_delete_10GE(self): - url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service1", "operation": "delete", @@ -522,10 +494,9 @@ class TransportPCEtesting(unittest.TestCase): {"node-id": "SPDR-SA1", "client-tp": "XPDR1-CLIENT1", "network-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -536,44 +507,40 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "odu-connection/XPDR1-CLIENT1-ODU2e-service1-x-XPDR1-NETWORK1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_18_check_no_interface_ODU2E_NETWORK(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_19_check_no_interface_ODU2E_CLIENT(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ODU2e-service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_20_check_no_interface_10GE_CLIENT(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET10G" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_21_otn_service_path_delete_ODU4(self): - url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service_ODU4", "operation": "delete", @@ -582,10 +549,9 @@ class TransportPCEtesting(unittest.TestCase): "nodes": [ {"node-id": "SPDR-SA1", "network-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -596,14 +562,13 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU4" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_23_service_path_delete_OCH_OTU4(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "service-name": "service_OTU4", "wave-number": "1", @@ -612,10 +577,9 @@ class TransportPCEtesting(unittest.TestCase): "nodes": [ {"node-id": "SPDR-SA1", "dest-tp": "XPDR1-NETWORK1"}]}} - headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) time.sleep(3) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -626,32 +590,23 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_25_check_no_interface_OCH(self): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) def test_26_disconnect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("SPDR-SA1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/2.2.1/test_otn_topology.py b/tests/transportpce_tests/2.2.1/test_otn_topology.py index 89a2eef03..1be82ab69 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_topology.py +++ b/tests/transportpce_tests/2.2.1/test_otn_topology.py @@ -25,7 +25,6 @@ from common import test_utils class TransportPCEtesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -42,28 +41,15 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) def test_01_connect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "SPDR-SA1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['spdrav2']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) + response = test_utils.mount_device("SPDR-SA1", 'spdrav2') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) + url = ("{}/operational/network-topology:" "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -72,10 +58,9 @@ class TransportPCEtesting(unittest.TestCase): def test_02_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() logging.info(res) @@ -84,10 +69,9 @@ class TransportPCEtesting(unittest.TestCase): def test_03_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'SPDR-SA1') @@ -100,10 +84,9 @@ class TransportPCEtesting(unittest.TestCase): def test_04_getLinks_OpenroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -111,10 +94,9 @@ class TransportPCEtesting(unittest.TestCase): def test_05_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -170,20 +152,18 @@ class TransportPCEtesting(unittest.TestCase): def test_06_getLinks_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('ietf-network-topology:link', res['network'][0]) def test_07_getNodes_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertEqual(response.status_code, requests.codes.ok) nbNode = len(res['network'][0]['node']) @@ -295,22 +275,14 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_08_disconnect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("SPDR-SA1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_09_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -319,29 +291,26 @@ class TransportPCEtesting(unittest.TestCase): def test_10_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_11_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertNotIn('node', res['network'][0]) def test_12_getNodes_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertNotIn('node', res['network'][0]) diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index 14edf7096..68d59d543 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -24,7 +24,6 @@ from common import test_utils class TransportPCEPortMappingTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -41,32 +40,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 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)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + def test_01_rdm_device_connection(self): + response = test_utils.mount_device("ROADM-A1", 'roadma') + 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(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -77,10 +60,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_03_rdm_portmapping_info(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADM-A1/node-info" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -95,10 +77,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_04_rdm_portmapping_DEG1_TTP_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADM-A1/mapping/DEG1-TTP-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -109,10 +90,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 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(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -125,10 +105,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_06_rdm_portmapping_SRG1_PP3_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADM-A1/mapping/SRG1-PP3-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -139,10 +118,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_07_rdm_portmapping_SRG3_PP1_TXRX(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADM-A1/mapping/SRG3-PP1-TXRX" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -150,32 +128,16 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, res['mapping']) - def test_08_xpdr_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + def test_08_xpdr_device_connection(self): + response = test_utils.mount_device("XPDR-A1", 'xpdra') + 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(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -186,10 +148,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_10_xpdr_portmapping_info(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1/node-info" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -204,10 +165,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_11_xpdr_portmapping_NETWORK1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1/mapping/XPDR1-NETWORK1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -221,10 +181,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_12_xpdr_portmapping_NETWORK2(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1/mapping/XPDR1-NETWORK2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -238,10 +197,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_13_xpdr_portmapping_CLIENT1(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1/mapping/XPDR1-CLIENT1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -256,10 +214,9 @@ class TransportPCEPortMappingTesting(unittest.TestCase): def test_14_xpdr_portmapping_CLIENT2(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1/mapping/XPDR1-CLIENT2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -271,23 +228,15 @@ class TransportPCEPortMappingTesting(unittest.TestCase): '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" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + def test_15_xpdr_device_disconnection(self): + response = test_utils.unmount_device("XPDR-A1") + 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(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + "topology-netconf/node/XPDR-A1".format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -295,11 +244,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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): - url = ("{}/config/transportpce-portmapping:network/nodes/XPDR-A1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + 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=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -307,22 +255,15 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + def test_18_rdm_device_disconnection(self): + response = test_utils.unmount_device("ROADM-A1") + 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(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( @@ -330,11 +271,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase): "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): - url = ("{}/config/transportpce-portmapping:network/nodes/ROADM-A1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + 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=headers, auth=('admin', 'admin')) + "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) res = response.json() self.assertIn( diff --git a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py index c5c7ec229..9134fb92d 100644 --- a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py @@ -25,7 +25,6 @@ from common import test_utils class TransportPCERendererTesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -39,54 +38,20 @@ class TransportPCERendererTesting(unittest.TestCase): print("all processes killed") def test_01_rdm_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertIn(response.status_code, [requests.codes.created, - requests.codes.ok]) - # self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_xpdr_device_connected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - # self.assertEqual(response.status_code, requests.codes.created) - self.assertIn(response.status_code, [requests.codes.created, - requests.codes.ok]) - time.sleep(20) + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_rdm_portmapping(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/ROADM-A1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -101,10 +66,10 @@ class TransportPCERendererTesting(unittest.TestCase): def test_04_xpdr_portmapping(self): url = ("{}/config/transportpce-portmapping:network/" "nodes/XPDR-A1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn( @@ -124,7 +89,7 @@ class TransportPCERendererTesting(unittest.TestCase): res['nodes'][0]['mapping']) def test_05_service_path_create(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "renderer:service-name": "service_test", "renderer:wave-number": "7", @@ -140,7 +105,7 @@ class TransportPCERendererTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Roadm-connection successfully created for nodes: ROADM-A1', res["output"]["result"]) @@ -149,10 +114,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-nmc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -174,10 +139,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-mc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -199,10 +164,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP3-TXRX-nmc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -225,10 +190,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP3-TXRX-mc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -240,10 +205,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP3-TXRX-DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -265,10 +230,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -292,10 +257,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -319,10 +284,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the 2 following statements replace self.assertDictContainsSubset deprecated in python 3.2 @@ -351,10 +316,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 @@ -376,10 +341,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-NET" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('not-reserved-inuse', res['circuit-packs'][0]["equipment-state"]) @@ -388,16 +353,16 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-CLIENT" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('not-reserved-inuse', res['circuit-packs'][0]["equipment-state"]) def test_17_service_path_delete(self): - url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl) + url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL) data = {"renderer:input": { "renderer:service-name": "service_test", "renderer:wave-number": "7", @@ -412,7 +377,7 @@ class TransportPCERendererTesting(unittest.TestCase): headers = {'content-type': 'application/json'} response = requests.request( "POST", url, data=json.dumps(data), - headers=headers, auth=('admin', 'admin')) + headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) self.assertEqual(response.json(), { 'output': {'result': 'Request processed', 'success': True}}) @@ -421,10 +386,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-mc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -436,10 +401,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/DEG1-TTP-TXRX-nmc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -451,10 +416,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP3-TXRX-mc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -466,10 +431,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/SRG1-PP3-TXRX-nmc-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -481,10 +446,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/ROADM-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP3-TXRX-DEG1-TTP-TXRX-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -496,10 +461,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-7" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -511,10 +476,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-OTU" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -526,10 +491,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-NETWORK1-ODU" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -541,10 +506,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "interface/XPDR1-CLIENT1-ETHERNET" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.not_found) res = response.json() self.assertIn( @@ -556,10 +521,10 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-NET" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual('not-reserved-available', res["circuit-packs"][0]['equipment-state']) @@ -568,35 +533,21 @@ class TransportPCERendererTesting(unittest.TestCase): url = ("{}/config/network-topology:network-topology/topology/topology-netconf/" "node/XPDR-A1/yang-ext:mount/org-openroadm-device:org-openroadm-device/" "circuit-packs/1%2F0%2F1-PLUG-CLIENT" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) headers = {'content-type': 'application/json'} response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual('not-reserved-available', res["circuit-packs"][0]['equipment-state']) def test_29_rdm_device_disconnected(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + response = test_utils.unmount_device("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_30_xpdr_device_disconnected(self): - url = ("{}/config/network-topology:" - "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')) - self.assertEqual(response.status_code, requests.codes.ok) - time.sleep(20) + response = test_utils.unmount_device("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__": diff --git a/tests/transportpce_tests/2.2.1/test_tapi.py b/tests/transportpce_tests/2.2.1/test_tapi.py index 718b7404b..e1c67477b 100644 --- a/tests/transportpce_tests/2.2.1/test_tapi.py +++ b/tests/transportpce_tests/2.2.1/test_tapi.py @@ -16,11 +16,6 @@ import requests from common import test_utils -RESTCONF_BASE_URL = "http://localhost:8181/restconf" - -CODE_SHOULD_BE_200 = 'Http status code should be 200' - -CODE_SHOULD_BE_201 = 'Http status code should be 201' CREATED_SUCCESSFULLY = 'Result message should contain Xponder Roadm Link created successfully' @@ -62,158 +57,137 @@ class TransportTapitesting(unittest.TestCase): self.fail('Feature installation failed') print("execution of {}".format(self.id().split(".")[-1])) - # connect netconf devices - def test_00_connect_spdr_sa1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("SPDR-SA1", test_utils.sims['spdrav2']['port']) - response = test_utils.put_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member + response = test_utils.mount_device("SPDR-SA1", 'spdrav2') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) + # TODO replace connect and disconnect timers with test_utils.wait_until_log_contains def test_01_connect_xpdra(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("XPDR-A1", test_utils.sims['xpdra']['port']) - response = test_utils.put_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) def test_02_connect_xpdrc(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("XPDR-C1", test_utils.sims['xpdrc']['port']) - response = test_utils.put_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member + response = test_utils.mount_device("XPDR-C1", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) def test_03_connect_rdma(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("ROADM-A1", test_utils.sims['roadma']['port']) - response = test_utils.put_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(20) def test_04_connect_rdmc(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(RESTCONF_BASE_URL)) - data = test_utils.generate_connect_data("ROADM-C1", test_utils.sims['roadmc']['port']) - response = test_utils.put_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.created, CODE_SHOULD_BE_201) # pylint: disable=no-member + response = test_utils.mount_device("ROADM-C1", 'roadmc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(20) def test_05_connect_xprda_n1_to_roadma_pp1(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-A1", "1", "1", "ROADM-A1", "1", "SRG1-PP1-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_06_connect_roadma_pp1_to_xpdra_n1(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-A1", "1", "1", "ROADM-A1", "1", "SRG1-PP1-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_07_connect_xprdc_n1_to_roadmc_pp1(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-C1", "1", "1", "ROADM-C1", "1", "SRG1-PP1-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_08_connect_roadmc_pp1_to_xpdrc_n1(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-C1", "1", "1", "ROADM-C1", "1", "SRG1-PP1-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_09_connect_xprda_n2_to_roadma_pp2(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-A1", "1", "2", "ROADM-A1", "1", "SRG1-PP2-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_10_connect_roadma_pp2_to_xpdra_n2(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-A1", "1", "2", "ROADM-A1", "1", "SRG1-PP2-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_11_connect_xprdc_n2_to_roadmc_pp2(self): - url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-C1", "1", "2", "ROADM-C1", "1", "SRG1-PP2-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_12_connect_roadmc_pp2_to_xpdrc_n2(self): - url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(RESTCONF_BASE_URL) + url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".format(test_utils.RESTCONF_BASE_URL) data = test_utils.generate_link_data("XPDR-C1", "1", "2", "ROADM-C1", "1", "SRG1-PP2-TXRX") - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertIn('Roadm Xponder links created successfully', res["output"]["result"], CREATED_SUCCESSFULLY) time.sleep(2) def test_13_get_tapi_openroadm_topology(self): - url = "{}/operations/tapi-topology:get-topology-details".format(RESTCONF_BASE_URL) + url = "{}/operations/tapi-topology:get-topology-details".format(test_utils.RESTCONF_BASE_URL) data = { "tapi-topology:input": { "tapi-topology:topology-id-or-name": "openroadm-topology" } } - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertEqual(len(res["output"]["topology"]["node"]), 1, 'There should be 1 node') self.assertEqual(len(res["output"]["topology"]["node"][0]["owned-node-edge-point"]), 4, 'There should be 4 owned-node-edge-points') def test_14_get_tapi_otn_topology(self): - url = "{}/operations/tapi-topology:get-topology-details".format(RESTCONF_BASE_URL) + url = "{}/operations/tapi-topology:get-topology-details".format(test_utils.RESTCONF_BASE_URL) data = { "tapi-topology:input": { "tapi-topology:topology-id-or-name": "otn-topology" } } - response = test_utils.post_request(url, data, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.post_request(url, data, test_utils.ODL_LOGIN, test_utils.ODL_PWD) + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) res = response.json() self.assertEqual(len(res["output"]["topology"]["node"]), 4, 'There should be 4 nodes') self.assertEqual(len(res["output"]["topology"]["link"]), 5, 'There should be 5 links') @@ -259,47 +233,28 @@ class TransportTapitesting(unittest.TestCase): self.fail('Wrong layer protocol name') def test_15_disconnect_xpdra(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(RESTCONF_BASE_URL)) - - response = test_utils.delete_request(url, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.unmount_device("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) time.sleep(10) def test_16_disconnect_xpdrc(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-C1" - .format(RESTCONF_BASE_URL)) - - response = test_utils.delete_request(url, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.unmount_device("XPDR-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) time.sleep(10) def test_17_disconnect_roadma(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(RESTCONF_BASE_URL)) - - response = test_utils.delete_request(url, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.unmount_device("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) time.sleep(10) def test_18_disconnect_roadmc(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(RESTCONF_BASE_URL)) - - response = test_utils.delete_request(url, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.unmount_device("ROADM-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) time.sleep(10) def test_19_disconnect_spdr_sa1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(RESTCONF_BASE_URL)) - response = test_utils.delete_request(url, 'admin', 'admin') - self.assertEqual(response.status_code, requests.codes.ok, CODE_SHOULD_BE_200) # pylint: disable=no-member + response = test_utils.unmount_device("SPDR-SA1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def find_object_with_key(list_dicts, key, value): diff --git a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py index f6285bafb..36e52bd0d 100644 --- a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py @@ -25,7 +25,6 @@ from common import test_utils class TransportPCEtesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -43,32 +42,15 @@ class TransportPCEtesting(unittest.TestCase): # Connect the ROADMA def test_01_connect_rdm(self): - # Config ROADMA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # Verify the termination points of the ROADMA def test_02_compareOpenroadmTopologyPortMapping_rdm(self): urlTopo = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) responseTopo = requests.request( - "GET", urlTopo, headers=headers, auth=('admin', 'admin')) + "GET", urlTopo, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) resTopo = responseTopo.json() nbNode = len(resTopo['network'][0]['node']) nbMapCumul = 0 @@ -79,9 +61,9 @@ class TransportPCEtesting(unittest.TestCase): nodeMapId = nodeId.split("-")[0] + "-" + nodeId.split("-")[1] print("nodeMapId={}".format(nodeMapId)) urlMapList = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId - urlMapListFull = urlMapList.format(self.restconf_baseurl) + urlMapListFull = urlMapList.format(test_utils.RESTCONF_BASE_URL) responseMapList = requests.request( - "GET", urlMapListFull, headers=headers, auth=('admin', 'admin')) + "GET", urlMapListFull, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) resMapList = responseMapList.json() nbMappings = len(resMapList['nodes'][0]['mapping']) - nbMapCumul @@ -91,9 +73,9 @@ class TransportPCEtesting(unittest.TestCase): tpId = resTopo['network'][0]['node'][i]['ietf-network-topology:termination-point'][j]['tp-id'] if((not "CP" in tpId) and (not "CTP" in tpId)): urlMap = "{}/config/transportpce-portmapping:network/nodes/" + nodeMapId + "/mapping/" + tpId - urlMapFull = urlMap.format(self.restconf_baseurl) + urlMapFull = urlMap.format(test_utils.RESTCONF_BASE_URL) responseMap = requests.request( - "GET", urlMapFull, headers=headers, auth=('admin', 'admin')) + "GET", urlMapFull, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(responseMap.status_code, requests.codes.ok) if(responseMap.status_code == requests.codes.ok): nbMapCurrent += 1 @@ -105,34 +87,17 @@ class TransportPCEtesting(unittest.TestCase): def test_03_disconnect_rdm(self): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) # #Connect the XPDRA def test_04_connect_xpdr(self): - # Config XPDRA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # #Verify the termination points related to XPDR def test_05_compareOpenroadmTopologyPortMapping_xpdr(self): @@ -142,12 +107,11 @@ class TransportPCEtesting(unittest.TestCase): def test_06_disconnect_device(self): url = ("{}/config/network-topology:" "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) diff --git a/tests/transportpce_tests/2.2.1/test_topology.py b/tests/transportpce_tests/2.2.1/test_topology.py index c531cb25f..27da88a84 100644 --- a/tests/transportpce_tests/2.2.1/test_topology.py +++ b/tests/transportpce_tests/2.2.1/test_topology.py @@ -25,7 +25,6 @@ from common import test_utils class TransportPCEtesting(unittest.TestCase): processes = None - restconf_baseurl = "http://localhost:8181/restconf" @classmethod def setUpClass(cls): @@ -42,31 +41,14 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(5) def test_01_connect_ROADM_A1(self): - # Config ROADMA - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-A1", 'roadma') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_02_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() logging.info(res) @@ -75,10 +57,9 @@ class TransportPCEtesting(unittest.TestCase): def test_03_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'ROADM-A1') @@ -89,10 +70,9 @@ class TransportPCEtesting(unittest.TestCase): def test_04_getLinks_OpenroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -130,10 +110,9 @@ class TransportPCEtesting(unittest.TestCase): def test_05_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -200,30 +179,14 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_06_connect_XPDRA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDR-A1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "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'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(30) + response = test_utils.mount_device("XPDR-A1", 'xpdra') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_07_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'NodeA') @@ -231,10 +194,9 @@ class TransportPCEtesting(unittest.TestCase): def test_08_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -254,10 +216,9 @@ class TransportPCEtesting(unittest.TestCase): def test_09_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -344,7 +305,7 @@ class TransportPCEtesting(unittest.TestCase): def test_10_connect_tail_xpdr_rdm(self): # Connect the tail: XPDRA to ROADMA url = ("{}/operations/transportpce-networkutils:init-xpdr-rdm-links" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"networkutils:input": { "networkutils:links-input": { "networkutils:xpdr-node": "XPDR-A1", @@ -356,16 +317,15 @@ class TransportPCEtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_11_connect_tail_rdm_xpdr(self): # Connect the tail: ROADMA to XPDRA url = ("{}/operations/transportpce-networkutils:init-rdm-xpdr-links" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"networkutils:input": { "networkutils:links-input": { "networkutils:xpdr-node": "XPDR-A1", @@ -377,18 +337,16 @@ class TransportPCEtesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_12_getLinks_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -434,31 +392,15 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(XPDR_OUT), 0) def test_13_connect_ROADMC(self): - # Config ROADMC - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-C1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmc']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-C1", 'roadmc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_14_omsAttributes_ROADMA_ROADMC(self): # Config ROADMA-ROADMC oms-attributes url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -467,10 +409,9 @@ class TransportPCEtesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_15_omsAttributes_ROADMC_ROADMA(self): @@ -478,7 +419,7 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -488,18 +429,16 @@ class TransportPCEtesting(unittest.TestCase): "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_16_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -517,10 +456,9 @@ class TransportPCEtesting(unittest.TestCase): def test_17_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -550,10 +488,9 @@ class TransportPCEtesting(unittest.TestCase): def test_18_getROADMLinkOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -609,10 +546,9 @@ class TransportPCEtesting(unittest.TestCase): def test_19_getLinkOmsAttributesOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -637,10 +573,9 @@ class TransportPCEtesting(unittest.TestCase): def test_20_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -748,30 +683,15 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_21_connect_ROADMB(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-B1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADM-B1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": test_utils.sims['roadmb']['port'], - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) - time.sleep(20) + response = test_utils.mount_device("ROADM-B1", 'roadmb') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_22_omsAttributes_ROADMA_ROADMB(self): # Config ROADM-A1-ROADM-B1 oms-attributes url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-A1-DEG1-DEG1-TTP-TXRXtoROADM-B1-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -782,10 +702,9 @@ class TransportPCEtesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_23_omsAttributes_ROADMB_ROADMA(self): @@ -793,7 +712,7 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-B1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG1-DEG1-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -804,10 +723,9 @@ class TransportPCEtesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_24_omsAttributes_ROADMB_ROADMC(self): @@ -815,7 +733,7 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-B1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -826,10 +744,9 @@ class TransportPCEtesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_25_omsAttributes_ROADMC_ROADMB(self): @@ -837,7 +754,7 @@ class TransportPCEtesting(unittest.TestCase): url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-C1-DEG2-DEG2-TTP-TXRXtoROADM-B1-DEG2-DEG2-TTP-TXRX/org-openroadm-network-topology:" "OMS-attributes/span" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "auto-spanloss": "true", "engineered-spanloss": 12.2, @@ -846,18 +763,16 @@ class TransportPCEtesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_26_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -877,10 +792,9 @@ class TransportPCEtesting(unittest.TestCase): def test_27_verifyDegree(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -898,10 +812,9 @@ class TransportPCEtesting(unittest.TestCase): def test_28_verifyOppositeLinkTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -915,9 +828,9 @@ class TransportPCEtesting(unittest.TestCase): oppLink_id = res['network'][0]['ietf-network-topology:link'][i]['org-openroadm-common-network:opposite-link'] # Find the opposite link url_oppLink = "{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:link/"+oppLink_id - url = (url_oppLink.format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} - response_oppLink = requests.request("GET", url, headers=headers, auth=('admin', 'admin')) + url = (url_oppLink.format(test_utils.RESTCONF_BASE_URL)) + response_oppLink = requests.request( + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response_oppLink.status_code, requests.codes.ok) res_oppLink = response_oppLink.json() self.assertEqual(res_oppLink['ietf-network-topology:link'][0] @@ -940,10 +853,9 @@ class TransportPCEtesting(unittest.TestCase): def test_29_getLinkOmsAttributesOpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) @@ -970,52 +882,34 @@ class TransportPCEtesting(unittest.TestCase): def test_30_disconnect_ROADMB(self): # Delete in the topology-netconf - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-B1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADM-B1") # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeB" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_31_disconnect_ROADMC(self): # Delete in the topology-netconf - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-C1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADM-C1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeC" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) # def test_24_check_roadm2roadm_links_deletion(self): # url = ("{}/config/ietf-network:networks/network/openroadm-topology" -# .format(self.restconf_baseurl)) -# headers = {'content-type': 'application/json'} +# .format(test_utils.RESTCONF_BASE_URL)) # response = requests.request( -# "GET", url, headers=headers, auth=('admin', 'admin')) +# "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) # self.assertEqual(response.status_code, requests.codes.ok) # res = response.json() # #Write the response in the log @@ -1071,10 +965,9 @@ class TransportPCEtesting(unittest.TestCase): def test_32_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -1154,10 +1047,9 @@ class TransportPCEtesting(unittest.TestCase): def test_33_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1168,10 +1060,9 @@ class TransportPCEtesting(unittest.TestCase): def test_34_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1180,22 +1071,14 @@ class TransportPCEtesting(unittest.TestCase): self.assertNotEqual(res['network'][0]['node'][1]['org-openroadm-clli-network:clli'], 'NodeC') def test_35_disconnect_XPDRA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDR-A1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("XPDR-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_36_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1204,10 +1087,9 @@ class TransportPCEtesting(unittest.TestCase): def test_37_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -1217,10 +1099,9 @@ class TransportPCEtesting(unittest.TestCase): def test_38_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -1274,30 +1155,27 @@ class TransportPCEtesting(unittest.TestCase): # Link-1 url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/XPDR-A1-XPDR1-XPDR1-NETWORK1toROADM-A1-SRG1-SRG1-PP1-TXRX" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) # Link-2 url = ("{}/config/ietf-network:networks/network/openroadm-topology/ietf-network-topology:" "link/ROADM-A1-SRG1-SRG1-PP1-TXRXtoXPDR-A1-XPDR1-XPDR1-NETWORK1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_40_getLinks_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) @@ -1338,51 +1216,40 @@ class TransportPCEtesting(unittest.TestCase): ['org-openroadm-common-network:link-type'], 'XPONDER-INPUT') def test_41_disconnect_ROADMA(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADM-A1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("ROADM-A1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) # Delete in the clli-network url = ("{}/config/ietf-network:networks/network/clli-network/node/NodeA" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {} - headers = {'content-type': 'application/json'} response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "DELETE", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) def test_42_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_43_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_44_check_roadm2roadm_link_persistence(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbLink = len(res['network'][0]['ietf-network-topology:link']) diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index b94c9de01..e3af5fe2f 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -22,11 +22,22 @@ sims = simulators.sims honeynode_executable = simulators.honeynode_executable samples_directory = simulators.samples_directory -HONEYNODE_OK_START_MSG = re.escape("Netconf SSH endpoint started successfully at 0.0.0.0") -KARAF_OK_START_MSG = re.escape("Blueprint container for bundle " - "org.opendaylight.netconf.restconf") + ".* was successfully created" +HONEYNODE_OK_START_MSG = "Netconf SSH endpoint started successfully at 0.0.0.0" +KARAF_OK_START_MSG = re.escape( + "Blueprint container for bundle org.opendaylight.netconf.restconf")+".* was successfully created" -TYPE_APPLICATION_JSON = {'content-type': 'application/json'} + +RESTCONF_BASE_URL = "http://localhost:8181/restconf" +ODL_LOGIN = "admin" +ODL_PWD = "admin" +NODES_LOGIN = "admin" +NODES_PWD = "admin" + +TYPE_APPLICATION_JSON = {'Content-Type': 'application/json', 'Accept': 'application/json'} +TYPE_APPLICATION_XML = {'Content-Type': 'application/xml', 'Accept': 'application/xml'} + +CODE_SHOULD_BE_200 = 'Http status code should be 200' +CODE_SHOULD_BE_201 = 'Http status code should be 201' log_directory = os.path.dirname(os.path.realpath(__file__)) @@ -36,6 +47,10 @@ karaf_log = os.path.join( process_list = [] +if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True': + tpce_log = 'odl.log' +else: + tpce_log = karaf_log def start_sims(sims_list): for sim in sims_list: @@ -55,16 +70,16 @@ def start_sims(sims_list): def start_tpce(): - print("starting opendaylight...") + print("starting OpenDaylight...") if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True': process = start_lighty() # TODO: add some sort of health check similar to Karaf below else: process = start_karaf() if wait_until_log_contains(karaf_log, KARAF_OK_START_MSG, time_to_wait=60): - print("opendaylight started") + print("OpenDaylight started !") else: - print("opendaylight failed to start") + print("OpenDaylight failed to start !") shutdown_process(process) for pid in process_list: shutdown_process(pid) @@ -122,16 +137,37 @@ def delete_request(url, username, password): auth=(username, password)) -def generate_connect_data(node_id: str, node_port: str): - data = {"node": [{ +def mount_device(node_id, sim): + url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/" + + node_id).format(RESTCONF_BASE_URL) + headers = {"node": [{ "node-id": node_id, - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", + "netconf-node-topology:username": NODES_LOGIN, + "netconf-node-topology:password": NODES_PWD, "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": node_port, + "netconf-node-topology:port": sims[sim]['port'], "netconf-node-topology:tcp-only": "false", "netconf-node-topology:pass-through": {}}]} - return data + response = put_request(url, headers, ODL_LOGIN, ODL_PWD) + if wait_until_log_contains(tpce_log, re.escape("Triggering notification stream NETCONF for node "+node_id), 60): + print("Node "+node_id+" correctly added to tpce topology", end='... ', flush=True) + else: + print("Node "+node_id+" still not added to tpce topology", end='... ', flush=True) + if response.status_code == requests.codes.ok: + print("It was probably loaded at start-up", end='... ', flush=True) + # TODO an else-clause to abort test would probably be nice here + return response + + +def unmount_device(node_id): + url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/" + + node_id).format(RESTCONF_BASE_URL) + response = delete_request(url, ODL_LOGIN, ODL_PWD) + if wait_until_log_contains(tpce_log, re.escape("onDeviceDisConnected: "+node_id), 60): + print("Node "+node_id+" correctly deleted from tpce topology", end='... ', flush=True) + else: + print("Node "+node_id+" still not deleted from tpce topology", end='... ', flush=True) + return response def generate_link_data(xpdr_node: str, xpdr_num: str, network_num: str, rdm_node: str, srg_num: str, @@ -167,30 +203,31 @@ def start_honeynode(log_file: str, node_port: str, node_config_file_name: str): stdout=outfile, stderr=outfile) -def wait_until_log_contains(log_file, searched_string, time_to_wait=20): +def wait_until_log_contains(log_file, regexp, time_to_wait=20): found = False tail = None try: with timeout(seconds=time_to_wait): - print("Waiting for " + searched_string) + print("Searching for pattern '"+regexp+"' in "+os.path.basename(log_file), end='... ', flush=True) tail = subprocess.Popen(['tail', '-F', log_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - regexp = re.compile(searched_string) + compiled_regexp = re.compile(regexp) while True: line = tail.stdout.readline().decode('utf-8') - if regexp.search(line): - print("Searched string found.") + if compiled_regexp.search(line): + print("String found!", end=' ') found = True break except TimeoutError: - print("Cannot find string "+searched_string+" after waiting for "+str(time_to_wait)) + print("String not found after "+str(time_to_wait), end=" seconds! ", flush=True) finally: if tail is not None: - print("Stopping tail command") + print("Stopping tail command", end='... ', flush=True) tail.stderr.close() tail.stdout.close() tail.kill() tail.wait() return found +# TODO try to find an alternative to subprocess+tail -f (such as https://pypi.org/project/tailhead/) class timeout: