diff options
Diffstat (limited to 'functest')
-rw-r--r-- | functest/ci/config_functest.yaml | 2 | ||||
-rwxr-xr-x | functest/ci/prepare_env.py | 44 | ||||
-rw-r--r-- | functest/cli/cli_base.py | 6 | ||||
-rw-r--r-- | functest/cli/commands/cli_env.py | 27 | ||||
-rw-r--r-- | functest/cli/commands/cli_os.py | 28 | ||||
-rw-r--r-- | functest/cli/setup.py | 15 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/conf_utils.py | 5 | ||||
-rw-r--r-- | functest/tests/unit/ci/test_prepare_env.py | 15 | ||||
-rw-r--r-- | functest/tests/unit/cli/commands/test_cli_os.py | 74 | ||||
-rw-r--r-- | functest/tests/unit/cli/test_cli_base.py | 7 | ||||
-rw-r--r-- | functest/utils/decorators.py | 7 | ||||
-rwxr-xr-x | functest/utils/openstack_clean.py | 1 | ||||
-rwxr-xr-x | functest/utils/openstack_snapshot.py | 1 |
13 files changed, 43 insertions, 189 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index 5aa5bfda..1b2c8380 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -130,7 +130,7 @@ tempest: tenant_name: tempest tenant_description: Tenant for Tempest test suite user_name: tempest - user_password: tempest + user_password: Tempest123! validation: ssh_timeout: 130 object_storage: diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index e03bc654..9e53e30b 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -83,11 +83,9 @@ def check_env_variables(): % CONST.__getattribute__('INSTALLER_TYPE')) if CONST.__getattribute__('INSTALLER_IP') is None: - logger.warning("The env variable 'INSTALLER_IP' is not defined. " - "It is needed to fetch the OpenStack credentials. " - "If the credentials are not provided to the " - "container as a volume, please add this env variable " - "to the 'docker run' command.") + logger.warning( + "The env variable 'INSTALLER_IP' is not defined. It is recommended" + " to extract some information from the deployment") else: logger.info(" INSTALLER_IP=%s" % CONST.__getattribute__('INSTALLER_IP')) @@ -177,7 +175,6 @@ def create_directories(): def source_rc_file(): print_separator() - logger.info("Fetching RC file...") if CONST.__getattribute__('openstack_creds') is None: logger.warning("The environment variable 'creds' must be set and" @@ -187,38 +184,17 @@ def source_rc_file(): CONST.__getattribute__('dir_functest_conf'), 'openstack.creds') if not os.path.isfile(CONST.__getattribute__('openstack_creds')): - logger.info("RC file not provided. " - "Fetching it from the installer...") - if CONST.__getattribute__('INSTALLER_IP')is None: - logger.error("The env variable 'INSTALLER_IP' must be provided in" - " order to fetch the credentials from the installer.") - raise Exception("Missing CI_INSTALLER_IP.") - if (CONST.__getattribute__('INSTALLER_TYPE') not in - opnfv_constants.INSTALLERS): - logger.error("Cannot fetch credentials. INSTALLER_TYPE=%s is " - "not a valid OPNFV installer. Available " - "installers are : %s." % - (CONST.__getattribute__('INSTALLER_TYPE'), - opnfv_constants.INSTALLERS)) - raise Exception("Wrong INSTALLER_TYPE.") - - cmd = ("/home/opnfv/repos/releng/utils/fetch_os_creds.sh " - "-d %s -i %s -a %s" - % (CONST.__getattribute__('openstack_creds'), - CONST.__getattribute__('INSTALLER_TYPE'), - CONST.__getattribute__('INSTALLER_IP'))) - logger.debug("Executing command: %s" % cmd) - p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) - output = p.communicate()[0] - logger.debug("\n%s" % output) - if p.returncode != 0: - raise Exception("Failed to fetch credentials from installer.") + raise Exception( + "OpenStack credentials file not provided. " + "The OpenStack credentials must be in {}" + .format(CONST.__getattribute__('openstack_creds'))) else: logger.info("RC file provided in %s." % CONST.__getattribute__('openstack_creds')) if os.path.getsize(CONST.__getattribute__('openstack_creds')) == 0: - raise Exception("The file %s is empty." % - CONST.__getattribute__('openstack_creds')) + raise Exception( + "The OpenStack RC file {} is empty." + .format(CONST.__getattribute__('openstack_creds'))) logger.info("Sourcing the OpenStack RC file...") os_utils.source_credentials(CONST.__getattribute__('openstack_creds')) diff --git a/functest/cli/cli_base.py b/functest/cli/cli_base.py index 2104e125..2f085834 100644 --- a/functest/cli/cli_base.py +++ b/functest/cli/cli_base.py @@ -86,12 +86,6 @@ def os_show_credentials(): _openstack.show_credentials() -@openstack.command('fetch-rc', help="Fetch the OpenStack RC file from " - "the installer.") -def os_fetch_rc(): - _openstack.fetch_credentials() - - @env.command('prepare', help="Prepares the Functest environment. This step is " "needed run the tests.") def env_prepare(): diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py index f5ba4b34..b43116fc 100644 --- a/functest/cli/commands/cli_env.py +++ b/functest/cli/commands/cli_env.py @@ -11,6 +11,7 @@ import os import click import git +import prettytable from functest.utils.constants import CONST import functest.utils.functest_utils as ft_utils @@ -66,21 +67,19 @@ class CliEnv(object): if self.status(verbose=False) == 0: STATUS = "ready" - click.echo("+======================================================+") - click.echo("| Functest Environment info |") - click.echo("+======================================================+") - click.echo("| INSTALLER: %s|" % installer_info.ljust(41)) - click.echo("| SCENARIO: %s|" % scenario.ljust(41)) - click.echo("| POD: %s|" % node.ljust(41)) - click.echo("| GIT BRACNH: %s|" % git_branch.ljust(41)) - click.echo("| GIT HASH: %s|" % git_hash.ljust(41)) + msg = prettytable.PrettyTable( + header_style='upper', padding_width=5, + field_names=['Functest Environment', 'value']) + msg.add_row(['INSTALLER', installer_info]) + msg.add_row(['SCENARIO', scenario]) + msg.add_row(['POD', node]) + msg.add_row(['GIT BRANCH', git_branch]) + msg.add_row(['GIT HASH', git_hash]) if build_tag: - click.echo("| BUILD TAG: %s|" % build_tag.ljust(41)) - click.echo("| DEBUG FLAG: %s|" % is_debug.ljust(41)) - click.echo("+------------------------------------------------------+") - click.echo("| STATUS: %s|" % STATUS.ljust(41)) - click.echo("+------------------------------------------------------+") - click.echo("") + msg.add_row(['BUILD TAG', build_tag]) + msg.add_row(['DEBUG FLAG', is_debug]) + msg.add_row(['STATUS', STATUS]) + click.echo(msg.get_string()) def status(self, verbose=True): ret_val = 0 diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py index 5e6e1109..c66362fc 100644 --- a/functest/cli/commands/cli_os.py +++ b/functest/cli/commands/cli_os.py @@ -47,34 +47,6 @@ class CliOpenStack(object): if key.startswith('OS_'): click.echo("{}={}".format(key, value)) - def fetch_credentials(self): - if os.path.isfile(self.openstack_creds): - answer = raw_input("It seems the RC file is already present. " - "Do you want to overwrite it? [y|n]\n") - while True: - if answer.lower() in ["y", "yes"]: - break - elif answer.lower() in ["n", "no"]: - return - else: - answer = raw_input("Invalid answer. Please type [y|n]\n") - - installer_type = CONST.__getattribute__('INSTALLER_TYPE') - if installer_type is None: - click.echo("The environment variable 'INSTALLER_TYPE' is not" - "defined. Please export it") - installer_ip = CONST.__getattribute__('INSTALLER_IP') - if installer_ip is None: - click.echo("The environment variable 'INSTALLER_IP' is not" - "defined. Please export it") - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - installer_type, - installer_ip)) - click.echo("Fetching credentials from installer node '%s' with IP=%s.." - % (installer_type, installer_ip)) - ft_utils.execute_command(cmd, verbose=False) - def check(self): self.ping_endpoint() cmd = os.path.join(CONST.__getattribute__('dir_repo_functest'), diff --git a/functest/cli/setup.py b/functest/cli/setup.py deleted file mode 100644 index 21547e15..00000000 --- a/functest/cli/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -from setuptools import setup - -setup( - name='functest', - version='colorado.0.1', - py_modules=['cli_base'], - include_package_data=True, - install_requires=[ - 'click', - ], - entry_points=''' - [console_scripts] - functest=cli_base:cli - ''', -) diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 15365ccf..4eb5661e 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -290,6 +290,11 @@ def configure_tempest_update_params(tempest_conf_file, config.set('identity', 'password', CONST.__getattribute__('tempest_identity_user_password')) config.set('identity', 'region', 'RegionOne') + if os_utils.is_keystone_v3(): + auth_version = 'v3' + else: + auth_version = 'v2' + config.set('identity', 'auth_version', auth_version) config.set( 'validation', 'ssh_timeout', CONST.__getattribute__('tempest_validation_ssh_timeout')) diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py index 85d1918d..f3e15a01 100644 --- a/functest/tests/unit/ci/test_prepare_env.py +++ b/functest/tests/unit/ci/test_prepare_env.py @@ -47,14 +47,9 @@ class PrepareEnvTesting(unittest.TestCase): prepare_env.check_env_variables() mock_logger_info.assert_any_call("Checking environment variables" "...") - mock_logger_warn.assert_any_call("The env variable 'INSTALLER_IP'" - " is not defined. It is needed to" - " fetch the OpenStack credentials." - " If the credentials are not" - " provided to the container as a" - " volume, please add this env" - " variable to the 'docker run'" - " command.") + mock_logger_warn.assert_any_call( + "The env variable 'INSTALLER_IP' is not defined. It is recommended" + " to extract some information from the deployment") @mock.patch('functest.ci.prepare_env.logger.info') @mock.patch('functest.ci.prepare_env.logger.warning') @@ -272,8 +267,8 @@ class PrepareEnvTesting(unittest.TestCase): mock.patch('functest.ci.prepare_env.subprocess.Popen') \ as mock_subproc_popen, \ self.assertRaises(Exception): - CONST.__setattr__('openstack_creds', 'test_creds') - CONST.__setattr__('INSTALLER_IP', None) + CONST.__setattr__('openstack_creds', None) + CONST.__setattr__('INSTALLER_IP', 'test_ip') CONST.__setattr__('INSTALLER_TYPE', 'test_type') opnfv_constants.INSTALLERS = ['test_type'] diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py index b551ee4d..c3285ecb 100644 --- a/functest/tests/unit/cli/commands/test_cli_os.py +++ b/functest/tests/unit/cli/commands/test_cli_os.py @@ -62,80 +62,6 @@ class CliOpenStackTesting(unittest.TestCase): mock_exit.assert_called_once_with(0) @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_default(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - CONST.__setattr__('INSTALLER_TYPE', self.installer_type) - CONST.__setattr__('INSTALLER_IP', self.installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - self.installer_type, - self.installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_called_once_with("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (self.installer_type, - self.installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_missing_installer_type(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - CONST.__setattr__('INSTALLER_TYPE', None) - CONST.__setattr__('INSTALLER_IP', self.installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - None, - self.installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_any_call("The environment variable " - "'INSTALLER_TYPE' is not" - "defined. Please export it") - mock_click_echo.assert_any_call("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (None, - self.installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_missing_installer_ip(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - installer_type = self.installer_type - installer_ip = None - CONST.__setattr__('INSTALLER_TYPE', installer_type) - CONST.__setattr__('INSTALLER_IP', installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - installer_type, - installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_any_call("The environment variable " - "'INSTALLER_IP' is not" - "defined. Please export it") - mock_click_echo.assert_any_call("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (installer_type, - installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') def test_check(self, mock_ftutils_execute): with mock.patch.object(self.cli_os, 'ping_endpoint'): CONST.__setattr__('dir_repo_functest', self.dir_repo_functest) diff --git a/functest/tests/unit/cli/test_cli_base.py b/functest/tests/unit/cli/test_cli_base.py index 89603279..61bd093e 100644 --- a/functest/tests/unit/cli/test_cli_base.py +++ b/functest/tests/unit/cli/test_cli_base.py @@ -62,13 +62,6 @@ class CliBaseTesting(unittest.TestCase): self.assertEqual(result.exit_code, 0) self.assertTrue(mock_method.called) - def test_os_fetch_rc(self): - with mock.patch.object(self._openstack, 'fetch_credentials') \ - as mock_method: - result = self.runner.invoke(cli_base.os_fetch_rc) - self.assertEqual(result.exit_code, 0) - self.assertTrue(mock_method.called) - def test_env_prepare(self): with mock.patch.object(self._env, 'prepare') as mock_method: result = self.runner.invoke(cli_base.env_prepare) diff --git a/functest/utils/decorators.py b/functest/utils/decorators.py index 73e0a352..230a99e7 100644 --- a/functest/utils/decorators.py +++ b/functest/utils/decorators.py @@ -1,5 +1,12 @@ #!/usr/bin/env python +# Copyright (c) 2017 Orange and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 + # pylint: disable=missing-docstring import errno diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py index cdd91852..0ce08798 100755 --- a/functest/utils/openstack_clean.py +++ b/functest/utils/openstack_clean.py @@ -425,6 +425,7 @@ def main(): separator() remove_tenants(keystone_client, default_tenants) separator() + return 0 if __name__ == '__main__': diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py index 8f1d3b9b..233c316a 100755 --- a/functest/utils/openstack_snapshot.py +++ b/functest/utils/openstack_snapshot.py @@ -160,6 +160,7 @@ def main(): % yaml_file.read()) logger.debug("NOTE: These objects will NOT be deleted after " + "running the test.") + return 0 if __name__ == '__main__': |