diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-11-09 14:04:16 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-11-09 15:05:50 +0100 |
commit | 41e88f6515b177824a3b4d33183180b164d5bd61 (patch) | |
tree | 8a18dcf16b55c18b8c5401ab3eeef8d037e2c642 | |
parent | a5bbece9c373b219fdfce1c21d84355a663ceb95 (diff) |
Print Test API links in console
It adds TEST_DB_EXT_URL to print the right links in case of NAT or SSH
port forwardings.
Change-Id: If85b00de7325909facc903fba13a3fd59a1e705f
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 384308c4a5af0a66ff9e78de17ace94ab7d1d51f)
-rw-r--r-- | xtesting/core/testcase.py | 10 | ||||
-rw-r--r-- | xtesting/tests/unit/core/test_testcase.py | 1 | ||||
-rw-r--r-- | xtesting/utils/env.py | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py index 386c9d86..d10fc37a 100644 --- a/xtesting/core/testcase.py +++ b/xtesting/core/testcase.py @@ -232,8 +232,14 @@ class TestCase(object): url, data=json.dumps(data, sort_keys=True), headers=self._headers) req.raise_for_status() - self.__logger.info( - "The results were successfully pushed to DB") + if urllib.parse.urlparse(url).scheme != "file": + res_url = req.json()["href"] + if env.get('TEST_DB_EXT_URL'): + res_url = res_url.replace( + env.get('TEST_DB_URL'), env.get('TEST_DB_EXT_URL')) + self.__logger.info( + "The results were successfully pushed to DB: \n\n%s\n", + res_url) except AssertionError: self.__logger.exception( "Please run test before publishing the results") diff --git a/xtesting/tests/unit/core/test_testcase.py b/xtesting/tests/unit/core/test_testcase.py index 3dbbac2c..73062149 100644 --- a/xtesting/tests/unit/core/test_testcase.py +++ b/xtesting/tests/unit/core/test_testcase.py @@ -58,6 +58,7 @@ class TestCaseTesting(unittest.TestCase): self.test.result = 100 self.test.details = {"Hello": "World"} os.environ['TEST_DB_URL'] = TestCaseTesting._test_db_url + os.environ['TEST_DB_EXT_URL'] = TestCaseTesting._test_db_url os.environ['INSTALLER_TYPE'] = "installer_type" os.environ['DEPLOY_SCENARIO'] = "scenario" os.environ['NODE_NAME'] = "node_name" diff --git a/xtesting/utils/env.py b/xtesting/utils/env.py index c781b846..dde6778e 100644 --- a/xtesting/utils/env.py +++ b/xtesting/utils/env.py @@ -20,6 +20,7 @@ INPUTS = { 'BUILD_TAG': None, 'NODE_NAME': None, 'TEST_DB_URL': 'http://testresults.opnfv.org/test/api/v1/results', + 'TEST_DB_EXT_URL': None, 'ENERGY_RECORDER_API_URL': 'http://energy.opnfv.fr/resources', 'ENERGY_RECORDER_API_USER': None, 'ENERGY_RECORDER_API_PASSWORD': None, |