summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-03-30 10:23:01 +0000
committerxudan <xudan16@huawei.com>2017-03-31 02:29:51 +0000
commit8bde91d7e2b58b5313f0b069b052cda82915b6b5 (patch)
tree6158b6fb8e5b888d6b2b45aaa2fb7cf34c62cb06 /dovetail/utils/dovetail_utils.py
parentaa8654d4f3f727f99016aaa540c8d5aa3f79edcb (diff)
dovetail tool: check push_to_db success or fail
JIRA: DOVETAIL-380 If Functest fails to push results to db, there is just an error log in functest.log Dovetail needs to know the failure. Dovetail will get the results from db with keys, build_tag and testcase. If it can get the results data, it means push_to_db success. Fix the duration time wrong. Change-Id: If03bdf0ceb2f1a9d422381cdf06e1fd207358bd5 Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 32d334e8..e72a37ca 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -14,6 +14,8 @@ import os
import re
import subprocess
from collections import Mapping, Set, Sequence
+import json
+import urllib2
def exec_log(verbose, logger, msg, level, flush=False):
@@ -123,6 +125,20 @@ def get_ext_net_name(env_file, logger=None):
return None
+def check_db_results(db_url, build_tag, testcase, logger):
+ url = "%s/results?build_tag=%s&case=%s" % (db_url, build_tag, testcase)
+ logger.debug("Query to rest api: %s", url)
+ try:
+ data = json.load(urllib2.urlopen(url))
+ if data['results']:
+ return True
+ else:
+ return False
+ except Exception as e:
+ logger.error("Cannot read content from %s, exception: %s", url, e)
+ return False
+
+
def show_progress_bar(length):
max_len = 50
length %= max_len