aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sfc/lib/config.py30
-rw-r--r--sfc/lib/utils.py39
-rw-r--r--sfc/tests/functest/config.yaml12
-rw-r--r--sfc/tests/functest/run_sfc_tests.py76
-rw-r--r--sfc/tests/functest/sfc_one_chain_two_service_functions.py13
-rw-r--r--sfc/tests/functest/sfc_symmetric_chain.py9
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py15
7 files changed, 133 insertions, 61 deletions
diff --git a/sfc/lib/config.py b/sfc/lib/config.py
index c1e73e46..16613eab 100644
--- a/sfc/lib/config.py
+++ b/sfc/lib/config.py
@@ -10,7 +10,10 @@
import os
import yaml
+import sfc
+import functest
+import sfc.lib.utils as test_utils
from functest.utils.constants import CONST
import logging
import functest.utils.functest_utils as ft_utils
@@ -27,37 +30,44 @@ class CommonConfig(object):
def __init__(self):
self.line_length = 30
self.test_db = ft_utils.get_functest_config("results.test_db_url")
- self.repo_path = CONST.dir_repo_sfc
+ self.functest_repo_path = os.path.dirname(functest.__file__)
+ self.functest_logging_api = os.path.join(self.functest_repo_path,
+ "ci", "logging.ini")
+ self.sfc_repo_path = os.path.dirname(sfc.__file__)
self.sfc_test_dir = os.path.join(
- self.repo_path, "sfc", "tests", "functest")
+ self.sfc_repo_path, "tests", "functest")
self.vnfd_dir = os.path.join(self.sfc_test_dir, "vnfd-templates")
self.vnfd_default_params_file = os.path.join(
self.sfc_test_dir, "vnfd-default-params-file")
self.functest_results_dir = os.path.join(
CONST.dir_results, "odl-sfc")
self.config_file = os.path.join(self.sfc_test_dir, "config.yaml")
- self.installer_type = ft_utils.get_parameter_from_yaml(
- "defaults.installer.type", self.config_file)
- self.installer_ip = ft_utils.get_parameter_from_yaml(
- "defaults.installer.ip", self.config_file)
+
+ self.installer_type = CONST.__getattribute__('INSTALLER_TYPE')
+
+ self.installer_fields = test_utils.fill_installer_dict(
+ self.installer_type)
+
+ self.installer_ip = CONST.__getattribute__('INSTALLER_IP')
+
self.installer_user = ft_utils.get_parameter_from_yaml(
- "defaults.installer.user", self.config_file)
+ self.installer_fields['user'], self.config_file)
try:
self.installer_password = ft_utils.get_parameter_from_yaml(
- "defaults.installer.password", self.config_file)
+ self.installer_fields['password'], self.config_file)
except:
self.installer_password = None
try:
self.installer_key_file = ft_utils.get_parameter_from_yaml(
- "defaults.installer.key_file", self.config_file)
+ self.installer_fields['pkey_file'], self.config_file)
except:
self.installer_key_file = None
try:
self.installer_cluster = ft_utils.get_parameter_from_yaml(
- "defaults.installer.cluster", self.config_file)
+ self.installer_fields['cluster'], self.config_file)
except:
self.installer_cluster = None
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py
index 2a188960..bc7a9ddc 100644
--- a/sfc/lib/utils.py
+++ b/sfc/lib/utils.py
@@ -7,15 +7,15 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-
+import ConfigParser
import os
import re
import subprocess
import requests
import time
-import xmltodict
import yaml
+
import logging
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
@@ -559,16 +559,20 @@ def get_nova_id(tacker_client, resource, vnf_id=None, vnf_name=None):
def get_odl_ip_port(nodes):
- local_jetty = os.path.join(os.getcwd(), 'jetty.xml')
- odl_node = next(n for n in nodes if n.is_odl())
- odl_node.get_file('/opt/opendaylight/etc/jetty.xml', local_jetty)
- with open(local_jetty) as fd:
- parsed = xmltodict.parse(fd.read(), dict_constructor=dict)
-
- ip = (parsed['Configure']['Call'][0]['Arg']['New']
- ['Set'][0]['Property']['@default'])
- port = (parsed['Configure']['Call'][0]['Arg']['New']
- ['Set'][1]['Property']['@default'])
+ controller_node = next(n for n in nodes if n.is_controller())
+ home_folder = controller_node.run_cmd('pwd')
+ remote_ml2_conf_etc = '/etc/neutron/plugins/ml2/ml2_conf.ini'
+ remote_ml2_conf_home = '{0}/ml2_conf.ini'.format(home_folder)
+ local_ml2_conf_file = os.path.join(os.getcwd(), 'ml2_conf.ini')
+ controller_node.run_cmd('sudo cp {0} {1}/'
+ .format(remote_ml2_conf_etc, home_folder))
+ controller_node.run_cmd('sudo chmod 777 {0}'
+ .format(remote_ml2_conf_home))
+ controller_node.get_file(remote_ml2_conf_home, local_ml2_conf_file)
+ con_par = ConfigParser.RawConfigParser()
+ con_par.read(local_ml2_conf_file)
+ ip, port = re.search(r'[0-9]+(?:\.[0-9]+){3}\:[0-9]+',
+ con_par.get('ml2_odl', 'url')).group().split(':')
return ip, port
@@ -651,3 +655,14 @@ def delete_classifier_and_acl(tacker_client, clf_name, odl_ip, odl_port):
odl_port,
'ietf-access-control-list:ipv4-acl',
clf_name)
+
+
+def fill_installer_dict(installer_type):
+ default_string = "defaults.installer.{}.".format(installer_type)
+ installer_yaml_fields = {
+ "user": default_string+"user",
+ "password": default_string+"password",
+ "cluster": default_string+"cluster",
+ "pkey_file": default_string+"pkey_file"
+ }
+ return installer_yaml_fields
diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml
index d28456dd..b844880d 100644
--- a/sfc/tests/functest/config.yaml
+++ b/sfc/tests/functest/config.yaml
@@ -8,11 +8,13 @@ defaults:
image_name: sfc_nsh_danube
image_file_name: sfc_nsh_danube.qcow2
installer:
- type: fuel
- ip: 10.20.0.2
- user: root
- password: r00tme
- cluster: 1 # Change this to the id of the desired fuel env (1, 2, 3...)
+ fuel:
+ user: root
+ password: r00tme
+ cluster: 1 # Change this to the id of the desired fuel env (1, 2, 3...)
+ apex:
+ user: stack
+ pkey_file: "/root/.ssh/id_rsa"
image_format: qcow2
url: "http://artifacts.opnfv.org/sfc/images"
vnfd-dir: "vnfd-templates"
diff --git a/sfc/tests/functest/run_sfc_tests.py b/sfc/tests/functest/run_sfc_tests.py
index c569165b..edf9595e 100644
--- a/sfc/tests/functest/run_sfc_tests.py
+++ b/sfc/tests/functest/run_sfc_tests.py
@@ -14,8 +14,8 @@ import time
import sys
import yaml
-from functest.core import testcase
from functest.utils import openstack_utils as os_utils
+from functest.core import testcase
from opnfv.utils import ovs_logger as ovs_log
from opnfv.deployment.factory import Factory as DeploymentFactory
from sfc.lib import cleanup as sfc_cleanup
@@ -40,8 +40,43 @@ class SfcFunctest(testcase.OSGCTestCase):
logger.info("found tackerc file")
return rc_file
- def __disable_heat_resource_finder_cache(self, nodes):
- controllers = [node for node in nodes if node.is_controller()]
+ def __disable_heat_resource_finder_cache_apex(self, controllers):
+ remote_heat_conf_etc = '/etc/heat/heat.conf'
+ remote_heat_conf_home = '/home/heat-admin/heat.conf'
+ local_heat_conf = '/tmp/heat.conf'
+ cmd_restart_heat = ("sudo"
+ " /bin/systemctl"
+ " restart"
+ " openstack-heat-engine.service"
+ )
+ for controller in controllers:
+ logger.info("Fetch {0} from controller {1}"
+ .format(remote_heat_conf_etc, controller.ip))
+ controller.run_cmd('sudo cp {0} /home/heat-admin/'
+ .format(remote_heat_conf_etc))
+ controller.run_cmd('sudo chmod 777 {0}'
+ .format(remote_heat_conf_home))
+ controller.get_file(remote_heat_conf_home, local_heat_conf)
+ with open(local_heat_conf, 'a') as cfg:
+ cfg.write('\n[resource_finder_cache]\n')
+ cfg.write('caching=False\n')
+ logger.info("Replace {0} with {1} in controller {2}"
+ .format(remote_heat_conf_etc,
+ local_heat_conf,
+ controller.ip))
+ controller.run_cmd('sudo rm -f {0}'.format(remote_heat_conf_home))
+ controller.run_cmd('sudo rm -f {0}'.format(remote_heat_conf_etc))
+ controller.put_file(local_heat_conf,
+ remote_heat_conf_home)
+ controller.run_cmd('sudo cp {0} /etc/heat/'
+ .format(remote_heat_conf_home))
+ logger.info("Restart heat-engine in {0}".format(controller.ip))
+ controller.run_cmd(cmd_restart_heat)
+ os.remove(local_heat_conf)
+ logger.info("Waiting for heat-engine to restart in controllers")
+ time.sleep(10)
+
+ def __disable_heat_resource_finder_cache_fuel(self, controllers):
remote_heat_conf = '/etc/heat/heat.conf'
local_heat_conf = '/tmp/heat.conf'
for controller in controllers:
@@ -63,32 +98,45 @@ class SfcFunctest(testcase.OSGCTestCase):
logger.info("Waiting for heat-engine to restart in controllers")
time.sleep(10)
+ def __disable_heat_resource_finder_cache(self, nodes, installer_type):
+ controllers = [node for node in nodes if node.is_controller()]
+
+ if installer_type == 'apex':
+ self.__disable_heat_resource_finder_cache_apex(controllers)
+ elif installer_type == "fuel":
+ self.__disable_heat_resource_finder_cache_fuel(controllers)
+ else:
+ raise Exception('Unsupported installer')
+
def run(self):
deploymentHandler = DeploymentFactory.get_handler(
COMMON_CONFIG.installer_type,
COMMON_CONFIG.installer_ip,
COMMON_CONFIG.installer_user,
- installer_pwd=COMMON_CONFIG.installer_password)
+ COMMON_CONFIG.installer_password,
+ COMMON_CONFIG.installer_key_file)
cluster = COMMON_CONFIG.installer_cluster
nodes = (deploymentHandler.get_nodes({'cluster': cluster})
if cluster is not None
else deploymentHandler.get_nodes())
- a_controller = [node for node in nodes
- if node.is_controller()][0]
+ self.__disable_heat_resource_finder_cache(nodes,
+ COMMON_CONFIG.installer_type)
- self.__disable_heat_resource_finder_cache(nodes)
+ if COMMON_CONFIG.installer_type == 'fuel':
+ a_controller = [node for node in nodes
+ if node.is_controller()][0]
- rc_file = self.__fetch_tackerc_file(a_controller)
- os_utils.source_credentials(rc_file)
+ rc_file = self.__fetch_tackerc_file(a_controller)
+ os_utils.source_credentials(rc_file)
- logger.info("Updating env with {0}".format(rc_file))
- logger.info("OS credentials:")
- for var, value in os.environ.items():
- if var.startswith("OS_"):
- logger.info("\t{0}={1}".format(var, value))
+ logger.info("Updating env with {0}".format(rc_file))
+ logger.info("OS credentials:")
+ for var, value in os.environ.items():
+ if var.startswith("OS_"):
+ logger.info("\t{0}={1}".format(var, value))
odl_ip, odl_port = sfc_utils.get_odl_ip_port(nodes)
diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
index 3f1165ec..695c8b36 100644
--- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py
+++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
@@ -7,13 +7,11 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-
import os
import sys
import threading
-
import logging
-from functest.utils.constants import CONST
+
import functest.utils.openstack_tacker as os_tacker
import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
@@ -40,9 +38,11 @@ def main():
COMMON_CONFIG.installer_type,
COMMON_CONFIG.installer_ip,
COMMON_CONFIG.installer_user,
- installer_pwd=COMMON_CONFIG.installer_password)
+ COMMON_CONFIG.installer_password,
+ COMMON_CONFIG.installer_key_file)
cluster = COMMON_CONFIG.installer_cluster
+
openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster})
if cluster is not None
else deploymentHandler.get_nodes())
@@ -55,7 +55,7 @@ def main():
odl_ip, odl_port = test_utils.get_odl_ip_port(openstack_nodes)
for compute in compute_nodes:
- logger.info("This is a compute: %s" % compute.info)
+ logger.info("This is a compute: %s" % compute.ip)
results = Results(COMMON_CONFIG.line_length)
results.add_to_summary(0, "=")
@@ -275,6 +275,5 @@ def main():
if __name__ == '__main__':
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(COMMON_CONFIG.functest_logging_api)
main()
diff --git a/sfc/tests/functest/sfc_symmetric_chain.py b/sfc/tests/functest/sfc_symmetric_chain.py
index 686d7fc0..cdcd8d3a 100644
--- a/sfc/tests/functest/sfc_symmetric_chain.py
+++ b/sfc/tests/functest/sfc_symmetric_chain.py
@@ -12,8 +12,8 @@
import os
import sys
import threading
-
import logging
+
import functest.utils.openstack_tacker as os_tacker
import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
@@ -25,7 +25,6 @@ from sfc.lib.results import Results
import sfc.lib.topology_shuffler as topo_shuffler
-from functest.utils.constants import CONST
logger = logging.getLogger(__name__)
CLIENT = "client"
@@ -39,7 +38,8 @@ def main():
COMMON_CONFIG.installer_type,
COMMON_CONFIG.installer_ip,
COMMON_CONFIG.installer_user,
- installer_pwd=COMMON_CONFIG.installer_password)
+ COMMON_CONFIG.installer_password,
+ COMMON_CONFIG.installer_key_file)
cluster = COMMON_CONFIG.installer_cluster
all_nodes = (deploymentHandler.get_nodes({'cluster': cluster})
@@ -250,6 +250,5 @@ def main():
if __name__ == '__main__':
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(COMMON_CONFIG.functest_logging_api)
main()
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
index 7f121b93..f0c5844e 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -11,8 +11,8 @@
import os
import sys
import threading
-
import logging
+
import functest.utils.openstack_tacker as os_tacker
import functest.utils.openstack_utils as os_utils
import opnfv.utils.ovs_logger as ovs_log
@@ -23,7 +23,6 @@ from sfc.lib.results import Results
from opnfv.deployment.factory import Factory as DeploymentFactory
import sfc.lib.topology_shuffler as topo_shuffler
-from functest.utils.constants import CONST
logger = logging.getLogger(__name__)
@@ -38,7 +37,8 @@ def main():
COMMON_CONFIG.installer_type,
COMMON_CONFIG.installer_ip,
COMMON_CONFIG.installer_user,
- installer_pwd=COMMON_CONFIG.installer_password)
+ COMMON_CONFIG.installer_password,
+ COMMON_CONFIG.installer_key_file)
cluster = COMMON_CONFIG.installer_cluster
openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster})
@@ -53,7 +53,7 @@ def main():
odl_ip, odl_port = test_utils.get_odl_ip_port(openstack_nodes)
for compute in compute_nodes:
- logger.info("This is a compute: %s" % compute.info)
+ logger.info("This is a compute: %s" % compute.ip)
results = Results(COMMON_CONFIG.line_length)
results.add_to_summary(0, "=")
@@ -61,9 +61,9 @@ def main():
results.add_to_summary(0, "=")
installer_type = os.environ.get("INSTALLER_TYPE")
- if installer_type != "fuel":
+ if installer_type != "fuel" and installer_type != "apex":
logger.error(
- '\033[91mCurrently supported only Fuel Installer type\033[0m')
+ '\033[91mCurrently supported only Fuel and Apex\033[0m')
sys.exit(1)
installer_ip = os.environ.get("INSTALLER_IP")
@@ -321,6 +321,5 @@ def main():
if __name__ == '__main__':
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(COMMON_CONFIG.functest_logging_api)
main()