summaryrefslogtreecommitdiffstats
path: root/dovetail/report.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-05-08 02:52:34 -0400
committerxudan <xudan16@huawei.com>2018-05-08 04:09:09 -0400
commit191f86a9713b857e9d3047a972fa6f8c8aca6c59 (patch)
treed2058893d25c2431867dcd8f0b3f7de26f7b9030 /dovetail/report.py
parent7adecf3d030f97ee1d19dcbda3272f88b71dd5d1 (diff)
Improve the CLI of Dovetail tool
The CLI of dovetail tool needs some improvement. 1. Add an option '--testcase' to support specify test case. 2. Add an option '--no-clean' to keep functest/yardstick/bottlenecks containers for debugging after running the test cases. 3. Improve the local report section. a. Remove some info that is not necessary b. Make the info more clearly JIRA: DOVETAIL-588 Change-Id: Ic769a6e2788b407c3df08ccd593a0ecdaa35e5ea Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/report.py')
-rw-r--r--dovetail/report.py35
1 files changed, 8 insertions, 27 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index 835fed3f..20475a3b 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -42,20 +42,19 @@ class Report(object):
checker.check(testcase, db_result)
@classmethod
- def generate_json(cls, testsuite_yaml, testarea, duration):
+ def generate_json(cls, testcase_list, duration):
report_obj = {}
report_obj['version'] = \
version.VersionInfo('dovetail').version_string()
- report_obj['testsuite'] = testsuite_yaml['name']
- # TO DO: once dashboard url settled, adjust accordingly
- report_obj['dashboard'] = None
report_obj['build_tag'] = dt_cfg.dovetail_config['build_tag']
report_obj['upload_date'] =\
datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
report_obj['duration'] = duration
report_obj['testcases_list'] = []
- testcase_list = Testcase.get_testcase_list(testsuite_yaml, testarea)
+ if not testcase_list:
+ return report_obj
+
for testcase_name in testcase_list:
testcase = Testcase.get(testcase_name)
testcase_inreport = {}
@@ -81,19 +80,14 @@ class Report(object):
return report_obj
@classmethod
- def generate(cls, testsuite_yaml, testarea, duration):
- report_data = cls.generate_json(testsuite_yaml, testarea, duration)
+ def generate(cls, testcase_list, duration):
+ report_data = cls.generate_json(testcase_list, duration)
report_txt = ''
report_txt += '\n\nDovetail Report\n'
report_txt += 'Version: %s\n' % report_data['version']
- report_txt += 'TestSuite: %s\n' % report_data['testsuite']
- report_txt += 'Result Dashboard: %s\n' % report_data['dashboard']
report_txt += 'Build Tag: %s\n' % report_data['build_tag']
report_txt += 'Upload Date: %s\n' % report_data['upload_date']
- if report_data['duration'] == 0:
- report_txt += 'Duration: %s\n\n' % 'N/A'
- else:
- report_txt += 'Duration: %.2f s\n\n' % report_data['duration']
+ report_txt += 'Duration: %.2f s\n\n' % report_data['duration']
total_num = 0
pass_num = 0
@@ -135,21 +129,13 @@ class Report(object):
pass_rate = pass_num / total_num
report_txt += 'Pass Rate: %.2f%% (%s/%s)\n' %\
(pass_rate * 100, pass_num, total_num)
- report_txt += 'Assessed test areas:\n'
else:
report_txt += \
- 'no testcase or all testcases are skipped in this testsuite'
+ 'no testcase or all testcases are skipped in this testsuite\n'
for key in sub_report:
if testcase_num[key] != 0:
pass_rate = testcase_passnum[key] / testcase_num[key]
- report_txt += '-%-25s pass %.2f%%\n' %\
- (key + ' results:', pass_rate * 100)
- elif key in testarea_scope:
- report_txt += '-%-25s all skipped\n' % key
- for key in sub_report:
- if testcase_num[key] != 0:
- pass_rate = testcase_passnum[key] / testcase_num[key]
report_txt += '%-25s pass rate %.2f%%\n' %\
(key + ':', pass_rate * 100)
report_txt += sub_report[key]
@@ -158,7 +144,6 @@ class Report(object):
report_txt += sub_report[key]
cls.logger.info(report_txt)
- # cls.save(report_txt)
return report_txt
@classmethod
@@ -292,7 +277,6 @@ class FunctestCrawler(Crawler):
'timestop': timestop, 'duration': duration,
'details': details}
- self.logger.debug('Results: {}'.format(str(json_results)))
return json_results
@@ -334,7 +318,6 @@ class YardstickCrawler(Crawler):
except KeyError as e:
self.logger.exception('Pass flag not found {}'.format(e))
json_results = {'criteria': criteria}
- self.logger.debug('Results: {}'.format(str(json_results)))
return json_results
def add_result_to_file(self, result, tc_name):
@@ -379,7 +362,6 @@ class BottlenecksCrawler(Crawler):
except KeyError as e:
self.logger.exception('Pass flag not found {}'.format(e))
json_results = {'criteria': criteria}
- self.logger.debug('Results: {}'.format(str(json_results)))
return json_results
@@ -436,7 +418,6 @@ class VnftestCrawler(Crawler):
except KeyError as e:
self.logger.exception('Pass flag not found {}'.format(e))
json_results = {'criteria': criteria}
- self.logger.debug('Results: {}'.format(str(json_results)))
return json_results