Switch all func tests to lightynode 49/110149/9
authorChristophe Betoule <christophe.betoule@orange.com>
Mon, 5 Feb 2024 15:45:37 +0000 (16:45 +0100)
committerChristophe Betoule <christophe.betoule@orange.com>
Thu, 29 Feb 2024 16:53:57 +0000 (17:53 +0100)
- in tox.ini adopt lightynode sims for remaing 7.1, hybrid and
  with_docker tests
- adapt tests using netconf connector instead of restconf one as soon as
Lightynode does not support restconf api.
- adopt lighty-openroadm-device-19.1.0.5

JIRA: TRNSPRTPCE-754
Signed-off-by: Christophe Betoule <christophe.betoule@orange.com>
Change-Id: I8c049137c56c46e4ca4af1ed95a20c4d62a7d420

tests/install_lightynode.sh
tests/transportpce_tests/common/test_utils.py
tests/transportpce_tests/hybrid/test03_autonomous_reroute.py
tox.ini

index 6d1f52e200b4b47fab75faa90f663b388de523e2..aa9cd5e94fd245603cda64ba0c23ab9740a5b2d1 100755 (executable)
@@ -2,7 +2,7 @@
 
 #set -x
 
-PLUGIN_VERSION=${1:-19.1.0.3}
+PLUGIN_VERSION=${1:-19.1.0.5}
 
 #check if curl exists
 if ! [ -x "$(command -v curl)" ];then
index 1c0bf202cfedc8e2efce9e0f146637fabb5254ab..5d2789c1b024bd901f9a61c68ccc773f725e72cf 100644 (file)
@@ -28,6 +28,7 @@ from dict2xml import dict2xml
 from netconf_client.connect import connect_ssh
 from netconf_client.ncclient import Manager
 
+
 # pylint: disable=import-error
 import simulators
 
@@ -731,3 +732,42 @@ def sims_update_cp_port_ntcf(sim: tuple, circuitpack: str, payload: dict):
     if "None" in str(reply):
         return True
     return False
+
+
+def sims_update_pm_interact(sim: tuple, payload: dict):
+    if SIMS_TYPE == 'lightynode':
+        return sims_update_pm_interact_ntcf(sim, payload)
+    if SIMS_TYPE == 'honeynode':
+        return sims_update_pm_interact_rest(sim, payload)
+    return False
+
+
+def sims_update_pm_interact_rest(sim: tuple, payload: dict):
+    # pylint: disable=consider-using-f-string
+    url = "{}/operations/pm-handling:pm-interact".format(SIMS[sim]['restconf_baseurl'])
+    body = {"input": payload}
+    response = requests.request("POST",
+                                url,
+                                data=json.dumps(body),
+                                headers=TYPE_APPLICATION_JSON,
+                                auth=(ODL_LOGIN, ODL_PWD),
+                                timeout=REQUEST_TIMEOUT)
+    return response.status_code == requests.codes.ok
+
+
+def sims_update_pm_interact_ntcf(sim: tuple, payload: dict):
+    # pylint: disable=line-too-long
+    xml_body = '<pm-interact xmlns="http://honeynode-simulator/pm-handling">'
+    xml_body += dict2xml(payload, indent="  ")
+    xml_body += '</pm-interact>'
+    new_xml = xml_body.replace("<pm-resource-instance>/org-openroadm-device:org-openroadm-device/org-openroadm-device:interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']</pm-resource-instance>",
+                               "<pm-resource-instance xmlns:a=\"http://org/openroadm/device\">/a:org-openroadm-device/a:interface[a:name='OTS-DEG2-TTP-TXRX']</pm-resource-instance>")
+    with connect_ssh(host='127.0.0.1',
+                     port=int(SIMS[sim]['port']),
+                     username=NODES_LOGIN,
+                     password=NODES_PWD) as session:
+        mgr = Manager(session, timeout=120)
+        reply = mgr.dispatch(new_xml)
+    if "netconf_client.ncclient.RPCReply" in str(reply):
+        return True
+    return False
index a7bca9592ade060e3f8fbf998f90227f328c7bed..e51f290d79d1cf6ea63c46649ba7480c07134255 100644 (file)
@@ -14,7 +14,6 @@
 # pylint: disable=too-many-public-methods
 # pylint: disable=too-many-lines
 
-import json
 import unittest
 import time
 import requests
@@ -682,6 +681,64 @@ class TransportPCEtesting(unittest.TestCase):
         }
     ]
 
+    pm_handling_degrade_body = {
+        "rpc-action": "set",
+        "pm-to-be-set-or-created": {
+            "current-pm-entry": [
+                {
+                    "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
+                                            ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
+                    "pm-resource-type": "interface",
+                    "pm-resource-type-extension": "",
+                    "current-pm": [
+                        {
+                            "type": "opticalPowerInput",
+                            "extension": "",
+                            "location": "nearEnd",
+                            "direction": "rx",
+                            "measurement": [
+                                {
+                                    "granularity": "15min",
+                                    "pmParameterValue": -30,
+                                    "pmParameterUnit": "dBm",
+                                    "validity": "complete"
+                                },
+                                {
+                                    "granularity": "24Hour",
+                                    "pmParameterValue": -21.3,
+                                    "pmParameterUnit": "dBm",
+                                    "validity": "complete"
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        }
+    }
+
+    pm_handling_recover_body = {
+        "rpc-action": "clear",
+        "pm-to-get-clear-or-delete": {
+            "current-pm-entry": [
+                {
+                    "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
+                                            ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
+                    "pm-resource-type": "interface",
+                    "pm-resource-type-extension": "",
+                    "current-pm": [
+                        {
+                            "type": "opticalPowerInput",
+                            "extension": "",
+                            "location": "nearEnd",
+                            "direction": "rx"
+                        }
+                    ]
+                }
+            ]
+        }
+    }
+
     @classmethod
     def setUpClass(cls):
         cls.processes = test_utils.start_tpce()
@@ -811,50 +868,8 @@ class TransportPCEtesting(unittest.TestCase):
 
     # Degrade ROADM-A1-ROADM-C1 link
     def test_14_set_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput(self):
-        url = "{}/operations/pm-handling:pm-interact"
-        body = {
-            "input": {
-                "rpc-action": "set",
-                "pm-to-be-set-or-created": {
-                    "current-pm-entry": [
-                        {
-                            "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
-                                                    ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
-                            "pm-resource-type": "interface",
-                            "pm-resource-type-extension": "",
-                            "current-pm": [
-                                {
-                                    "type": "opticalPowerInput",
-                                    "extension": "",
-                                    "location": "nearEnd",
-                                    "direction": "rx",
-                                    "measurement": [
-                                        {
-                                            "granularity": "15min",
-                                            "pmParameterValue": -30,
-                                            "pmParameterUnit": "dBm",
-                                            "validity": "complete"
-                                        },
-                                        {
-                                            "granularity": "24Hour",
-                                            "pmParameterValue": -21.3,
-                                            "pmParameterUnit": "dBm",
-                                            "validity": "complete"
-                                        }
-                                    ]
-                                }
-                            ]
-                        }
-                    ]
-                }
-            }
-        }
-        response = requests.request("POST", url.format("http://127.0.0.1:8141/restconf"),
-                                    data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
-                                    auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD),
-                                    timeout=test_utils.REQUEST_TIMEOUT)
-        self.assertEqual(response.status_code, requests.codes.ok)
-        self.assertEqual(response.json()['output']['status-message'], "The PMs has been successfully set !")
+        self.assertTrue(test_utils.sims_update_pm_interact(('roadma', self.NODE_VERSION_221),
+                                                           self.pm_handling_degrade_body))
         time.sleep(2)
 
     def test_15_get_eth_service1(self):
@@ -891,36 +906,8 @@ class TransportPCEtesting(unittest.TestCase):
 
     # Restore ROADM-A1-ROADM-C1 link
     def test_17_clear_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput(self):
-        url = "{}/operations/pm-handling:pm-interact"
-        body = {
-            "input": {
-                "rpc-action": "clear",
-                "pm-to-get-clear-or-delete": {
-                    "current-pm-entry": [
-                        {
-                            "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
-                                                    ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
-                            "pm-resource-type": "interface",
-                            "pm-resource-type-extension": "",
-                            "current-pm": [
-                                {
-                                    "type": "opticalPowerInput",
-                                    "extension": "",
-                                    "location": "nearEnd",
-                                    "direction": "rx"
-                                }
-                            ]
-                        }
-                    ]
-                }
-            }
-        }
-        response = requests.request("POST", url.format("http://127.0.0.1:8141/restconf"),
-                                    data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
-                                    auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD),
-                                    timeout=test_utils.REQUEST_TIMEOUT)
-        self.assertEqual(response.status_code, requests.codes.ok)
-        self.assertEqual(response.json()['output']['status-message'], "The PMs has been successfully released !")
+        self.assertTrue(test_utils.sims_update_pm_interact(('roadma', self.NODE_VERSION_221),
+                                                           self.pm_handling_recover_body))
         time.sleep(2)
 
     def test_18_get_eth_service1(self):
@@ -1137,50 +1124,7 @@ class TransportPCEtesting(unittest.TestCase):
 
     # Degrade ROADM-A1-ROADM-C1 link
     def test_36_set_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput(self):
-        url = "{}/operations/pm-handling:pm-interact"
-        body = {
-            "input": {
-                "rpc-action": "set",
-                "pm-to-be-set-or-created": {
-                    "current-pm-entry": [
-                        {
-                            "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
-                                                    ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
-                            "pm-resource-type": "interface",
-                            "pm-resource-type-extension": "",
-                            "current-pm": [
-                                {
-                                    "type": "opticalPowerInput",
-                                    "extension": "",
-                                    "location": "nearEnd",
-                                    "direction": "rx",
-                                    "measurement": [
-                                        {
-                                            "granularity": "15min",
-                                            "pmParameterValue": -30,
-                                            "pmParameterUnit": "dBm",
-                                            "validity": "complete"
-                                        },
-                                        {
-                                            "granularity": "24Hour",
-                                            "pmParameterValue": -21.3,
-                                            "pmParameterUnit": "dBm",
-                                            "validity": "complete"
-                                        }
-                                    ]
-                                }
-                            ]
-                        }
-                    ]
-                }
-            }
-        }
-        response = requests.request("POST", url.format("http://127.0.0.1:8141/restconf"),
-                                    data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
-                                    auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD),
-                                    timeout=test_utils.REQUEST_TIMEOUT)
-        self.assertEqual(response.status_code, requests.codes.ok)
-        self.assertEqual(response.json()['output']['status-message'], "The PMs has been successfully set !")
+        self.test_14_set_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput()
         time.sleep(self.WAITING * 2)
 
     def test_37_get_eth_service1(self):
@@ -1244,37 +1188,7 @@ class TransportPCEtesting(unittest.TestCase):
 
     # Restore ROADM-A1-ROADM-C1 link
     def test_41_clear_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput(self):
-        url = "{}/operations/pm-handling:pm-interact"
-        body = {
-            "input": {
-                "rpc-action": "clear",
-                "pm-to-get-clear-or-delete": {
-                    "current-pm-entry": [
-                        {
-                            "pm-resource-instance": "/org-openroadm-device:org-openroadm-device/org-openroadm-device"
-                                                    ":interface[org-openroadm-device:name='OTS-DEG2-TTP-TXRX']",
-                            "pm-resource-type": "interface",
-                            "pm-resource-type-extension": "",
-                            "current-pm": [
-                                {
-                                    "type": "opticalPowerInput",
-                                    "extension": "",
-                                    "location": "nearEnd",
-                                    "direction": "rx"
-                                }
-                            ]
-                        }
-                    ]
-                }
-            }
-        }
-        response = requests.request("POST", url.format("http://127.0.0.1:8141/restconf"),
-                                    data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON,
-                                    auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD),
-                                    timeout=test_utils.REQUEST_TIMEOUT)
-        self.assertEqual(response.status_code, requests.codes.ok)
-        self.assertEqual(response.json()['output']['status-message'], "The PMs has been successfully released !")
-        time.sleep(2)
+        self.test_17_clear_pm_ROADMA_OTS_DEG2_TTP_TXRX_OpticalPowerInput()
 
     def test_42_get_eth_service1(self):
         self.test_13_get_eth_service1()
diff --git a/tox.ini b/tox.ini
index 2f79e58107334b5b0ea2c5728aabdd4fbc3aa29e..6a86daa042260b670f0d9ba88b7cb5588dc1de76 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -209,19 +209,18 @@ commands =
 
 [testenv:tests71]
 depends = buildcontroller,build_karaf_tests71,sims71,tests_tapi
-allowlist_externals = launch_tests.sh install_honeynode.sh
+allowlist_externals = launch_tests.sh
 passenv = LAUNCHER
     USE_LIGHTY
+    USE_SIMS
     NO_ODL_STARTUP
     USE_ODL_RESTCONF_VERSION
 setenv =
 #    USE_LIGHTY=True
 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
-    USE_SIMS=honeynode
     USE_ODL_ALT_KARAF_ENV=./karaf71.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
 commands =
-  ./install_honeynode.sh 7.1
   ./launch_tests.sh 7.1 {posargs:}
 
 [testenv:build_karaf_tests_hybrid]
@@ -238,21 +237,19 @@ commands =
 [testenv:tests_hybrid]
 depends = buildcontroller,build_karaf_tests_hybrid,sims121,sims221,sims71,tests121,tests221,tests71
 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
-allowlist_externals = launch_tests.sh install_honeynode.sh
+allowlist_externals = launch_tests.sh
 passenv = LAUNCHER
     USE_LIGHTY
     USE_SIMS
     NO_ODL_STARTUP
     USE_ODL_RESTCONF_VERSION
 setenv =
-    USE_SIMS=honeynode
 #    USE_LIGHTY=True
 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
     USE_ODL_ALT_KARAF_ENV=./karaf121.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
 commands =
 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
-  ./install_honeynode.sh
   ./launch_tests.sh hybrid {posargs:}
 
 [testenv:tests_tapi]
@@ -281,15 +278,15 @@ commands =
 
 [testenv:with_docker]
 depends = buildcontroller,sims221
-allowlist_externals = launch_tests.sh dockercmd.sh install_honeynode.sh
+allowlist_externals = launch_tests.sh dockercmd.sh
 passenv = LAUNCHER
     USE_LIGHTY
+    USE_SIMS
     NO_ODL_STARTUP
     USE_ODL_RESTCONF_VERSION
 #    OLM_TIMER1
 #    OLM_TIMER2
 setenv =
-    USE_SIMS=honeynode
     OLM_TIMER1=3000
     OLM_TIMER2=2000
     INSTALL_TAPI=True
@@ -297,7 +294,6 @@ setenv =
 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
 
 commands =
-  ./install_honeynode.sh 2.2.1
   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
   ./launch_tests.sh with_docker {posargs:}
   ./dockercmd.sh container rm -f tpce_kafka1