summaryrefslogtreecommitdiffstats
path: root/functest/core
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-02-14 16:02:53 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-02-16 10:24:22 +0100
commitd589e4e5345ed82c68d9a011ac89f8cdbefe2ca3 (patch)
tree1ec221f1f95e6abaec9b1465e9e46b76f8777a27 /functest/core
parent98e2806cb674d206dea65647c0644dc5b2871b4b (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/core')
-rw-r--r--functest/core/testcase.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/functest/core/testcase.py b/functest/core/testcase.py
index f0c6c9e9..e8bb1409 100644
--- a/functest/core/testcase.py
+++ b/functest/core/testcase.py
@@ -17,6 +17,7 @@ import re
import requests
from functest.utils import decorators
+from functest.utils import env
import prettytable
@@ -180,14 +181,14 @@ class TestCase(object):
assert self.case_name
assert self.start_time
assert self.stop_time
- url = os.environ['TEST_DB_URL']
+ url = env.get('TEST_DB_URL')
data = {"project_name": self.project_name,
"case_name": self.case_name,
"details": self.details}
- data["installer"] = os.environ['INSTALLER_TYPE']
- data["scenario"] = os.environ['DEPLOY_SCENARIO']
- data["pod_name"] = os.environ['NODE_NAME']
- data["build_tag"] = os.environ['BUILD_TAG']
+ data["installer"] = env.get('INSTALLER_TYPE')
+ data["scenario"] = env.get('DEPLOY_SCENARIO')
+ data["pod_name"] = env.get('NODE_NAME')
+ data["build_tag"] = env.get('BUILD_TAG')
data["criteria"] = 'PASS' if self.is_successful(
) == TestCase.EX_OK else 'FAIL'
data["start_date"] = datetime.fromtimestamp(
@@ -197,7 +198,7 @@ class TestCase(object):
try:
data["version"] = re.search(
TestCase._job_name_rule,
- os.environ['BUILD_TAG']).group(2)
+ env.get('BUILD_TAG')).group(2)
except Exception: # pylint: disable=broad-except
data["version"] = "unknown"
req = requests.post(
@@ -210,9 +211,6 @@ class TestCase(object):
self.__logger.exception(
"Please run test before publishing the results")
return TestCase.EX_PUSH_TO_DB_ERROR
- except KeyError as exc:
- self.__logger.error("Please set env var: " + str(exc))
- return TestCase.EX_PUSH_TO_DB_ERROR
except requests.exceptions.HTTPError:
self.__logger.exception("The HTTP request raises issues")
return TestCase.EX_PUSH_TO_DB_ERROR