aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-10-07 13:12:39 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-10-13 09:28:16 +0800
commitf7b4e61fcc20c5814d9b7ed5ebefbec1b549cd03 (patch)
treeb912b940397d6d570cb4865d7c54b20b41e173e7 /dashboard
parent2dda7f90927934bc5738287b2f8960a4d14bb07e (diff)
Refactor pushing suite result to test db
modification: remove compute_suite.py,network_suite.py,storage_suite.py handler all suite result in suite_result.py refactor pushtoDB.py so that it can be called by qtip_server JIRA:QTIP-99 Change-Id: I1630a512c22cba7be038f5301f1454b8ef4f762f Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/__init__.py0
-rw-r--r--dashboard/pushtoDB.py27
2 files changed, 15 insertions, 12 deletions
diff --git a/dashboard/__init__.py b/dashboard/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dashboard/__init__.py
diff --git a/dashboard/pushtoDB.py b/dashboard/pushtoDB.py
index d5458b1d..e6a4d239 100644
--- a/dashboard/pushtoDB.py
+++ b/dashboard/pushtoDB.py
@@ -3,6 +3,10 @@ import json
import datetime
import os
import sys
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('push_db').get
+
TEST_DB = 'http://testresults.opnfv.org/test/api/v1'
suite_list = [('compute_result.json', 'compute_test_suite'),
@@ -11,28 +15,25 @@ suite_list = [('compute_result.json', 'compute_test_suite'),
payload_list = {}
-def push_results_to_db(db_url, case_name, payload, logger=None, pod_name="dell-pod1"):
+def push_results_to_db(db_url, case_name, payload, installer, pod_name):
url = db_url + "/results"
creation_date = str(datetime.datetime.utcnow().isoformat())
- installer = os.environ['INSTALLER_TYPE']
- pod_name = os.environ['NODE_NAME']
params = {"project_name": "qtip", "case_name": case_name,
"pod_name": pod_name, "installer": installer, "start_date": creation_date,
"version": "test", "details": payload}
headers = {'Content-Type': 'application/json'}
- print pod_name
- print installer
- print creation_date
-
+ logger.info('pod_name:{0},installer:{1},creation_data:{2}'.format(pod_name,
+ installer,
+ creation_date))
try:
r = requests.post(url, data=json.dumps(params), headers=headers)
- print r
+ logger.info(r)
return True
except:
- print "Error:", sys.exc_info()[0]
+ logger.info("Error:{0}".format(sys.exc_info()[0]))
return False
@@ -50,13 +51,15 @@ def main():
global payload_list
populate_payload(suite_list)
if payload_list:
- print payload_list
+ logger.info(payload_list)
for suite, case in payload_list.items():
with open('results/' + suite, 'r') as result_file:
j = json.load(result_file)
- push_results_to_db(TEST_DB, case, j)
+ push_results_to_db(TEST_DB, case, j,
+ os.environ['INSTALLER_TYPE'],
+ os.environ['NODE_NAME'])
elif not payload_list:
- print 'Results not found'
+ logger.info('Results not found')
if __name__ == "__main__":