Stop hardcoding results suffix in push_to_db 11/33511/2
authorMatthewLi <matthew.lijun@huawei.com>
Wed, 19 Apr 2017 06:21:14 +0000 (02:21 -0400)
committerCédric Ollivier <cedric.ollivier@orange.com>
Wed, 19 Apr 2017 08:53:10 +0000 (10:53 +0200)
Adding results in url is useless as it is defined in results
section in config_functest.yaml.

It allows defining the full name in case of dumping to file (see
decorator.py). The commented local file is the value required by
dovetail.

Co-Authored-By: Cédric Ollivier <cedric.ollivier@orange.com>
Change-Id: I35ba9b34d99e138292f099934e28585ee8b85604
Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/ci/config_functest.yaml
functest/utils/decorators.py
functest/utils/functest_utils.py

index 95a4408..a9ad15c 100755 (executable)
@@ -201,6 +201,6 @@ example:
     sg_desc: Example Security group
 
 results:
-    # you can also set a dir (e.g. /home/opnfv/db) to dump results
-    # test_db_url: file:///home/opnfv/db
-    test_db_url: http://testresults.opnfv.org/test/api/v1
+    # you can also set a file (e.g. /home/opnfv/functest/results/dump.txt) to dump results
+    # test_db_url: file:///home/opnfv/functest/results/dump.txt
+    test_db_url: http://testresults.opnfv.org/test/api/v1/results
index 276235d..2ca3106 100644 (file)
@@ -13,11 +13,12 @@ def can_dump_request_to_file(method):
         parseresult = urlparse.urlparse(request.url)
         if parseresult.scheme == "file":
             try:
-                os.makedirs(parseresult.path)
+                dirname = os.path.dirname(parseresult.path)
+                os.makedirs(dirname)
             except OSError as e:
                 if e.errno != errno.EEXIST:
                     raise
-            with open(os.path.join(parseresult.path, 'dump.txt'), 'a') as f:
+            with open(parseresult.path, 'a') as f:
                 headers = ""
                 for key in request.headers:
                     headers += key + " " + request.headers[key] + "\n"
index ef9d3da..0d61241 100644 (file)
@@ -197,7 +197,7 @@ def push_results_to_db(project, case_name,
     POST results to the Result target DB
     """
     # Retrieve params from CI and conf
-    url = get_db_url() + "/results"
+    url = get_db_url()
 
     try:
         installer = os.environ['INSTALLER_TYPE']