diff options
author | xudan <xudan16@huawei.com> | 2017-03-22 07:51:37 +0000 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2017-03-25 08:59:53 +0000 |
commit | 223806ad2a5d60c9909f32f35b8cea16bf703a69 (patch) | |
tree | dfcd9c27f2876c3b185a5afb2266ca78e0e155d8 /dovetail/run.py | |
parent | 02d44a030687100d0ebf68d1645536536d42cbb9 (diff) |
dovetail tool: Add an option cmd for pushing results into DB
JIRA: DOVETAIL-373
1. add an option --report/-r to choose the report type.
2. "-r file" will store results with files.
3. "-r http://192.168.135.2:8000/api/v1" will push results into DB.
The DB url can replaced by user's local DB or official DB.
4. Default report type is defined as "report_dest" in dovetail_config.yml.
5. Yardstick can't push results of one testcase into DB now, so both "-r file"
and "-r http://..." will be regarded as "file".
Change-Id: Ieaa017ab59c5b15235bf306ef57cdc56beb22af8
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/run.py')
-rwxr-xr-x | dovetail/run.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/dovetail/run.py b/dovetail/run.py index 05f48501..17d7edf4 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -64,8 +64,12 @@ def run_test(testsuite, testarea, logger): end_time = time.time() duration = end_time - start_time - result = Report.get_result(testcase) - Report.check_result(testcase, result) + if dt_cfg.dovetail_config['report_dest'].startswith("http"): + logger.info("Results has been pushed to database.") + if dt_cfg.dovetail_config['report_dest'] == "file": + logger.info("Results has been stored with files.") + result = Report.get_result(testcase) + Report.check_result(testcase, result) return duration @@ -82,6 +86,14 @@ def validate_input(input_dict, check_dict, logger): logger.error("yard_tag can't be %s, valid in %s", yard_tag, valid_tag) raise SystemExit(1) + # for 'report' option + report = input_dict['report'] + if report: + if not (report.startswith("http") or report == "file"): + logger.error("report can't be %s", input_dict['report']) + logger.info("valid report types are 'file' and 'http'") + raise SystemExit(1) + def filter_config(input_dict, logger): cli_dict = dt_cfg.dovetail_config['cli'] @@ -156,6 +168,9 @@ def main(*args, **kwargs): if configs is not None: dt_cfg.update_config(configs) + if kwargs['report']: + dt_cfg.dovetail_config['report_dest'] = kwargs['report'] + testarea = kwargs['testarea'] testsuite_validation = False testarea_validation = False @@ -168,7 +183,8 @@ def main(*args, **kwargs): testsuite_yaml = load_testsuite(kwargs['testsuite']) load_testcase() duration = run_test(testsuite_yaml, testarea, logger) - Report.generate(testsuite_yaml, testarea, duration) + if dt_cfg.dovetail_config['report_dest'] == "file": + Report.generate(testsuite_yaml, testarea, duration) else: logger.error('invalid input commands, testsuite %s testarea %s', kwargs['testsuite'], testarea) |