From d7abf14a2010afc2e297ea8cb81f8ccf6f568dad Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Wed, 28 Aug 2024 13:02:40 +0530 Subject: [PATCH] kcidb/templates: add templates for creating codec report Templates for generating fluster tests report. Signed-off-by: Jeny Sadadia --- kcidb/templates/fluster.j2 | 4 ++ kcidb/templates/fluster_revision.j2 | 34 ++++++++++++++++ .../fluster_revision_description.txt.j2 | 39 +++++++++++++++++++ .../templates/fluster_revision_summary.txt.j2 | 3 ++ kcidb/templates/fluster_test.j2 | 27 +++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 kcidb/templates/fluster.j2 create mode 100644 kcidb/templates/fluster_revision.j2 create mode 100644 kcidb/templates/fluster_revision_description.txt.j2 create mode 100644 kcidb/templates/fluster_revision_summary.txt.j2 create mode 100644 kcidb/templates/fluster_test.j2 diff --git a/kcidb/templates/fluster.j2 b/kcidb/templates/fluster.j2 new file mode 100644 index 00000000..e7226a20 --- /dev/null +++ b/kcidb/templates/fluster.j2 @@ -0,0 +1,4 @@ +{# fluster test macros #} +{% set selected_origins = ['maestro'] %} +{% set indent = " " * 6 %} +{% set stats_indent = " " * 50 %} diff --git a/kcidb/templates/fluster_revision.j2 b/kcidb/templates/fluster_revision.j2 new file mode 100644 index 00000000..75e7861d --- /dev/null +++ b/kcidb/templates/fluster_revision.j2 @@ -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 %} diff --git a/kcidb/templates/fluster_revision_description.txt.j2 b/kcidb/templates/fluster_revision_description.txt.j2 new file mode 100644 index 00000000..66381bc6 --- /dev/null +++ b/kcidb/templates/fluster_revision_description.txt.j2 @@ -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 + +Thanks, +KernelCI team + +{# Force git commit hook to ignore trailing newline #} diff --git a/kcidb/templates/fluster_revision_summary.txt.j2 b/kcidb/templates/fluster_revision_summary.txt.j2 new file mode 100644 index 00000000..4578fb8d --- /dev/null +++ b/kcidb/templates/fluster_revision_summary.txt.j2 @@ -0,0 +1,3 @@ +{# Revision (single-line) summary template #} +{% import "fluster_revision.j2" as revision_macros %} +{{- revision_macros.summary(revision) -}} diff --git a/kcidb/templates/fluster_test.j2 b/kcidb/templates/fluster_test.j2 new file mode 100644 index 00000000..7eb2b03b --- /dev/null +++ b/kcidb/templates/fluster_test.j2 @@ -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 %}