From 3fbd1085b8fe00e05b4bd71f0e27798242d3e159 Mon Sep 17 00:00:00 2001
From: Cédric Ollivier <cedric.ollivier@orange.com>
Date: Sat, 30 Nov 2019 10:44:46 +0100
Subject: Postprocess the TestAPI href returned
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[1] returned http://localhost:8082

[1] https://build.opnfv.org/ci/job/airship-opnfv-functest-healthcheck-latest-connection_check-run/58/console

Change-Id: Ifc0e37a97442193a77762ecc2928b100e27028cd
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 740afc884b2af2f068945e7a9963d5e4b66a1a0e)
---
 xtesting/core/testcase.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'xtesting/core')

diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py
index b8d4e4de..ab82ecfc 100644
--- a/xtesting/core/testcase.py
+++ b/xtesting/core/testcase.py
@@ -237,13 +237,14 @@ class TestCase(object):
                 headers=self._headers)
             req.raise_for_status()
             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'))
+                # href must be postprocessed as OPNFV testapi is misconfigured
+                # (localhost is returned)
+                uid = re.sub(r'^.*/api/v1/results/*', '', req.json()["href"])
+                netloc = env.get('TEST_DB_EXT_URL') if env.get(
+                    'TEST_DB_EXT_URL') else env.get('TEST_DB_URL')
                 self.__logger.info(
                     "The results were successfully pushed to DB: \n\n%s\n",
-                    res_url)
+                    os.path.join(netloc, uid))
         except AssertionError:
             self.__logger.exception(
                 "Please run test before publishing the results")
-- 
cgit