From ee434acc598f71692aeed6df6f10a60b8a5a8f86 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Thu, 13 Aug 2020 00:29:16 +0200 Subject: [PATCH] add a path computation request method in functests Signed-off-by: guillaume.lambert Change-Id: I5eecbb906b79844fc829025f27893d57d2bad19b --- tests/transportpce_tests/1.2.1/test_gnpy.py | 192 ++--------- tests/transportpce_tests/1.2.1/test_pce.py | 298 +++--------------- tests/transportpce_tests/common/test_utils.py | 17 + 3 files changed, 82 insertions(+), 425 deletions(-) diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 235b85f89..3b8b69be2 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -93,30 +93,9 @@ class TransportGNPYtesting(unittest.TestCase): # Path computed by PCE is feasible according to Gnpy def test_04_path_computation_FeasibleWithPCE(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = { - "input": { - "service-name": "service-1", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-1" - }, - "service-a-end": { - "node-id": "XPONDER-1", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node1" - }, - "service-z-end": { - "node-id": "XPONDER-5", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node5" - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-1", "service-1", + {"node-id": "XPONDER-1", "service-rate": "100", "service-format": "Ethernet", "clli": "Node1"}, + {"node-id": "XPONDER-5", "service-rate": "100", "service-format": "Ethernet", "clli": "Node5"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -135,54 +114,13 @@ class TransportGNPYtesting(unittest.TestCase): # Path computed by PCE is not feasible by GNPy and GNPy cannot find # another one (low SNR) def test_05_path_computation_FoundByPCE_NotFeasibleByGnpy(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = { - "input": { - "service-name": "service-2", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-2" - }, - "service-a-end": { - "node-id": "XPONDER-1", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node1" - }, - "service-z-end": { - "node-id": "XPONDER-5", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node5" - }, - "hard-constraints": { - "include_": { - "ordered-hops": [ - { - "hop-number": "0", - "hop-type": { - "node-id": "OpenROADM-2" - } - }, - { - "hop-number": "1", - "hop-type": { - "node-id": "OpenROADM-3" - } - }, - { - "hop-number": "2", - "hop-type": { - "node-id": "OpenROADM-4" - } - } - ] - } - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-2", "service-2", + {"node-id": "XPONDER-1", "service-rate": "100", "service-format": "Ethernet", "clli": "Node1"}, + {"node-id": "XPONDER-5", "service-rate": "100", "service-format": "Ethernet", "clli": "Node5"}, + {"include_": { "ordered-hops": [ + {"hop-number": "0", "hop-type": {"node-id": "OpenROADM-2"}}, + {"hop-number": "1", "hop-type": {"node-id": "OpenROADM-3"}}, + {"hop-number": "2", "hop-type": {"node-id": "OpenROADM-4"}}]}}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -202,48 +140,12 @@ class TransportGNPYtesting(unittest.TestCase): # #PCE cannot find a path while GNPy finds a feasible one def test_06_path_computation_NotFoundByPCE_FoundByGNPy(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = { - "input": { - "service-name": "service-3", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-3" - }, - "service-a-end": { - "node-id": "XPONDER-1", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node1" - }, - "service-z-end": { - "node-id": "XPONDER-4", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node5" - }, - "hard-constraints": { - "include_": { - "ordered-hops": [ - { - "hop-number": "0", - "hop-type": { - "node-id": "OpenROADM-2" - } - }, - { - "hop-number": "1", - "hop-type": { - "node-id": "OpenROADM-3" - } - } - ] - } - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-3", "service-3", + {"node-id": "XPONDER-1", "service-rate": "100", "service-format": "Ethernet", "clli": "Node1"}, + {"node-id": "XPONDER-4", "service-rate": "100", "service-format": "Ethernet", "clli": "Node5"}, + {"include_": {"ordered-hops": [ + {"hop-number": "0", "hop-type": {"node-id": "OpenROADM-2"}}, + {"hop-number": "1", "hop-type": {"node-id": "OpenROADM-3"}}]}}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ @@ -261,60 +163,14 @@ class TransportGNPYtesting(unittest.TestCase): # Not found path by PCE and GNPy cannot find another one def test_07_path_computation_FoundByPCE_NotFeasibleByGnpy(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = { - "input": { - "service-name": "service-4", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-4" - }, - "service-a-end": { - "node-id": "XPONDER-1", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node1" - }, - "service-z-end": { - "node-id": "XPONDER-4", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "Node5" - }, - "hard-constraints": { - "include_": { - "ordered-hops": [ - { - "hop-number": "0", - "hop-type": { - "node-id": "OpenROADM-2" - } - }, - { - "hop-number": "1", - "hop-type": { - "node-id": "OpenROADM-3" - } - }, - { - "hop-number": "2", - "hop-type": { - "node-id": "OpenROADM-4" - } - }, - { - "hop-number": "3", - "hop-type": { - "node-id": "OpenROADM-3" - } - } - ] - } - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-4", "service-4", + {"node-id": "XPONDER-1", "service-rate": "100", "service-format": "Ethernet", "clli": "Node1"}, + {"node-id": "XPONDER-4", "service-rate": "100", "service-format": "Ethernet", "clli": "Node5"}, + {"include_": {"ordered-hops": [ + {"hop-number": "0","hop-type": {"node-id": "OpenROADM-2"}}, + {"hop-number": "1","hop-type": {"node-id": "OpenROADM-3"}}, + {"hop-number": "2","hop-type": {"node-id": "OpenROADM-4"}}, + {"hop-number": "3","hop-type": {"node-id": "OpenROADM-3"}}]}}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual(res['output']['configuration-response-common'][ diff --git a/tests/transportpce_tests/1.2.1/test_pce.py b/tests/transportpce_tests/1.2.1/test_pce.py index 4092c0649..48a0fe9e0 100644 --- a/tests/transportpce_tests/1.2.1/test_pce.py +++ b/tests/transportpce_tests/1.2.1/test_pce.py @@ -95,29 +95,9 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_04_path_computation_xpdr_bi(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service-1", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-1" - }, - "service-a-end": { - "node-id": "XPDRA01", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "nodeA" - }, - "service-z-end": { - "node-id": "XPDRC01", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "nodeC" - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-1", "service-1", + {"node-id": "XPDRA01", "service-rate": "100", "service-format": "Ethernet", "clli": "nodeA"}, + {"node-id": "XPDRC01", "service-rate": "100", "service-format": "Ethernet", "clli": "nodeC"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -126,29 +106,9 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_05_path_computation_rdm_bi(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service-1", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-1" - }, - "service-a-end": { - "node-id": "ROADMA01", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "NodeA" - }, - "service-z-end": { - "node-id": "ROADMC01", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "NodeC" - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-1", "service-1", + {"node-id": "ROADMA01", "service-rate": "100", "service-format": "Ethernet", "clli": "NodeA"}, + {"node-id": "ROADMC01", "service-rate": "100", "service-format": "Ethernet", "clli": "NodeC"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -195,29 +155,9 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_11_path_computation_xpdr_uni(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service-1", - "resource-reserve": "true", - "pce-metric": "hop-count", - "service-handler-header": { - "request-id": "request-1" - }, - "service-a-end": { - "node-id": "XPONDER-1-2", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "ORANGE1" - }, - "service-z-end": { - "node-id": "XPONDER-3-2", - "service-rate": "100", - "service-format": "Ethernet", - "clli": "ORANGE3" - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request-1", "service-1", + {"node-id": "XPONDER-1-2", "service-rate": "100", "service-format": "Ethernet", "clli": "ORANGE1"}, + {"node-id": "XPONDER-3-2", "service-rate": "100", "service-format": "Ethernet", "clli": "ORANGE3"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -226,29 +166,9 @@ class TransportPCEtesting(unittest.TestCase): # Path Computation success def test_12_path_computation_rdm_uni(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request1" - }, - "service-a-end": { - "service-rate": "100", - "service-format": "Ethernet", - "clli": "cll21", - "node-id": "OpenROADM-2-1" - }, - "service-z-end": { - "service-rate": "100", - "service-format": "Ethernet", - "clli": "ncli22", - "node-id": "OpenROADM-2-2" - }, - "pce-metric": "hop-count" - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request1", "service1", + {"service-rate": "100", "service-format": "Ethernet", "clli": "cll21", "node-id": "OpenROADM-2-1"}, + {"service-rate": "100", "service-format": "Ethernet", "clli": "ncli22", "node-id": "OpenROADM-2-2"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -297,14 +217,8 @@ class TransportPCEtesting(unittest.TestCase): # Test failed path computation def test_17_fail_path_computation(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-handler-header": { - "request-id": "request-1" - } - } - } - response = test_utils.post_request(url, data) + response = test_utils.post_request(test_utils.URL_PATH_COMPUTATION_REQUEST, + {"input": { "service-handler-header": { "request-id": "request-1" }}}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Service Name is not set', @@ -313,20 +227,9 @@ class TransportPCEtesting(unittest.TestCase): # Test1 success path computation def test_18_success1_path_computation(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request1" - }, - "service-a-end": { - "service-format": "Ethernet", - "service-rate": "100", - "clli": "ORANGE2", - "node-id": "XPONDER-2-2", - "tx-direction": { - "port": { + response = test_utils.path_computation_request("request1", "service1", + {"service-format": "Ethernet","service-rate": "100", "clli": "ORANGE2", "node-id": "XPONDER-2-2", + "tx-direction": {"port": { "port-device-name": "Some port-device-name", "port-type": "Some port-type", "port-name": "Some port-name", @@ -334,10 +237,8 @@ class TransportPCEtesting(unittest.TestCase): "port-shelf": "Some port-shelf", "port-slot": "Some port-slot", "port-sub-slot": "Some port-sub-slot" - } - }, - "rx-direction": { - "port": { + }}, + "rx-direction": {"port": { "port-device-name": "Some port-device-name", "port-type": "Some port-type", "port-name": "Some port-name", @@ -345,16 +246,9 @@ class TransportPCEtesting(unittest.TestCase): "port-shelf": "Some port-shelf", "port-slot": "Some port-slot", "port-sub-slot": "Some port-sub-slot" - } - } - }, - "service-z-end": { - "service-format": "Ethernet", - "service-rate": "100", - "clli": "ORANGE1", - "node-id": "XPONDER-1-2", - "tx-direction": { - "port": { + }}}, + {"service-format": "Ethernet", "service-rate": "100", "clli": "ORANGE1", "node-id": "XPONDER-1-2", + "tx-direction": {"port": { "port-device-name": "Some port-device-name", "port-type": "Some port-type", "port-name": "Some port-name", @@ -362,10 +256,8 @@ class TransportPCEtesting(unittest.TestCase): "port-shelf": "Some port-shelf", "port-slot": "Some port-slot", "port-sub-slot": "Some port-sub-slot" - } - }, - "rx-direction": { - "port": { + }}, + "rx-direction": {"port": { "port-device-name": "Some port-device-name", "port-type": "Some port-type", "port-name": "Some port-name", @@ -373,34 +265,10 @@ class TransportPCEtesting(unittest.TestCase): "port-shelf": "Some port-shelf", "port-slot": "Some port-slot", "port-sub-slot": "Some port-sub-slot" - } - } - }, - "hard-constraints": { - "customer-code": [ - "Some customer-code" - ], - "co-routing": { - "existing-service": [ - "Some existing-service" - ] - } - }, - "soft-constraints": { - "customer-code": [ - "Some customer-code" - ], - "co-routing": { - "existing-service": [ - "Some existing-service" - ] - } - }, - "pce-metric": "hop-count", - "locally-protected-links": "true" - } - } - response = test_utils.post_request(url, data) + }}}, + {"customer-code": ["Some customer-code"], "co-routing": {"existing-service": ["Some existing-service"]}}, + {"customer-code": ["Some customer-code"], "co-routing": {"existing-service": ["Some existing-service"]}}, + "hop-count", {"locally-protected-links": "true"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -409,29 +277,9 @@ class TransportPCEtesting(unittest.TestCase): # Test2 success path computation with path description def test_19_success2_path_computation(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service 1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request 1" - }, - "service-a-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-1-2", - "clli": "ORANGE1" - }, - "service-z-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-3-2", - "clli": "ORANGE3" - }, - "pce-metric": "hop-count" - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request 1", "service 1", + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-1-2", "clli": "ORANGE1"}, + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-3-2", "clli": "ORANGE3"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -444,34 +292,10 @@ class TransportPCEtesting(unittest.TestCase): # Test3 success path computation with hard-constraints exclude def test_20_success3_path_computation(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service 1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request 1" - }, - "service-a-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-1-2", - "clli": "ORANGE1" - }, - "service-z-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-3-2", - "clli": "ORANGE3" - }, - "hard-constraints": { - "exclude_": { - "node-id": ["OpenROADM-2-1", "OpenROADM-2-2"] - } - }, - "pce-metric": "hop-count" - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request 1", "service 1", + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-1-2", "clli": "ORANGE1"}, + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-3-2", "clli": "ORANGE3"}, + {"exclude_": { "node-id": ["OpenROADM-2-1", "OpenROADM-2-2"] }}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -484,29 +308,9 @@ class TransportPCEtesting(unittest.TestCase): # Path computation before deleting oms-attribute of the link :openroadm1-3 to openroadm1-2 def test_21_path_computation_before_oms_attribute_deletion(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service 1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request 1" - }, - "service-a-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-2-2", - "clli": "ORANGE2" - }, - "service-z-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-1-2", - "clli": "ORANGE1" - }, - "pce-metric": "hop-count" - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request 1", "service 1", + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-2-2", "clli": "ORANGE2"}, + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-1-2", "clli": "ORANGE1"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', @@ -531,29 +335,9 @@ class TransportPCEtesting(unittest.TestCase): # Path computation after deleting oms-attribute of the link :openroadm1-3 to openroadm1-2 def test_23_path_computation_after_oms_attribute_deletion(self): - url = "{}/operations/transportpce-pce:path-computation-request" - data = {"input": { - "service-name": "service 1", - "resource-reserve": "true", - "service-handler-header": { - "request-id": "request 1" - }, - "service-a-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-2-2", - "clli": "ORANGE2" - }, - "service-z-end": { - "service-rate": "100", - "service-format": "Ethernet", - "node-id": "XPONDER-1-2", - "clli": "ORANGE1" - }, - "pce-metric": "hop-count" - } - } - response = test_utils.post_request(url, data) + response = test_utils.path_computation_request("request 1", "service 1", + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-2-2", "clli": "ORANGE2"}, + {"service-rate": "100", "service-format": "Ethernet", "node-id": "XPONDER-1-2", "clli": "ORANGE1"}) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn('Path is calculated', diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index da746393c..3a2d6e9ea 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -46,6 +46,7 @@ URL_SERV_DELETE = "{}/operations/org-openroadm-service:service-delete" URL_SERVICE_PATH = "{}/operations/transportpce-device-renderer:service-path" URL_OTN_SERVICE_PATH = "{}/operations/transportpce-device-renderer:otn-service-path" URL_CREATE_OTS_OMS = "{}/operations/transportpce-device-renderer:create-ots-oms" +URL_PATH_COMPUTATION_REQUEST = "{}/operations/transportpce-pce:path-computation-request" TYPE_APPLICATION_JSON = {'Content-Type': 'application/json', 'Accept': 'application/json'} TYPE_APPLICATION_XML = {'Content-Type': 'application/xml', 'Accept': 'application/xml'} @@ -370,6 +371,22 @@ def create_ots_oms_request(nodeid: str, lcp: str): "logical-connection-point": lcp}} return post_request(URL_CREATE_OTS_OMS, attr) +def path_computation_request(requestid: str, servicename: str, serviceaend, servicezend, + hardconstraints=None, softconstraints=None, metric="hop-count", other_attr=None): + attr = {"service-name": servicename, + "resource-reserve": "true", + "service-handler-header": { "request-id": requestid }, + "service-a-end": serviceaend, + "service-z-end": servicezend, + "pce-metric": metric} + if hardconstraints: + attr.update({ "hard-constraints": hardconstraints}) + if softconstraints: + attr.update({ "soft-constraints": softconstraints}) + if other_attr: + attr.update(other_attr) + return post_request(URL_PATH_COMPUTATION_REQUEST, {"input": attr }) + def shutdown_process(process): if process is not None: -- 2.36.6