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__)
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)
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)
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>"
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
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
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):
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)
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):
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
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>")
"""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)
"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,
"""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
: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
from functest.core import vnf
from functest.core import testcase
+from functest.utils import constants
from snaps.openstack.os_credentials import OSCreds
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()
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()
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)
@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)
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__):
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()