##############################################################################
import os
-sims = {
+SIMS = {
'xpdra': {'port': '17830', 'configfile': 'oper-XPDRA.xml', 'logfile': 'oper-XPDRA.log'},
'roadma': {'port': '17831', 'configfile': 'oper-ROADMA.xml', 'logfile': 'oper-ROADMA.log'},
'roadmb': {'port': '17832', 'configfile': 'oper-ROADMB.xml', 'logfile': 'oper-ROADMB.log'},
'roadmc-full': {'port': '17823', 'configfile': 'oper-ROADMC-full.xml', 'logfile': 'oper-ROADMC.log'}
}
-honeynode_executable = os.path.join(
+HONEYNODE_EXECUTABLE = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "honeynode", "1.2.1", "honeynode-simulator", "honeycomb-tpce")
-samples_directory = os.path.join(
+SAMPLES_DIRECTORY = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "sample_configs", "openroadm", "1.2.1")
import json
-import signal
import time
import unittest
-import psutil
import requests
from common import test_utils
for ele in liste_tp:
if ele['tp-id'] == 'XPDR1-NETWORK1':
self.assertEqual({u'frequency': 196.1, u'width': 40},
- ele[
- 'org-openroadm-network-topology:'
- 'xpdr-network-attributes'][
- 'wavelength'])
- if ele['tp-id'] == 'XPDR1-CLIENT1' or \
- ele['tp-id'] == 'XPDR1-CLIENT3':
+ ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
+ if ele['tp-id'] == 'XPDR1-CLIENT1' or ele['tp-id'] == 'XPDR1-CLIENT3':
self.assertNotIn(
'org-openroadm-network-topology:xpdr-client-attributes',
dict.keys(ele))
def test_49_loop_create_eth_service(self):
for i in range(1, 6):
- print("trial number {}".format(i))
+ print("iteration number {}".format(i))
print("eth service creation")
self.test_11_create_eth_service1()
print("check xc in ROADMA01")
time.sleep(5)
for i in range(1, 6):
- print("trial number {}".format(i))
+ print("iteration number {}".format(i))
print("oc service creation")
self.test_36_create_oc_service1()
print("check xc in ROADMA01")
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import unittest
import json
import os
-import psutil
-import requests
-import signal
import time
-import unittest
+import requests
from common import test_utils
#############################################################################
import unittest
-import requests
import time
-import subprocess
-import signal
import json
-import os
-import psutil
-import shutil
-from unittest.result import failfast
+#from unittest.result import failfast
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import unittest
import json
import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
import time
-import unittest
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import json
-import signal
import unittest
import time
import requests
-import psutil
from common import test_utils
#############################################################################
import unittest
-import requests
-import time
-import subprocess
-import signal
import json
-import os
-import psutil
-import shutil
-from unittest.result import failfast
+import time
+#from unittest.result import failfast
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import json
-import signal
import time
import unittest
import requests
-import psutil
from common import test_utils
##############################################################################
import json
-import signal
import time
import unittest
import requests
-import psutil
from common import test_utils
import os
-sims = {
+SIMS = {
'xpdra': {'port': '17840', 'configfile': 'oper-XPDRA.xml', 'logfile': 'oper-XPDRA.log'},
'roadma': {'port': '17841', 'configfile': 'oper-ROADMA.xml', 'logfile': 'oper-ROADMA.log'},
'roadmb': {'port': '17842', 'configfile': 'oper-ROADMB.xml', 'logfile': 'oper-ROADMB.log'},
'spdrav1': {'port': '17846', 'configfile': 'oper-SPDRAv1.xml', 'logfile': 'oper-SPDRAv1.log'}
}
-honeynode_executable = os.path.join(
+HONEYNODE_EXECUTABLE = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "honeynode", "2.2.1", "honeynode-simulator", "honeycomb-tpce")
-samples_directory = os.path.join(
+SAMPLES_DIRECTORY = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "sample_configs", "openroadm", "2.2.1")
##############################################################################
+import unittest
import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
import time
-import unittest
+import requests
from common import test_utils
def test_49_loop_create_eth_service(self):
for i in range(1, 6):
- print("trial number {}".format(i))
+ print("iteration number {}".format(i))
print("eth service creation")
self.test_11_create_eth_service1()
print("check xc in ROADM-A1")
time.sleep(5)
for i in range(1, 6):
- print("trial number {}".format(i))
+ print("iteration number {}".format(i))
print("oc service creation")
self.test_36_create_oc_service1()
print("check xc in ROADM-A1")
#############################################################################
import unittest
-import requests
import time
-import subprocess
-import signal
import json
-import os
-import psutil
-import shutil
-from unittest.result import failfast
+#from unittest.result import failfast
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import unittest
import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
import time
-import unittest
-import logging
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
-import time
import unittest
+import time
import logging
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
-import time
import unittest
+import time
+import requests
from common import test_utils
#############################################################################
import unittest
-import requests
-import time
-import subprocess
-import signal
import json
-import os
-import psutil
-import shutil
-from unittest.result import failfast
+#from unittest.result import failfast
+import requests
from common import test_utils
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_21_service_path_delete_rdm_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_22_service_path_delete_rdm_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_23_service_path_delete_xpdr_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_24_service_path_delete_xpdr_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_25_service_path_delete_xpdr_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_26_service_path_delete_xpdr_check(self):
"GET", url, headers=headers, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
res = response.json()
- self.assertIn(
- {"error-type": "application", "error-tag": "data-missing",
- "error-message": "Request could not be completed because the relevant data model content does not exist"},
+ self.assertIn({
+ "error-type": "application",
+ "error-tag": "data-missing",
+ "error-message": "Request could not be completed because the relevant data model content does not exist"},
res['errors']['error'])
def test_27_service_path_delete_xpdr_check(self):
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import os
-import re
+import sys
import time
import unittest
result = test_utils.install_karaf_feature("odl-transportpce-tapi")
if result.returncode != 0:
cls.init_failed = True
- print("Restarting opendaylight...")
+ print("Restarting OpenDaylight...")
test_utils.shutdown_process(cls.processes[0])
cls.processes = test_utils.start_tpce()
cls.init_failed = not test_utils.wait_until_log_contains(
- test_utils.karaf_log, test_utils.KARAF_OK_START_MSG, time_to_wait=60)
+ test_utils.KARAF_LOG, test_utils.KARAF_OK_START_MSG, time_to_wait=60)
if cls.init_failed:
print("tapi installaiton feature failed...")
test_utils.shutdown_process(cls.odl_processes[0])
- exit(2)
+ sys.exit(2)
cls.processes = test_utils.start_sims(['xpdra', 'roadma', 'roadmc', 'xpdrc', 'spdrav2'])
@classmethod
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import unittest
import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
import time
-import unittest
-import logging
+import requests
from common import test_utils
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
-import time
import unittest
+import time
+import json
import logging
+import requests
from common import test_utils
##############################################################################
import json
import os
+import sys
import re
import signal
import subprocess
import simulators
-sims = simulators.sims
-honeynode_executable = simulators.honeynode_executable
-samples_directory = simulators.samples_directory
+SIMS = simulators.SIMS
+HONEYNODE_EXECUTABLE = simulators.HONEYNODE_EXECUTABLE
+SAMPLES_DIRECTORY = simulators.SAMPLES_DIRECTORY
HONEYNODE_OK_START_MSG = "Netconf SSH endpoint started successfully at 0.0.0.0"
KARAF_OK_START_MSG = re.escape(
CODE_SHOULD_BE_200 = 'Http status code should be 200'
CODE_SHOULD_BE_201 = 'Http status code should be 201'
-log_directory = os.path.dirname(os.path.realpath(__file__))
+LOG_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
-karaf_log = os.path.join(
+KARAF_LOG = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "..", "karaf", "target", "assembly", "data", "log", "karaf.log")
process_list = []
if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True':
- tpce_log = 'odl.log'
+ TPCE_LOG = 'odl.log'
else:
- tpce_log = karaf_log
+ TPCE_LOG = KARAF_LOG
+
def start_sims(sims_list):
for sim in sims_list:
print("starting simulator for " + sim + "...")
- log_file = os.path.join(log_directory, sims[sim]['logfile'])
- process = start_honeynode(log_file, sims[sim]['port'], sims[sim]['configfile'])
+ log_file = os.path.join(LOG_DIRECTORY, SIMS[sim]['logfile'])
+ process = start_honeynode(log_file, SIMS[sim]['port'], SIMS[sim]['configfile'])
if wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 100):
print("simulator for " + sim + " started")
else:
shutdown_process(process)
for pid in process_list:
shutdown_process(pid)
- exit(3)
+ sys.exit(3)
process_list.append(process)
return process_list
# TODO: add some sort of health check similar to Karaf below
else:
process = start_karaf()
- if wait_until_log_contains(karaf_log, KARAF_OK_START_MSG, time_to_wait=60):
+ if wait_until_log_contains(KARAF_LOG, KARAF_OK_START_MSG, time_to_wait=60):
print("OpenDaylight started !")
else:
print("OpenDaylight failed to start !")
shutdown_process(process)
for pid in process_list:
shutdown_process(pid)
- exit(1)
+ sys.exit(1)
process_list.append(process)
return process_list
"netconf-node-topology:username": NODES_LOGIN,
"netconf-node-topology:password": NODES_PWD,
"netconf-node-topology:host": "127.0.0.1",
- "netconf-node-topology:port": sims[sim]['port'],
+ "netconf-node-topology:port": SIMS[sim]['port'],
"netconf-node-topology:tcp-only": "false",
"netconf-node-topology:pass-through": {}}]}
response = put_request(url, headers, ODL_LOGIN, ODL_PWD)
- if wait_until_log_contains(tpce_log, re.escape("Triggering notification stream NETCONF for node "+node_id), 60):
+ if wait_until_log_contains(TPCE_LOG, re.escape("Triggering notification stream NETCONF for node "+node_id), 60):
print("Node "+node_id+" correctly added to tpce topology", end='... ', flush=True)
else:
print("Node "+node_id+" still not added to tpce topology", end='... ', flush=True)
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/"
+ node_id).format(RESTCONF_BASE_URL)
response = delete_request(url, ODL_LOGIN, ODL_PWD)
- if wait_until_log_contains(tpce_log, re.escape("onDeviceDisConnected: "+node_id), 60):
+ if wait_until_log_contains(TPCE_LOG, re.escape("onDeviceDisConnected: "+node_id), 60):
print("Node "+node_id+" correctly deleted from tpce topology", end='... ', flush=True)
else:
print("Node "+node_id+" still not deleted from tpce topology", end='... ', flush=True)
def start_honeynode(log_file: str, node_port: str, node_config_file_name: str):
- if os.path.isfile(honeynode_executable):
+ if os.path.isfile(HONEYNODE_EXECUTABLE):
with open(log_file, 'w') as outfile:
return subprocess.Popen(
- [honeynode_executable, node_port, os.path.join(samples_directory, node_config_file_name)],
+ [HONEYNODE_EXECUTABLE, node_port, os.path.join(SAMPLES_DIRECTORY, node_config_file_name)],
stdout=outfile, stderr=outfile)
found = False
tail = None
try:
- with timeout(seconds=time_to_wait):
+ with TimeOut(seconds=time_to_wait):
print("Searching for pattern '"+regexp+"' in "+os.path.basename(log_file), end='... ', flush=True)
tail = subprocess.Popen(['tail', '-F', log_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
compiled_regexp = re.compile(regexp)
# TODO try to find an alternative to subprocess+tail -f (such as https://pypi.org/project/tailhead/)
-class timeout:
+class TimeOut:
def __init__(self, seconds=1, error_message='Timeout'):
self.seconds = seconds
self.error_message = error_message