diff options
-rw-r--r-- | functest/api/resources/v1/creds.py | 6 | ||||
-rw-r--r-- | functest/ci/check_deployment.py | 3 | ||||
-rw-r--r-- | functest/ci/config_functest.yaml | 2 | ||||
-rw-r--r-- | functest/ci/run_tests.py | 4 | ||||
-rw-r--r-- | functest/cli/commands/cli_os.py | 4 | ||||
-rw-r--r-- | functest/core/vnf.py | 4 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/snaps/snaps_utils.py | 11 | ||||
-rw-r--r-- | functest/tests/unit/core/test_vnf.py | 9 | ||||
-rw-r--r-- | functest/utils/constants.py | 10 | ||||
-rw-r--r-- | functest/utils/env.py | 4 |
10 files changed, 31 insertions, 26 deletions
diff --git a/functest/api/resources/v1/creds.py b/functest/api/resources/v1/creds.py index 25c0fd242..3eae19662 100644 --- a/functest/api/resources/v1/creds.py +++ b/functest/api/resources/v1/creds.py @@ -23,7 +23,7 @@ from functest.api.base import ApiResource from functest.api.common import api_utils from functest.ci import run_tests from functest.cli.commands.cli_os import OpenStack -from functest.utils.constants import CONST +from functest.utils import constants LOGGER = logging.getLogger(__name__) @@ -39,7 +39,7 @@ class V1Creds(ApiResource): endpoint='{0}/credentials'.format(ENDPOINT_CREDS)) def get(self): # pylint: disable=no-self-use """ Get credentials """ - run_tests.Runner.source_envfile(getattr(CONST, 'env_file')) + run_tests.Runner.source_envfile(constants.ENV_FILE) credentials_show = OpenStack.show_credentials() return jsonify(credentials_show) @@ -65,7 +65,7 @@ class V1Creds(ApiResource): lines = ['export {}={}\n'.format(k, v) for k, v in openrc_vars.items()] - rc_file = getattr(CONST, 'env_file') + rc_file = constants.ENV_FILE with open(rc_file, 'w') as creds_file: creds_file.writelines(lines) diff --git a/functest/ci/check_deployment.py b/functest/ci/check_deployment.py index bf43b5372..a475491a1 100644 --- a/functest/ci/check_deployment.py +++ b/functest/ci/check_deployment.py @@ -28,6 +28,7 @@ from snaps.openstack.utils import keystone_utils from snaps.openstack.utils import neutron_utils from snaps.openstack.utils import nova_utils +from functest.utils import constants from functest.opnfv_tests.openstack.snaps import snaps_utils __author__ = "Jose Lausuch <jose.lausuch@ericsson.com>" @@ -68,7 +69,7 @@ def get_auth_token(os_creds): class CheckDeployment(object): """ Check deployment class.""" - def __init__(self, rc_file='/home/opnfv/functest/conf/env_file'): + def __init__(self, rc_file=constants.ENV_FILE): self.rc_file = rc_file self.services = ('compute', 'network', 'image') self.os_creds = None diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index be7a2db58..e93b025d4 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -15,8 +15,6 @@ general: functest_images: /home/opnfv/functest/images rally_inst: /root/.rally - env_file: /home/opnfv/functest/conf/env_file - openstack: image_name: Cirros-0.4.0 image_name_alt: Cirros-0.4.0-1 diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index ca101ce6b..0b9803036 100644 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -29,10 +29,10 @@ import yaml from functest.ci import tier_builder from functest.core import testcase +from functest.utils import constants from functest.utils import env LOGGER = logging.getLogger('functest.ci.run_tests') -ENV_FILE = "/home/opnfv/functest/conf/env_file" class Result(enum.Enum): @@ -95,7 +95,7 @@ class Runner(object): pkg_resources.resource_filename('functest', 'ci/testcases.yaml')) @staticmethod - def source_envfile(rc_file=ENV_FILE): + def source_envfile(rc_file=constants.ENV_FILE): """Source the env file passed as arg""" if not os.path.isfile(rc_file): LOGGER.debug("No env file %s found", rc_file) diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py index 0cf286238..47d55c963 100644 --- a/functest/cli/commands/cli_os.py +++ b/functest/cli/commands/cli_os.py @@ -14,7 +14,7 @@ import click from six.moves import urllib from functest.ci import check_deployment -from functest.utils.constants import CONST +from functest.utils import constants class OpenStack(object): @@ -23,7 +23,7 @@ class OpenStack(object): self.os_auth_url = os.environ['OS_AUTH_URL'] self.endpoint_ip = None self.endpoint_port = None - self.openstack_creds = getattr(CONST, 'env_file') + self.openstack_creds = constants.ENV_FILE if self.os_auth_url: self.endpoint_ip = urllib.parse.urlparse(self.os_auth_url).hostname self.endpoint_port = urllib.parse.urlparse(self.os_auth_url).port diff --git a/functest/core/vnf.py b/functest/core/vnf.py index 05baf432a..cf20492b1 100644 --- a/functest/core/vnf.py +++ b/functest/core/vnf.py @@ -20,6 +20,7 @@ from snaps.openstack.create_project import OpenStackProject from snaps.openstack.tests import openstack_tests from functest.core import testcase +from functest.utils import constants __author__ = ("Morgan Richomme <morgan.richomme@orange.com>, " "Valentin Boucher <valentin.boucher@orange.com>") @@ -46,7 +47,6 @@ class VnfOnBoarding(testcase.TestCase): """Base model for VNF test cases.""" __logger = logging.getLogger(__name__) - env_file = "/home/opnfv/functest/conf/env_file" def __init__(self, **kwargs): super(VnfOnBoarding, self).__init__(**kwargs) @@ -110,7 +110,7 @@ class VnfOnBoarding(testcase.TestCase): "Prepare VNF: %s, description: %s", self.case_name, self.tenant_description) snaps_creds = openstack_tests.get_credentials( - os_env_file=self.env_file) + os_env_file=constants.ENV_FILE) self.os_project = OpenStackProject( snaps_creds, diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py index 4b1c93524..fc03ee9bd 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py @@ -9,7 +9,7 @@ """Some common utils wrapping snaps functions """ -from functest.utils.constants import CONST +from functest.utils import constants from functest.utils import env from snaps.openstack.tests import openstack_tests @@ -52,10 +52,9 @@ def get_credentials(proxy_settings_str=None, ssh_proxy_cmd=None): :return: an instance of snaps OSCreds object """ creds_override = None - if hasattr(CONST, 'snaps_os_creds_override'): - creds_override = getattr(CONST, 'snaps_os_creds_override') + if hasattr(constants.CONST, 'snaps_os_creds_override'): + creds_override = getattr(constants.CONST, 'snaps_os_creds_override') os_creds = openstack_tests.get_credentials( - os_env_file=getattr(CONST, 'env_file'), - proxy_settings_str=proxy_settings_str, ssh_proxy_cmd=ssh_proxy_cmd, - overrides=creds_override) + os_env_file=constants.ENV_FILE, proxy_settings_str=proxy_settings_str, + ssh_proxy_cmd=ssh_proxy_cmd, overrides=creds_override) return os_creds diff --git a/functest/tests/unit/core/test_vnf.py b/functest/tests/unit/core/test_vnf.py index 16a609027..0ac672f6c 100644 --- a/functest/tests/unit/core/test_vnf.py +++ b/functest/tests/unit/core/test_vnf.py @@ -16,6 +16,7 @@ import mock from functest.core import vnf from functest.core import testcase +from functest.utils import constants from snaps.openstack.os_credentials import OSCreds @@ -113,7 +114,7 @@ class VnfBaseTesting(unittest.TestCase): def test_prepare_exc1(self, *args): with self.assertRaises(Exception): self.test.prepare() - args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) + args[0].assert_called_with(os_env_file=constants.ENV_FILE) args[1].assert_not_called() args[2].assert_not_called() @@ -123,7 +124,7 @@ class VnfBaseTesting(unittest.TestCase): def test_prepare_exc2(self, *args): with self.assertRaises(Exception): self.test.prepare() - args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) + args[0].assert_called_with(os_env_file=constants.ENV_FILE) args[1].assert_called_with(mock.ANY, mock.ANY) args[2].assert_not_called() @@ -133,7 +134,7 @@ class VnfBaseTesting(unittest.TestCase): def test_prepare_exc3(self, *args): with self.assertRaises(Exception): self.test.prepare() - args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) + args[0].assert_called_with(os_env_file=constants.ENV_FILE) args[1].assert_called_with(mock.ANY, mock.ANY) args[2].assert_called_with(mock.ANY, mock.ANY) @@ -142,7 +143,7 @@ class VnfBaseTesting(unittest.TestCase): @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials') def test_prepare_default(self, *args): self.assertEqual(self.test.prepare(), testcase.TestCase.EX_OK) - args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) + args[0].assert_called_with(os_env_file=constants.ENV_FILE) args[1].assert_called_with(mock.ANY, mock.ANY) args[2].assert_called_with(mock.ANY, mock.ANY) diff --git a/functest/utils/constants.py b/functest/utils/constants.py index d8a1d54d1..2184c472f 100644 --- a/functest/utils/constants.py +++ b/functest/utils/constants.py @@ -8,11 +8,17 @@ import six from functest.utils import config from functest.utils import env +CONFIG_FUNCTEST_YAML = pkg_resources.resource_filename( + 'functest', 'ci/config_functest.yaml') + +ENV_FILE = '/home/opnfv/functest/conf/env_file' + class Constants(object): # pylint: disable=too-few-public-methods - CONFIG_FUNCTEST_YAML = pkg_resources.resource_filename( - 'functest', 'ci/config_functest.yaml') + # Backward compatibility (waiting for SDNVPN and SFC) + CONFIG_FUNCTEST_YAML = CONFIG_FUNCTEST_YAML + env_file = ENV_FILE def __init__(self): for attr_n, attr_v in six.iteritems(config.CONF.__dict__): diff --git a/functest/utils/env.py b/functest/utils/env.py index 0c0515ba1..e75b17d1a 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -37,10 +37,10 @@ def get(env_var): class Environment(object): # pylint: disable=too-few-public-methods - # Backward compatibilty (waiting for SDNVPN and SFC) + # Backward compatibility (waiting for SDNVPN and SFC) def __init__(self): for key, _ in six.iteritems(INPUTS): setattr(self, key, get(key)) -# Backward compatibilty (waiting for SDNVPN and SFC) +# Backward compatibility (waiting for SDNVPN and SFC) ENV = Environment() |