Print Test API links in console 20/68820/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sat, 9 Nov 2019 13:04:16 +0000 (14:04 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sat, 9 Nov 2019 13:43:34 +0000 (14:43 +0100)
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>
xtesting/core/testcase.py
xtesting/tests/unit/core/test_testcase.py
xtesting/utils/env.py

index cd0a937..a385651 100644 (file)
@@ -232,8 +232,14 @@ class TestCase():
                 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")
index 3dbbac2..7306214 100644 (file)
@@ -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"
index 9ce3998..73acf3b 100644 (file)
@@ -21,6 +21,7 @@ INPUTS = {
     'BUILD_TAG': None,
     'NODE_NAME': None,
     'TEST_DB_URL': 'http://testresults.opnfv.org/test/api/v1/results',
+    'TEST_DB_EXT_URL': None,
     'S3_ENDPOINT_URL': None,
     'S3_DST_URL': None,
     'HTTP_DST_URL': None