diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-02-14 16:02:53 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-02-16 10:24:22 +0100 |
commit | d589e4e5345ed82c68d9a011ac89f8cdbefe2ca3 (patch) | |
tree | 1ec221f1f95e6abaec9b1465e9e46b76f8777a27 /functest/ci | |
parent | 98e2806cb674d206dea65647c0644dc5b2871b4b (diff) |
Get properly env vars or their default values
It defines env.get() as an unique way to get Functest env vars or
their default values. It can be considered as a wrapper above os.environ.
It enforces backward compatibility via CONST which mustn't be used
for that purpose. It should be noted that it also stops using CONST
for getting OpenStack env vars.
Change-Id: I333dc1afbc0123166a7eaff8b551370098efa341
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/ci')
-rw-r--r-- | functest/ci/run_tests.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index ff38720d..ca101ce6 100644 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -27,8 +27,9 @@ import enum import prettytable import yaml -import functest.ci.tier_builder as tb -import functest.core.testcase as testcase +from functest.ci import tier_builder +from functest.core import testcase +from functest.utils import env LOGGER = logging.getLogger('functest.ci.run_tests') ENV_FILE = "/home/opnfv/functest/conf/env_file" @@ -88,9 +89,9 @@ class Runner(object): self.overall_result = Result.EX_OK self.clean_flag = True self.report_flag = False - self.tiers = tb.TierBuilder( - os.environ.get('INSTALLER_TYPE', None), - os.environ.get('DEPLOY_SCENARIO', None), + self.tiers = tier_builder.TierBuilder( + env.get('INSTALLER_TYPE'), + env.get('DEPLOY_SCENARIO'), pkg_resources.resource_filename('functest', 'ci/testcases.yaml')) @staticmethod @@ -207,7 +208,7 @@ class Runner(object): field_names=['tiers', 'order', 'CI Loop', 'description', 'testcases']) for tier in self.tiers.get_tiers(): - ci_loop = os.environ.get('CI_LOOP', 'daily') + ci_loop = env.get('CI_LOOP') if (tier.get_tests() and re.search(ci_loop, tier.get_ci_loop()) is not None): tiers_to_run.append(tier) @@ -247,7 +248,7 @@ class Runner(object): LOGGER.error("Unknown test case or tier '%s', or not " "supported by the given scenario '%s'.", kwargs['test'], - os.environ.get('DEPLOY_SCENARIO', "")) + env.get('DEPLOY_SCENARIO')) LOGGER.debug("Available tiers are:\n\n%s", self.tiers) return Result.EX_ERROR @@ -270,7 +271,7 @@ class Runner(object): field_names=['env var', 'value']) for env_var in ['INSTALLER_TYPE', 'DEPLOY_SCENARIO', 'BUILD_TAG', 'CI_LOOP']: - msg.add_row([env_var, os.environ.get(env_var, "")]) + msg.add_row([env_var, env.get(env_var)]) LOGGER.info("Deployment description:\n\n%s\n", msg) msg = prettytable.PrettyTable( header_style='upper', padding_width=5, |