X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F2.2.1%2Ftest_end2end.py;h=6555bcf154963c6baf0f83fa79be317107774770;hb=78881abcc31dc039c374bcc15266030e8dabcf87;hp=1b1aab3dbc29b74ba8f3dee1616fa1c99159ba10;hpb=31bc01d3dab733bbb6ad48cc43586de43cb6c5c9;p=transportpce.git diff --git a/tests/transportpce_tests/2.2.1/test_end2end.py b/tests/transportpce_tests/2.2.1/test_end2end.py index 1b1aab3db..6555bcf15 100644 --- a/tests/transportpce_tests/2.2.1/test_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_end2end.py @@ -9,158 +9,50 @@ ############################################################################## +import unittest import json -import os -import psutil -import requests -import signal -import shutil -import subprocess import time -import unittest -import test_utils +import requests +from common import test_utils class TransportPCEFulltesting(unittest.TestCase): - odl_process = None - sim_process1 = None - sim_process2 = None - sim_process3 = None - sim_process4 = None - restconf_baseurl = "http://localhost:8181/restconf" + processes = None WAITING = 20 # nominal value is 300 -# START_IGNORE_XTESTING - @classmethod def setUpClass(cls): - cls.sim_process1 = test_utils.start_sim('xpdra') - - cls.sim_process2 = test_utils.start_sim('roadma') - - cls.sim_process3 = test_utils.start_sim('roadmc') - - cls.sim_process4 = test_utils.start_sim('xpdrc') - print("all sims started") - - cls.odl_process = test_utils.start_tpce() - time.sleep(80) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma', 'roadmc', 'xpdrc']) @classmethod def tearDownClass(cls): - for child in psutil.Process(cls.odl_process.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.odl_process.send_signal(signal.SIGINT) - cls.odl_process.wait() - for child in psutil.Process(cls.sim_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.sim_process1.send_signal(signal.SIGINT) - cls.sim_process1.wait() - for child in psutil.Process(cls.sim_process2.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.sim_process2.send_signal(signal.SIGINT) - cls.sim_process2.wait() - for child in psutil.Process(cls.sim_process3.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.sim_process3.send_signal(signal.SIGINT) - cls.sim_process3.wait() - for child in psutil.Process(cls.sim_process4.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.sim_process4.send_signal(signal.SIGINT) - cls.sim_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) print("all processes killed") def setUp(self): # instruction executed before each test method print("execution of {}".format(self.id().split(".")[-1])) -# END_IGNORE_XTESTING - -# 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": { @@ -173,17 +65,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": { @@ -196,17 +87,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": { @@ -219,17 +109,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": { @@ -242,10 +131,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"]) @@ -256,7 +144,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, @@ -267,10 +155,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): @@ -278,7 +165,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, @@ -289,16 +176,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", @@ -387,11 +273,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', @@ -400,11 +284,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( @@ -421,10 +303,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 @@ -448,10 +329,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 @@ -473,9 +353,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'] @@ -492,9 +372,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}, @@ -511,9 +391,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}, @@ -531,7 +411,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": { @@ -544,17 +424,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": { @@ -567,17 +446,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": { @@ -590,17 +468,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": { @@ -613,10 +490,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"]) @@ -624,7 +500,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", @@ -713,11 +589,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', @@ -726,11 +600,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( @@ -748,10 +620,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 @@ -771,9 +642,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'] @@ -792,9 +663,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] @@ -822,9 +693,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] @@ -850,7 +721,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", @@ -939,11 +810,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', @@ -954,7 +823,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", @@ -968,10 +837,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', @@ -981,7 +849,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", @@ -995,10 +863,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', @@ -1007,7 +874,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", @@ -1021,10 +888,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', @@ -1034,9 +900,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'])) @@ -1044,9 +910,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'] @@ -1062,9 +928,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] @@ -1081,9 +947,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] @@ -1101,7 +967,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", @@ -1190,11 +1056,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', @@ -1203,11 +1067,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( @@ -1225,10 +1087,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 @@ -1252,10 +1113,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 @@ -1277,7 +1137,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", @@ -1366,11 +1226,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', @@ -1379,11 +1237,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( @@ -1401,10 +1257,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 @@ -1431,7 +1286,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", @@ -1445,10 +1300,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', @@ -1457,7 +1311,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", @@ -1471,10 +1325,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', @@ -1484,11 +1337,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( @@ -1500,11 +1351,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']) @@ -1516,7 +1365,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_49_loop_create_eth_service(self): for i in range(1, 6): - print("trial number {}".format(i)) + print("iteration number {}".format(i)) print("eth service creation") self.test_11_create_eth_service1() print("check xc in ROADM-A1") @@ -1528,11 +1377,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", @@ -1546,12 +1395,12 @@ 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): - print("trial number {}".format(i)) + print("iteration number {}".format(i)) print("oc service creation") self.test_36_create_oc_service1() print("check xc in ROADM-A1") @@ -1562,48 +1411,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__":