See section on environment variables for details.
-cat openstack.creds::
+cat env_file::
export OS_AUTH_URL=XXX
export OS_USER_DOMAIN_NAME=XXX
Run healthcheck suite::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-healthcheck
Run smoke suite::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-smoke
Run features suite::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-features
Run components suite::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-components
Run vnf suite::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-vnf
OpenStack credentials are mandatory and must be provided to Functest.
When running the command "functest env prepare", the framework will
automatically look for the Openstack credentials file
-"/home/opnfv/functest/conf/openstack.creds" and will exit with
+"/home/opnfv/functest/conf/env_file" and will exit with
error if it is not present or is empty.
There are 2 ways to provide that file:
* by using a Docker volume with -v option when creating the Docker container.
This is referred to in docker documentation as "Bind Mounting".
See the usage of this parameter in the following chapter.
- * or creating manually the file '/home/opnfv/functest/conf/openstack.creds'
+ * or creating manually the file '/home/opnfv/functest/conf/env_file'
inside the running container and pasting the credentials in it. Consult
your installer guide for further details. This is however not
instructed in this document.
includes two main directories:
* The **conf** directory stores configuration files (e.g. the
- OpenStack creds are stored in path '/home/opnfv/functest/conf/openstack.creds'),
+ OpenStack creds are stored in path '/home/opnfv/functest/conf/env_file'),
* the **results** directory stores some temporary result log files
src and repos directories are used to host third party code used for the tests.
Once the credentials are there inside the container, they should be
sourced before running any Openstack commands::
- source /home/opnfv/functest/conf/openstack.creds
+ source /home/opnfv/functest/conf/env_file
After this, try to run any OpenStack command to see if you get any
output, for instance::
'no_proxy' environment variable are set correctly::
# Make double sure that the 'no_proxy=...' line in the
- # 'openstack.creds' file is commented out first. Otherwise, the
+ # 'env_file' file is commented out first. Otherwise, the
# values set into the 'no_proxy' environment variable below will
# be ovewrwritten, each time the command
- # 'source ~/functest/conf/openstack.creds' is issued.
+ # 'source ~/functest/conf/env_file' is issued.
cd ~/functest/conf/
- sed -i 's/export no_proxy/#export no_proxy/' openstack.creds
- source ./openstack.creds
+ sed -i 's/export no_proxy/#export no_proxy/' env_file
+ source ./env_file
# Next calculate some IP addresses for which http_proxy
# usage should be excluded:
simply run the tiers by typing (e.g. with functest-healthcheck)::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-healthcheck
Considering the healthcheck example, running functest manaully means::
sudo docker run -ti --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
opnfv/functest-healthcheck /bin/bash
The docker prompt shall be returned. Then within the docker run the following
commands::
- $ source /home/opnfv/functest/conf/openstack.creds
+ $ source /home/opnfv/functest/conf/env_file
Tier
----
or::
- source /home/opnfv/functest/conf/openstack.creds
+ source /home/opnfv/functest/conf/env_file
VIM
---
This is an example of running a customized list of Tempest tests in Functest::
sudo docker run --env-file env \
- -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/openstack.creds \
+ -v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
-v $(pwd)/my-custom-testcases.yaml:/usr/lib/python2.7/site-packages/functest/ci/testcases.yaml \
-v $(pwd)/my-custom-tempest-tests.txt:/usr/lib/python2.7/site-packages/functest/opnfv_tests/openstack/tempest/custom_tests/test_list.txt \
endpoint='{0}/credentials'.format(ENDPOINT_CREDS))
def get(self): # pylint: disable=no-self-use
""" Get credentials """
- os_utils.source_credentials(CONST.__getattribute__('openstack_creds'))
+ os_utils.source_credentials(CONST.__getattribute__('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 = CONST.__getattribute__('openstack_creds')
+ rc_file = CONST.__getattribute__('env_file')
with open(rc_file, 'w') as creds_file:
creds_file.writelines(lines)
class CheckDeployment(object):
""" Check deployment class."""
- def __init__(self, rc_file='/home/opnfv/functest/conf/openstack.creds'):
+ def __init__(self, rc_file='/home/opnfv/functest/conf/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
- openstack:
- creds: /home/opnfv/functest/conf/openstack.creds
+ env_file: /home/opnfv/functest/conf/env_file
+ openstack:
image_name: Cirros-0.4.0
image_name_alt: Cirros-0.4.0-1
image_file_name: cirros-0.4.0-x86_64-disk.img
CONST.__getattribute__('DEPLOY_SCENARIO'),
pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
- @staticmethod
- def source_rc_file():
- """Set the environmental vars from openstack.creds"""
-
- rc_file = CONST.__getattribute__('openstack_creds')
- if not os.path.isfile(rc_file):
- raise Exception("RC file %s does not exist..." % rc_file)
- LOGGER.debug("Sourcing the OpenStack RC file...")
- os_utils.source_credentials(rc_file)
-
@staticmethod
def get_run_dict(testname):
"""Obtain the 'run' block of the testcase from testcases.yaml"""
self.report_flag = kwargs['report']
try:
if 'test' in kwargs:
- self.source_rc_file()
+ LOGGER.debug("Sourcing the credential file...")
+ os_utils.source_credentials(CONST.__getattribute__('env_file'))
+
LOGGER.debug("Test args: %s", kwargs['test'])
if self.tiers.get_tier(kwargs['test']):
self.run_tier(self.tiers.get_tier(kwargs['test']))
self.os_auth_url = CONST.__getattribute__('OS_AUTH_URL')
self.endpoint_ip = None
self.endpoint_port = None
- self.openstack_creds = CONST.__getattribute__('openstack_creds')
+ self.openstack_creds = CONST.__getattribute__('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
def ping_endpoint(self):
if self.os_auth_url is None:
- click.echo("Source the OpenStack credentials first '. $creds'")
+ click.echo("Source the OpenStack credentials first")
exit(0)
response = os.system("ping -c 1 " + self.endpoint_ip + ">/dev/null")
if response == 0:
self.__logger.info("Prepare VNF: %s, description: %s",
self.tenant_name, tenant_description)
snaps_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'))
+ os_env_file=CONST.__getattribute__('env_file'))
project_creator = OpenStackProject(
snaps_creds,
""" Generate tempest.conf file"""
try:
openstack_utils.source_credentials(
- CONST.__getattribute__('openstack_creds'))
+ CONST.__getattribute__('env_file'))
resources = self.resources.create(create_project=True,
use_custom_images=True,
use_custom_flavors=True)
creds_override = CONST.__getattribute__(
'snaps_os_creds_override')
os_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'),
+ os_env_file=CONST.__getattribute__('env_file'),
proxy_settings_str=proxy_settings_str, ssh_proxy_cmd=ssh_proxy_cmd,
overrides=creds_override)
return os_creds
self.run_tests_parser = run_tests.RunTestsParser()
- @mock.patch('functest.ci.run_tests.os.path.isfile', return_value=False)
- def test_source_rc_file_ko(self, *args):
- with self.assertRaises(Exception):
- self.runner.source_rc_file()
- args[0].assert_called_once_with(
- '/home/opnfv/functest/conf/openstack.creds')
-
- @mock.patch('functest.ci.run_tests.os.path.isfile',
- return_value=True)
- def test_source_rc_file_default(self, *args):
- with mock.patch('functest.ci.run_tests.os_utils.source_credentials',
- return_value=self.creds):
- self.runner.source_rc_file()
- args[0].assert_called_once_with(
- '/home/opnfv/functest/conf/openstack.creds')
-
@mock.patch('functest.ci.run_tests.ft_utils.get_dict_by_test')
def test_get_run_dict(self, *args):
retval = {'run': mock.Mock()}
self.runner.run_all()
self.assertTrue(mock_methods[1].called)
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file',
+ @mock.patch('functest.utils.openstack_utils.source_credentials',
side_effect=Exception)
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_main_failed(self, *mock_methods):
self.runner.tiers.configure_mock(**args)
self.assertEqual(self.runner.main(**kwargs),
run_tests.Result.EX_ERROR)
- mock_methods[1].assert_called_once_with()
+ mock_methods[1].assert_called_once_with(
+ '/home/opnfv/functest/conf/env_file')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_test',
return_value=TestCase.EX_OK)
@mock.patch('functest.ci.run_tests.Runner.summary')
run_tests.Result.EX_OK)
mock_methods[1].assert_called()
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_test',
return_value=TestCase.EX_OK)
def test_main_test(self, *mock_methods):
args = {'get_tier.return_value': None,
'get_test.return_value': 'test_name'}
self.runner.tiers = mock.Mock()
+ mock_methods[1].return_value = self.creds
self.runner.tiers.configure_mock(**args)
self.assertEqual(self.runner.main(**kwargs),
run_tests.Result.EX_OK)
mock_methods[0].assert_called_once_with('test_name')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_all')
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_main_all_tier(self, *args):
run_tests.Result.EX_OK)
args[0].assert_called_once_with(None)
args[1].assert_called_once_with()
- args[2].assert_called_once_with()
+ args[2].assert_called_once_with('/home/opnfv/functest/conf/env_file')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
def test_main_any_tier_test_ko(self, *args):
kwargs = {'get_tier.return_value': None,
'get_test.return_value': None}
self.assertEqual(
self.runner.main(test='any', noclean=True, report=True),
run_tests.Result.EX_ERROR)
- args[0].assert_called_once_with()
+ args[0].assert_called_once_with('/home/opnfv/functest/conf/env_file')
if __name__ == "__main__":
self.os_auth_url = 'http://test_ip:test_port/v2.0'
self.installer_type = 'test_installer_type'
self.installer_ip = 'test_installer_ip'
- self.openstack_creds = 'test_openstack_creds'
+ self.openstack_creds = 'test_env_file'
self.snapshot_file = 'test_snapshot_file'
self.cli_os = cli_os.CliOpenStack()
self.cli_os.os_auth_url = None
self.cli_os.ping_endpoint()
mock_click_echo.assert_called_once_with(
- "Source the OpenStack credentials first '. $creds'")
+ "Source the OpenStack credentials first")
mock_exit.assert_called_once_with(0)
@mock.patch('functest.cli.commands.cli_os.exit')
with self.assertRaises(Exception):
self.test.prepare()
args[0].assert_called_with(
- os_env_file=constants.CONST.__getattribute__('openstack_creds'))
+ os_env_file=constants.CONST.__getattribute__('env_file'))
args[1].assert_not_called()
args[2].assert_not_called()
with self.assertRaises(Exception):
self.test.prepare()
args[0].assert_called_with(
- os_env_file=constants.CONST.__getattribute__('openstack_creds'))
+ os_env_file=constants.CONST.__getattribute__('env_file'))
args[1].assert_called_with(mock.ANY, mock.ANY)
args[2].assert_not_called()
with self.assertRaises(Exception):
self.test.prepare()
args[0].assert_called_with(
- os_env_file=constants.CONST.__getattribute__('openstack_creds'))
+ os_env_file=constants.CONST.__getattribute__('env_file'))
args[1].assert_called_with(mock.ANY, mock.ANY)
args[2].assert_called_with(mock.ANY, mock.ANY)
def test_prepare_default(self, *args):
self.assertEqual(self.test.prepare(), testcase.TestCase.EX_OK)
args[0].assert_called_with(
- os_env_file=constants.CONST.__getattribute__('openstack_creds'))
+ os_env_file=constants.CONST.__getattribute__('env_file'))
args[1].assert_called_with(mock.ANY, mock.ANY)
args[2].assert_called_with(mock.ANY, mock.ANY)