summaryrefslogtreecommitdiffstats
path: root/dovetail/report.py
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2017-01-19 02:07:16 -0500
committerMatthewLi <matthew.lijun@huawei.com>2017-01-25 20:38:24 -0500
commit3374309f5aae1dc2be3ac1eee545a05bca69b8e6 (patch)
tree93f118cf97b72faf1dd26561441d9e4dced98258 /dovetail/report.py
parent8475a7b2d96bc55da4414220337315c7096ad686 (diff)
dovetail tool: functest different testsuite support and yardstick testcase added
JIRA: DOVETAIL-186 Change-Id: Id0eec6652c9595c660436dec89a309a77b16bc03 Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
Diffstat (limited to 'dovetail/report.py')
-rw-r--r--dovetail/report.py64
1 files changed, 44 insertions, 20 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index 91a4ebd4..286c3893 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -221,7 +221,37 @@ class FunctestCrawler:
self.logger.info('result file not found: %s', file_path)
return None
- try:
+ criteria = 'FAIL'
+ timestart = 0
+ testcase_duration = 0
+ testcase_name = testcase.validate_testcase()
+ json_results = {}
+ if testcase_name in dt_cfg.dovetail_config['functest_testcase']:
+ file_path = \
+ os.path.join(dovetail_config['result_dir'],
+ dovetail_config[self.type]['result']['file_path'])
+ if not os.path.exists(file_path):
+ self.logger.info('result file not found: %s', file_path)
+ return None
+ with open(file_path, 'r') as f:
+ for jsonfile in f:
+ data = json.loads(jsonfile)
+ if testcase_name == data['case_name']:
+ criteria = data['details']['status']
+ timestart = data['details']['timestart']
+ testcase_duration = data['details']['duration']
+
+ json_results = {'criteria': criteria,
+ 'details': {"timestart": timestart,
+ "duration": testcase_duration,
+ "tests": '', "failures": ''}}
+ elif 'tempest' in testcase_name:
+ file_path = \
+ os.path.join(dovetail_config['result_dir'],
+ dovetail_config[self.type]['result']['tp_path'])
+ if not os.path.exists(file_path):
+ self.logger.info('result file not found: %s', file_path)
+ return None
with open(file_path, 'r') as myfile:
output = myfile.read()
error_logs = ""
@@ -229,8 +259,7 @@ class FunctestCrawler:
for match in re.findall('(.*?)[. ]*FAILED', output):
error_logs += match
- criteria = 'PASS'
- failed_num = int(re.findall(' - Failed: (\d*)', output)[0])
+ failed_num = int(re.findall(' - Failures: (\d*)', output)[0])
if failed_num != 0:
criteria = 'FAIL'
@@ -240,12 +269,9 @@ class FunctestCrawler:
"duration": int(dur_sec_int),
"tests": int(num_tests), "failures": failed_num,
"errors": error_logs}}
- self.logger.debug('Results: %s', str(json_results))
- return json_results
- except Exception as e:
- self.logger.error('Cannot read content from the file: %s, '
- 'exception: %s', file_path, e)
- return None
+
+ self.logger.debug('Results: %s', str(json_results))
+ return json_results
def crawl_from_url(self, testcase=None):
url = \
@@ -289,17 +315,15 @@ class YardstickCrawler:
if not os.path.exists(file_path):
self.logger.info('result file not found: %s', file_path)
return None
- try:
- with open(file_path, 'r') as myfile:
- myfile.read()
- criteria = 'PASS'
- json_results = {'criteria': criteria}
- self.logger.debug('Results: %s', str(json_results))
- return json_results
- except Exception as e:
- self.logger.error('Cannot read content from the file: %s, '
- 'exception: %s', file_path, e)
- return None
+ criteria = 'FAIL'
+ with open(file_path, 'r') as f:
+ for jsonfile in f:
+ data = json.loads(jsonfile)
+ if 1 == data['status']:
+ criteria = 'PASS'
+ json_results = {'criteria': criteria}
+ self.logger.debug('Results: %s', str(json_results))
+ return json_results
def crawl_from_url(self, testcase=None):
return None