Skip to content

Commit

Permalink
kcidb/templates: add templates for creating codec report
Browse files Browse the repository at this point in the history
Templates for generating fluster tests report.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia committed Aug 28, 2024
1 parent 188b903 commit d7abf14
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kcidb/templates/fluster.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{# fluster test macros #}
{% set selected_origins = ['maestro'] %}
{% set indent = " " * 6 %}
{% set stats_indent = " " * 50 %}
34 changes: 34 additions & 0 deletions kcidb/templates/fluster_revision.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{# Revision template macros #}

{% macro summary(revision) %}
{% set git_repository_url =
revision.repo_branch_checkouts | list | first %}
{% set git_repository_branch =
revision.repo_branch_checkouts[git_repository_url] | list | first %}
{% set location = none
if git_repository_url is none
else (git_repository_branch |
reject("none") | join("")) %}
{% set commit = (none
if revision.git_commit_hash is none
else revision.git_commit_hash[:12])
if revision.git_commit_name is none
else revision.git_commit_name %}
{% set location_commit = [location, commit] | reject("none") |
join("@") | default(none, true) %}
{% set patches = ("+" + (revision.patchset_files | length | string) + "P")
if revision.patchset_files
else none %}
{% set location_commit_patches =
none
if location_commit is none
else ([location_commit, patches] | reject("none") | join("")) %}
{% set comment =
revision.repo_branch_checkouts[git_repository_url]
[git_repository_branch] |
map(attribute="comment") | reject("none") | first | default(none)
%}
{{- [location_commit_patches,
none if comment is none else ('"' + comment + '"')] |
reject("none") | join(" ") -}}
{% endmacro %}
39 changes: 39 additions & 0 deletions kcidb/templates/fluster_revision_description.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{# Revision description template #}
{% import "fluster.j2" as fluster_macros %}
{% import "fluster_test.j2" as test_macros %}
{% import "misc.j2" as misc_macros %}
{# Maximum length of a list of things (builds/tests/etc.) #}
{% set max_list_len = 5 %}

REVISION

Commit
{% if revision.git_commit_name %}
{{- " name: " + revision.git_commit_name }}
{% endif %}
{% if revision.git_commit_hash %}
{{- " hash: " + revision.git_commit_hash }}
{% endif %}
Checked out from
{% for repo, branch_checkouts
in revision.repo_branch_checkouts.items() %}
{{- " " +
(([repo] + (branch_checkouts | list)) |
reject("none") | join(" ")) }}
{% endfor %}

{# #}
{{- test_macros.container_summary(revision, max_list_len) -}}
{# #}

See complete and up-to-date report at:

https://kcidb.kernelci.org/d/revision/revision?orgId=1&var-git_commit_hash={{revision.git_commit_hash | urlencode }}&var-patchset_hash={{revision.patchset_hash | urlencode }}


Tested-by: kernelci.org bot <bot@kernelci.org>

Thanks,
KernelCI team

{# Force git commit hook to ignore trailing newline #}
3 changes: 3 additions & 0 deletions kcidb/templates/fluster_revision_summary.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{# Revision (single-line) summary template #}
{% import "fluster_revision.j2" as revision_macros %}
{{- revision_macros.summary(revision) -}}
27 changes: 27 additions & 0 deletions kcidb/templates/fluster_test.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{# Test macros #}
{% import "fluster.j2" as fluster_macros %}
{% from "fluster.j2" import indent, stats_indent %}

{% macro container_summary(container, max_list_len) %}
{{- "\nFLUSTER TESTS" }}
{% if container.tests %}
{% set fluster_tests = container.tests_root["fluster"].waived_status_tests[false] %}
{% set failed_tests = fluster_tests["FAIL"] |
selectattr('origin', 'in', fluster_macros.selected_origins) | list %}
{% set passed_tests = fluster_tests["PASS"] |
selectattr('origin', 'in', fluster_macros.selected_origins) | list %}
{% set grouped_passed_tests = passed_tests|groupby("environment_misc.platform") %}
{% set grouped_failed_tests = failed_tests|groupby("environment_misc.platform") %}
{% set sorted_tests = container.tests_root.sort_fluster_tests_by_platform(grouped_passed_tests, grouped_failed_tests) %}
{% set fluster_stats = container.tests_root.get_fluster_stats(sorted_tests) %}

{% for platform, stats in fluster_stats.items() %}
{{- "\n" + indent + platform }}:
{% for test, passed_count, failed_count in stats %}
{{- indent + "-" + test}}: {{ " " * (stats_indent|length - indent|length - test|length) }} passed: {{ passed_count }}, failed: {{ failed_count }}
{% endfor %}
{% endfor %}
{% else %}
{{- "\n No tests found" }}
{% endif %}
{% endmacro %}

0 comments on commit d7abf14

Please sign in to comment.