Skip to content

Commit

Permalink
src/test_report: rename 'group' to 'job'
Browse files Browse the repository at this point in the history
Rename variables and methods to use 'job' instead
of 'group' as the test report denotes statistics and
information of different jobs run of a specific
`checkout` node rather than group of nodes.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia authored and gctucker committed Sep 15, 2023
1 parent ad23531 commit a96c348
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
22 changes: 11 additions & 11 deletions config/reports/test-report.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ Describe: {{ root.revision.describe }}
URL: {{ root.revision.url }}
SHA1: {{ root.revision.commit }}

{%- if groups.items() %}
{%- if jobs.items() %}
{{ '%-17s %s %-8s %s %-8s %s %-8s'|format(
"Name", "|", "Result", "|", "Total", "|", "Failures") }}
{{ '%s%s%s%s%s%s%s'|format(
"-"*18, "+", "-"*10, "+", "-"*10, "+", "-"*9) }}
{%- for group_name, group in groups.items() %}
{%- for job_name, job in jobs.items() %}
{{ '%-17s %s %-8s %s %8d %s %8d'|format(
group_name, "|",
group.root.result, "|",
group.nodes, "|",
group.failures|count) }}
job_name, "|",
job.root.result, "|",
job.nodes, "|",
job.failures|count) }}
{%- endfor %}


Failing tests
=============

{%- for group_name, group in groups.items() %}
{%- if group.failures|count %}
{%- for job_name, job in jobs.items() %}
{%- if job.failures|count %}

{{ group_name }}
{{ '-'*group_name|length }}
{{ job_name }}
{{ '-'*job_name|length }}

{% for failure in group.failures %}* {{ failure.path }}
{% for failure in job.failures %}* {{ failure.path }}
{% endfor %}
{%- endif %}
{%- endfor %}
Expand Down
48 changes: 24 additions & 24 deletions src/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,37 @@ def __init__(self, configs, args):
def _dump_report(self, content):
print(content, flush=True)

def _get_group_stats(self, groups_data):
def _get_job_stats(self, jobs_data):
failures = 0
for _, group in groups_data.items():
if group['root']['result'] == 'fail':
for _, job in jobs_data.items():
if job['root']['result'] == 'fail':
failures += 1

return {
'total': len(groups_data),
'total': len(jobs_data),
'failures': failures,
}

def _get_group_data(self, checkout_node, group):
def _get_job_data(self, checkout_node, job):
revision = checkout_node['revision']

root_node = self._api.get_nodes({
'revision.commit': revision['commit'],
'revision.tree': revision['tree'],
'revision.branch': revision['branch'],
'name': group,
'name': job,
})[0]
group_nodes = self._api.count_nodes({
job_nodes = self._api.count_nodes({
'revision.commit': revision['commit'],
'revision.tree': revision['tree'],
'revision.branch': revision['branch'],
'group': group,
'group': job,
})
failures = self._api.get_nodes({
'revision.commit': revision['commit'],
'revision.tree': revision['tree'],
'revision.branch': revision['branch'],
'group': group,
'group': job,
'result': 'fail',
})
failures = [
Expand All @@ -79,32 +79,32 @@ def _get_group_data(self, checkout_node, group):
if node['id'] == root_node['id']:
parent_path_len = len(checkout_node['path'])
node['path'] = '.'.join(node['path'][parent_path_len:])
return {'root': root_node, 'nodes': group_nodes, 'failures': failures}
return {'root': root_node, 'nodes': job_nodes, 'failures': failures}

def _get_groups(self, root_node):
groups = []
def _get_jobs(self, root_node):
jobs = []
revision = root_node['revision']
nodes = self._api.get_nodes({
'revision.commit': revision['commit'],
'revision.tree': revision['tree'],
'revision.branch': revision['branch']
})
for node in nodes:
if node['group'] and node['group'] not in groups:
groups.append(node['group'])
return groups
if node['group'] and node['group'] not in jobs:
jobs.append(node['group'])
return jobs

def _get_results_data(self, root_node):
groups = self._get_groups(root_node)
jobs = self._get_jobs(root_node)

groups_data = {
group: self._get_group_data(root_node, group)
for group in groups
jobs_data = {
job: self._get_job_data(root_node, job)
for job in jobs
}
group_stats = self._get_group_stats(groups_data)
jobs_stats = self._get_job_stats(jobs_data)
return {
'stats': group_stats,
'groups': groups_data,
'stats': jobs_stats,
'jobs': jobs_data,
}

def _get_report(self, root_node):
Expand All @@ -115,12 +115,12 @@ def _get_report(self, root_node):
revision = root_node['revision']
results = self._get_results_data(root_node)
stats = results['stats']
groups = results['groups']
jobs = results['jobs']
subject = f"\
[STAGING] {revision['tree']}/{revision['branch']} {revision['describe']}: \
{stats['total']} runs {stats['failures']} failures"
content = template.render(
subject=subject, root=root_node, groups=groups
subject=subject, root=root_node, jobs=jobs
)
return content, subject

Expand Down

0 comments on commit a96c348

Please sign in to comment.