X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F2.2.1%2Ftest_otn_topology.py;h=1be82ab6977378ec151bf4c5df87b73bcb7b4a59;hb=c8bd98e0844257ae2e40e01d54546a40596df26d;hp=0e0390fa241c032b0284714fe107655ac94c2ac3;hpb=de9c823434160ba713e598018cd1cfc09d8cbb08;p=transportpce.git diff --git a/tests/transportpce_tests/2.2.1/test_otn_topology.py b/tests/transportpce_tests/2.2.1/test_otn_topology.py index 0e0390fa2..1be82ab69 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_topology.py +++ b/tests/transportpce_tests/2.2.1/test_otn_topology.py @@ -19,65 +19,37 @@ import subprocess import time import unittest import logging -import test_utils +from common import test_utils class TransportPCEtesting(unittest.TestCase): - honeynode_process1 = None - odl_process = None - restconf_baseurl = "http://localhost:8181/restconf" + processes = None @classmethod def setUpClass(cls): - print("starting honeynode1...") - cls.honeynode_process1 = test_utils.start_spdra_honeynode() - time.sleep(20) - - 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(['spdrav2']) @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 process in cls.processes: + test_utils.shutdown_process(process) + print("all processes killed") def setUp(self): time.sleep(5) def test_01_connect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "SPDR-SA1", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17845", - "netconf-node-topology:tcp-only": "false", - "netconf-node-topology:pass-through": {}}]} - headers = {'content-type': 'application/json'} - response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.created) + response = test_utils.mount_device("SPDR-SA1", 'spdrav2') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) time.sleep(10) + url = ("{}/operational/network-topology:" "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -86,10 +58,9 @@ class TransportPCEtesting(unittest.TestCase): def test_02_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() logging.info(res) @@ -98,10 +69,9 @@ class TransportPCEtesting(unittest.TestCase): def test_03_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['network'][0]['node'][0]['node-id'], 'SPDR-SA1') @@ -114,10 +84,9 @@ class TransportPCEtesting(unittest.TestCase): def test_04_getLinks_OpenroadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() # Tests related to links @@ -125,10 +94,9 @@ class TransportPCEtesting(unittest.TestCase): def test_05_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() # Tests related to nodes self.assertEqual(response.status_code, requests.codes.ok) @@ -184,20 +152,18 @@ class TransportPCEtesting(unittest.TestCase): def test_06_getLinks_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('ietf-network-topology:link', res['network'][0]) def test_07_getNodes_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertEqual(response.status_code, requests.codes.ok) nbNode = len(res['network'][0]['node']) @@ -309,22 +275,14 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_08_disconnect_SPDR_SA1(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/SPDR-SA1" - .format(self.restconf_baseurl)) - data = {} - headers = {'content-type': 'application/json'} - response = requests.request( - "DELETE", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) - self.assertEqual(response.status_code, requests.codes.ok) + response = test_utils.unmount_device("SPDR-SA1") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_09_getClliNetwork(self): url = ("{}/config/ietf-network:networks/network/clli-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() nbNode = len(res['network'][0]['node']) @@ -333,29 +291,26 @@ class TransportPCEtesting(unittest.TestCase): def test_10_getOpenRoadmNetwork(self): url = ("{}/config/ietf-network:networks/network/openroadm-network" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn('node', res['network'][0]) def test_11_getNodes_OpenRoadmTopology(self): url = ("{}/config/ietf-network:networks/network/openroadm-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertNotIn('node', res['network'][0]) def test_12_getNodes_OtnTopology(self): url = ("{}/config/ietf-network:networks/network/otn-topology" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json'} + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, headers=headers, auth=('admin', 'admin')) + "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertNotIn('node', res['network'][0])