diff options
author | Dimitrios Markou <mardim@intracom-telecom.com> | 2017-08-25 10:43:22 +0300 |
---|---|---|
committer | Dimitrios Markou <mardim@intracom-telecom.com> | 2017-08-31 11:25:56 +0300 |
commit | 4a607daea35b21b86d063a9f32a332396ce5681a (patch) | |
tree | 51fb90e63874b90ae9dda3c9a2cde48ac9a7abcc /sfc/lib | |
parent | 60f2b2cf578fbf2a9e0efba4709d4aa6aa8a2f79 (diff) |
Adapt the testcases to multiple installers
Right now the testcases are dependent to only one installer.
So when we are trying to run the testcases to multiple installers
the tests are failing.
This patch make the testcases independent to the installer that they
run.
The testcases are running until the point which they hit the tacker
client commands.They are failing in the tacker client commands
because we need the new library for the upstream tacker API.
The testaces have already tested to two installers (Fuel,Apex-ha).
Also this patch contains the changes which are required for the
adaptation to the new functest.
For more information see the Jira tickets [0],[1],[2].
[0]: https://jira.opnfv.org/browse/SFC-100
[1]: https://jira.opnfv.org/browse/SFC-101
[2]: https://jira.opnfv.org/browse/SFC-102
Change-Id: Id1e5d5c94a65ab8bdea9584fa833bfa0cdec6632
Signed-off-by: Dimitrios Markou <mardim@intracom-telecom.com>
Diffstat (limited to 'sfc/lib')
-rw-r--r-- | sfc/lib/config.py | 30 | ||||
-rw-r--r-- | sfc/lib/utils.py | 39 |
2 files changed, 47 insertions, 22 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 |