diff options
Diffstat (limited to 'testcases')
-rw-r--r--[-rwxr-xr-x] | testcases/Controllers/ODL/odlreport2db.py | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/testcases/Controllers/ODL/odlreport2db.py b/testcases/Controllers/ODL/odlreport2db.py index 368d26611..6b3fb913d 100755..100644 --- a/testcases/Controllers/ODL/odlreport2db.py +++ b/testcases/Controllers/ODL/odlreport2db.py @@ -14,13 +14,6 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # -# 0.1: This script boots the VM1 and allocates IP address from Nova -# Later, the VM2 boots then execute cloud-init to ping VM1. -# After successful ping, both the VMs are deleted. -# 0.2: measure test duration and publish results under json format -# 0.3: adapt push 2 DB after Test API refacroting -# -# import getopt import json @@ -33,13 +26,8 @@ import functest.utils.functest_utils as functest_utils def usage(): print """Usage: - python odlreport2db.py --xml=<output.xml> --pod=<pod name> - --installer=<installer> --database=<database url> - --scenario=<scenario> + python odlreport2db.py --xml=<output.xml> --help -x, --xml xml file generated by robot test - -p, --pod POD name where the test come from - -i, --installer - -s, --scenario -h, --help this message """ sys.exit(2) @@ -47,9 +35,11 @@ def usage(): def populate_detail(test): detail = {} - detail['test_name'] = test['@name'] - detail['test_status'] = test['status'] - detail['test_doc'] = test['doc'] + detail['name'] = test['@name'] + for x in ['status', 'critical', 'starttime', 'endtime']: + detail[x] = test['status']['@' + x] + if '#text' in test['status']: + detail['text'] = test['status']['#text'] return detail @@ -70,9 +60,9 @@ def parse_suites(suites): a = suite['suite'] if type(a) == list: for b in a: - data['details'] = parse_test(b['test'], details) + data['tests'] = parse_test(b['test'], details) else: - data['details'] = parse_test(a['test'], details) + data['tests'] = parse_test(a['test'], details) # data['details'] = parse_test(suite['test'], details) # suites is not iterable @@ -80,32 +70,21 @@ def parse_suites(suites): def main(argv): - (xml_file, pod, installer, scenario) = None, None, None, None + xml_file = None try: opts, args = getopt.getopt(argv, - 'x:p:i:s:h', - ['xml=', 'pod=', - 'installer=', - 'scenario=', - 'help']) + 'x:h', + ['xml=', 'help']) except getopt.GetoptError: usage() for opt, arg in opts: - if opt in ('-h', '--help'): - usage() - elif opt in ('-x', '--xml'): + if opt in ('-x', '--xml'): xml_file = arg - elif opt in ('-p', '--pod'): - pod = arg - elif opt in ('-i', '--installer'): - installer = arg - elif opt in ('-s', '--scenario'): - scenario = arg else: usage() - if not all(x is not None for x in (xml_file, pod, installer, scenario)): + if xml_file is None: usage() with open(xml_file, "r") as myfile: @@ -117,20 +96,10 @@ def main(argv): try: data = parse_suites(all_data['suite']['suite']) data['description'] = all_data['suite']['@name'] - data['version'] = all_data['@generator'] - data['test_project'] = "functest" - data['case_name'] = "odl" - data['pod_name'] = pod - data['installer'] = installer + data['generator'] = all_data['@generator'] json.dumps(data, indent=4, separators=(',', ': ')) - # example: - # python odlreport2db.py -x ~/Pictures/Perso/odl/output3.xml - # -i fuel - # -p opnfv-jump-2 - # -s os-odl_l2-ha - # success criteria for ODL = 100% of tests OK status = "FAIL" # TODO as part of the tests are executed before in the bash @@ -139,8 +108,8 @@ def main(argv): stop_time = start_time tests_passed = 0 tests_failed = 0 - for v in data['details']: - if v['test_status']['@status'] == "PASS": + for v in data['tests']: + if v['status'] == "PASS": tests_passed += 1 else: tests_failed += 1 @@ -148,8 +117,8 @@ def main(argv): if (tests_failed < 1): status = "PASS" - functest_utils.push_results_to_db(data['test_project'], - data['case_name'], + functest_utils.push_results_to_db("functest", + "odl", None, start_time, stop_time, |