more flexible test naming in reports

pull/8364/head
Jan Tattermusch 8 years ago
parent 0b1a62c7d4
commit 19a4121e73
  1. 7
      tools/run_tests/report_utils.py
  2. 8
      tools/run_tests/run_tests.py
  3. 9
      tools/run_tests/run_tests_matrix.py

@ -55,11 +55,12 @@ def _filter_msg(msg, output_format):
return msg return msg
def render_junit_xml_report(resultset, xml_report): def render_junit_xml_report(resultset, xml_report, suite_package='grpc',
suite_name='tests'):
"""Generate JUnit-like XML report.""" """Generate JUnit-like XML report."""
root = ET.Element('testsuites') root = ET.Element('testsuites')
testsuite = ET.SubElement(root, 'testsuite', id='1', package='grpc', testsuite = ET.SubElement(root, 'testsuite', id='1', package=suite_package,
name='tests') name=suite_name)
for shortname, results in resultset.iteritems(): for shortname, results in resultset.iteritems():
for result in results: for result in results:
xml_test = ET.SubElement(testsuite, 'testcase', name=shortname) xml_test = ET.SubElement(testsuite, 'testcase', name=shortname)

@ -949,6 +949,8 @@ argp.add_argument('--update_submodules', default=[], nargs='*',
argp.add_argument('-a', '--antagonists', default=0, type=int) argp.add_argument('-a', '--antagonists', default=0, type=int)
argp.add_argument('-x', '--xml_report', default=None, type=str, argp.add_argument('-x', '--xml_report', default=None, type=str,
help='Generates a JUnit-compatible XML report') help='Generates a JUnit-compatible XML report')
argp.add_argument('--report_suite_name', default='tests', type=str,
help='Test suite name to use in generated JUnit XML report')
argp.add_argument('--force_default_poller', default=False, action='store_const', const=True, argp.add_argument('--force_default_poller', default=False, action='store_const', const=True,
help='Dont try to iterate over many polling strategies when they exist') help='Dont try to iterate over many polling strategies when they exist')
args = argp.parse_args() args = argp.parse_args()
@ -1273,7 +1275,8 @@ def _build_and_run(
if build_only: if build_only:
if xml_report: if xml_report:
report_utils.render_junit_xml_report(resultset, xml_report) report_utils.render_junit_xml_report(resultset, xml_report,
suite_name=args.report_suite_name)
return [] return []
# start antagonists # start antagonists
@ -1325,7 +1328,8 @@ def _build_and_run(
for antagonist in antagonists: for antagonist in antagonists:
antagonist.kill() antagonist.kill()
if xml_report and resultset: if xml_report and resultset:
report_utils.render_junit_xml_report(resultset, xml_report) report_utils.render_junit_xml_report(resultset, xml_report,
suite_name=args.report_suite_name)
number_failures, _ = jobset.run( number_failures, _ = jobset.run(
post_tests_steps, maxjobs=1, stop_on_failure=True, post_tests_steps, maxjobs=1, stop_on_failure=True,

@ -55,7 +55,8 @@ def _docker_jobspec(name, runtests_args=[]):
'--use_docker', '--use_docker',
'-t', '-t',
'-j', str(_INNER_JOBS), '-j', str(_INNER_JOBS),
'-x', 'report_%s.xml' % name] + runtests_args, '-x', 'report_%s.xml' % name,
'--report_suite_name', '%s' % name] + runtests_args,
shortname='run_tests_%s' % name, shortname='run_tests_%s' % name,
timeout_seconds=_RUNTESTS_TIMEOUT) timeout_seconds=_RUNTESTS_TIMEOUT)
return test_job return test_job
@ -70,7 +71,8 @@ def _workspace_jobspec(name, runtests_args=[], workspace_name=None):
cmdline=['tools/run_tests/run_tests_in_workspace.sh', cmdline=['tools/run_tests/run_tests_in_workspace.sh',
'-t', '-t',
'-j', str(_INNER_JOBS), '-j', str(_INNER_JOBS),
'-x', '../report_%s.xml' % name] + runtests_args, '-x', '../report_%s.xml' % name,
'--report_suite_name', '%s' % name] + runtests_args,
environ=env, environ=env,
shortname='run_tests_%s' % name, shortname='run_tests_%s' % name,
timeout_seconds=_RUNTESTS_TIMEOUT) timeout_seconds=_RUNTESTS_TIMEOUT)
@ -271,7 +273,8 @@ num_failures, resultset = jobset.run(jobs,
newline_on_success=True, newline_on_success=True,
travis=True, travis=True,
maxjobs=args.jobs) maxjobs=args.jobs)
report_utils.render_junit_xml_report(resultset, 'report.xml') report_utils.render_junit_xml_report(resultset, 'report.xml',
suite_name='aggregate_tests')
if num_failures == 0: if num_failures == 0:
jobset.message('SUCCESS', 'All run_tests.py instance finished successfully.', jobset.message('SUCCESS', 'All run_tests.py instance finished successfully.',

Loading…
Cancel
Save