X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F2.2.1%2Ftest_olm.py;h=8c59393a6156764be936ef3167142219b906987e;hb=78881abcc31dc039c374bcc15266030e8dabcf87;hp=c721d591aec4e54c1e19a7842c6f01e67dd180c1;hpb=b7853af0d6c2959dba772c9a01ca1da3e9029400;p=transportpce.git diff --git a/tests/transportpce_tests/2.2.1/test_olm.py b/tests/transportpce_tests/2.2.1/test_olm.py index c721d591a..8c59393a6 100644 --- a/tests/transportpce_tests/2.2.1/test_olm.py +++ b/tests/transportpce_tests/2.2.1/test_olm.py @@ -10,166 +10,50 @@ ############################################################################# import unittest -import requests import time -import subprocess -import signal import json -import os -import psutil -import shutil -from unittest.result import failfast -import test_utils +#from unittest.result import failfast +import requests +from common import test_utils class TransportOlmTesting(unittest.TestCase): - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None - odl_process = None - restconf_baseurl = "http://localhost:8181/restconf" - -# START_IGNORE_XTESTING + processes = None @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_xpdra_honeynode() - time.sleep(20) - - print("starting honeynode2...") - cls.honeynode_process2 = test_utils.start_roadma_honeynode() - time.sleep(20) - - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_honeynode() - time.sleep(20) - - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() - time.sleep(20) - - print("all honeynodes started") - - print("starting opendaylight...") - cls.odl_process = test_utils.start_tpce() - time.sleep(60) - 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.honeynode_process1.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process1.send_signal(signal.SIGINT) - cls.honeynode_process1.wait() - for child in psutil.Process(cls.honeynode_process2.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process2.send_signal(signal.SIGINT) - cls.honeynode_process2.wait() - for child in psutil.Process(cls.honeynode_process3.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): print("execution of {}".format(self.id().split(".")[-1])) time.sleep(1) -# END_IGNORE_XTESTING - 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": "17840", - "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": "17844", - "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": "17841", - "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": "17843", - "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": { @@ -185,13 +69,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": { @@ -207,13 +91,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": { @@ -229,13 +113,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": { @@ -251,13 +135,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", @@ -267,7 +151,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() @@ -275,7 +159,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", @@ -285,14 +169,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", @@ -306,7 +190,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({ @@ -323,7 +207,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", @@ -337,7 +221,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({ @@ -354,7 +238,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", @@ -364,19 +248,19 @@ 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"]) self.assertIn({ - "spanloss": "18", + "spanloss": "17.6", "link-id": "ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX" }, res["output"]["spans"]) 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" @@ -385,17 +269,17 @@ 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"]) self.assertIn({ - "spanloss": "26", + "spanloss": "25.7", "link-id": "ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX" }, res["output"]["spans"]) self.assertIn({ - "spanloss": "18", + "spanloss": "17.6", "link-id": "ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX" }, res["output"]["spans"]) time.sleep(5) @@ -403,29 +287,29 @@ 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(18, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) - self.assertEqual(26, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-receive']) + self.assertEqual(17.6, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) + self.assertEqual(25.7, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-receive']) 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(26, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-transmit']) - self.assertEqual(18, res['org-openroadm-optical-transport-interfaces:ots']['span-loss-receive']) + 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", @@ -459,7 +343,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"]) @@ -467,7 +351,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", @@ -501,7 +385,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"]) @@ -509,7 +393,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", @@ -541,7 +425,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"]) @@ -549,10 +433,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']) @@ -561,10 +445,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']) @@ -573,16 +457,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", @@ -614,7 +498,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"]) @@ -622,10 +506,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']) @@ -634,17 +518,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", @@ -676,7 +560,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"]) @@ -684,10 +568,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']) @@ -696,16 +580,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", @@ -739,14 +623,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", @@ -780,7 +664,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"]) @@ -789,7 +673,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": { @@ -805,13 +689,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": { @@ -827,13 +711,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", @@ -857,7 +741,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"]) @@ -867,17 +751,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", @@ -901,39 +785,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', @@ -941,26 +811,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__":