aboutsummaryrefslogtreecommitdiffstats
path: root/functest/ci/run_tests.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-02-08 18:55:08 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-02-08 19:24:34 +0100
commit181e6d6e4828711744d451185d64c5c4939824fe (patch)
tree18722b0e324de7e11234c22dc44efd3d429dd262 /functest/ci/run_tests.py
parent89bb80232f777b0619d4168b292338c16a0a704c (diff)
Move source_credentials() into run_tests.py
It's also renamed source_envfile(). Change-Id: I0e7c38c2def125961f86dc2bc9a63cfb6ad87c03 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/ci/run_tests.py')
-rw-r--r--functest/ci/run_tests.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index feef7d6a5..89c74a975 100644
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -29,7 +29,6 @@ import prettytable
import functest.ci.tier_builder as tb
import functest.core.testcase as testcase
import functest.utils.functest_utils as ft_utils
-import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
# __name__ cannot be used here
@@ -99,6 +98,22 @@ class Runner(object):
pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
@staticmethod
+ def source_envfile(rc_file):
+ """Source the env file passed as arg"""
+ with open(rc_file, "r") as rcfd:
+ for line in rcfd:
+ var = (line.rstrip('"\n').replace('export ', '').split(
+ "=") if re.search(r'(.*)=(.*)', line) else None)
+ # The two next lines should be modified as soon as rc_file
+ # conforms with common rules. Be aware that it could induce
+ # issues if value starts with '
+ if var:
+ key = re.sub(r'^["\' ]*|[ \'"]*$', '', var[0])
+ value = re.sub(r'^["\' ]*|[ \'"]*$', '', "".join(var[1:]))
+ os.environ[key] = value
+ setattr(CONST, key, value)
+
+ @staticmethod
def get_run_dict(testname):
"""Obtain the 'run' block of the testcase from testcases.yaml"""
try:
@@ -202,7 +217,7 @@ class Runner(object):
try:
if 'test' in kwargs:
LOGGER.debug("Sourcing the credential file...")
- os_utils.source_credentials(CONST.__getattribute__('env_file'))
+ self.source_envfile(getattr(CONST, 'env_file'))
LOGGER.debug("Test args: %s", kwargs['test'])
if self.tiers.get_tier(kwargs['test']):