X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F2.2.1%2Ftest_end2end.py;h=dd92540c44aca23052cdf7f550304b19a8225941;hb=c8bd98e0844257ae2e40e01d54546a40596df26d;hp=755d0c668bb9289214544bd7e323f6f6bc7ba20a;hpb=f4d7679be9ffcc5ef14241cbfe9040c1c177b260;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 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__":