From: Cédric Ollivier Date: Mon, 12 Feb 2018 10:33:49 +0000 (+0100) Subject: Simplify functest/cli/commands/cli_env.py X-Git-Tag: opnfv-6.0.0~167 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F52035%2F2;p=functest.git Simplify functest/cli/commands/cli_env.py CONST shouldn't be used for getting/setting env vars. It adds complexity and may raise side effects. It also removes the obsolete env var CI_DEBUG. Change-Id: I8a8fde0fa781351d5eabd2698ca8aae9dee76fb8 Signed-off-by: Cédric Ollivier --- diff --git a/docs/testing/user/configguide/configguide.rst b/docs/testing/user/configguide/configguide.rst index 431e9635d..9adf79e14 100644 --- a/docs/testing/user/configguide/configguide.rst +++ b/docs/testing/user/configguide/configguide.rst @@ -235,7 +235,6 @@ when performing manual test scenarios: * NODE_NAME = * BUILD_TAG = - * CI_DEBUG = where: @@ -255,11 +254,6 @@ where: which are independently pushed to the results database from different Jenkins jobs. DO NOT USE THIS OPTION IN MANUAL TEST SCENARIOS. - * = "true" or "false" - Default = "false", if not specified - If "true" is specified, then additional debug trace - text can be sent to the test results file / log files - and also to the standard console output. Openstack credentials diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py index c1b66da41..a5c0e3996 100644 --- a/functest/cli/commands/cli_env.py +++ b/functest/cli/commands/cli_env.py @@ -8,11 +8,10 @@ # pylint: disable=missing-docstring +import os + import click import prettytable - -from functest.utils.constants import CONST - import six @@ -20,24 +19,19 @@ class Env(object): # pylint: disable=too-few-public-methods @staticmethod def show(): - def _get_value(attr, default='Unknown'): - return attr if attr else default - - install_type = _get_value(CONST.__getattribute__('INSTALLER_TYPE')) - installer_ip = _get_value(CONST.__getattribute__('INSTALLER_IP')) + install_type = os.environ.get('INSTALLER_TYPE', 'Unknown') + installer_ip = os.environ.get('INSTALLER_IP', 'Unknown') installer_info = ("%s, %s" % (install_type, installer_ip)) - scenario = _get_value(CONST.__getattribute__('DEPLOY_SCENARIO')) - node = _get_value(CONST.__getattribute__('NODE_NAME')) - is_debug = _get_value(CONST.__getattribute__('CI_DEBUG'), 'false') - build_tag = CONST.__getattribute__('BUILD_TAG') - if build_tag is not None: + scenario = os.environ.get('DEPLOY_SCENARIO', 'Unknown') + node = os.environ.get('NODE_NAME', 'Unknown') + build_tag = os.environ.get('BUILD_TAG', None) + if build_tag: build_tag = build_tag.lstrip( "jenkins-").lstrip("functest").lstrip("-") env_info = {'INSTALLER': installer_info, 'SCENARIO': scenario, 'POD': node, - 'DEBUG FLAG': is_debug, 'BUILD_TAG': build_tag} return env_info diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py index 883772348..d17da166e 100644 --- a/functest/tests/unit/cli/commands/test_cli_env.py +++ b/functest/tests/unit/cli/commands/test_cli_env.py @@ -48,9 +48,6 @@ class CliEnvTesting(unittest.TestCase): elif var == 'BUILD_TAG': os.environ['BUILD_TAG'] = '' reg_string = r"| BUILD TAG: None|" - elif var == 'DEBUG': - os.environ['CI_DEBUG'] = '' - reg_string = r"| DEBUG FLAG: false\s*|" with mock.patch('functest.cli.commands.cli_env.click.echo') \ as mock_click_echo: @@ -72,9 +69,6 @@ class CliEnvTesting(unittest.TestCase): def test_show_missing_ci_build_tag(self, *args): self._test_show_missing_env_var('BUILD_TAG', *args) - def test_show_missing_ci_debug(self, *args): - self._test_show_missing_env_var('DEBUG', *args) - if __name__ == "__main__": logging.disable(logging.CRITICAL) diff --git a/functest/utils/env.py b/functest/utils/env.py index f6e6e100f..aaa5beacc 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -13,7 +13,6 @@ class Environment(object): # pylint: disable=too-few-public-methods default_envs = { 'NODE_NAME': 'unknown_pod', - 'CI_DEBUG': 'false', 'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha', 'DEPLOY_TYPE': 'virt', 'INSTALLER_TYPE': None,