From 5ef0bbbda90428378a08d416481b90047f5ba870 Mon Sep 17 00:00:00 2001 From: mrichomme Date: Thu, 8 Oct 2020 13:46:50 +0200 Subject: Add reporting page creation in pythonsdk-tests Issue-ID: TEST-269 Signed-off-by: mrichomme Change-Id: I4ab0a2f7a1a1e98ae5d05166c6aa06212d24eeae Signed-off-by: mrichomme --- src/onaptests/templates/reporting/base.html.j2 | 231 +++++++++++++++++++++ .../templates/reporting/reporting.html.j2 | 43 ++++ 2 files changed, 274 insertions(+) create mode 100644 src/onaptests/templates/reporting/base.html.j2 create mode 100644 src/onaptests/templates/reporting/reporting.html.j2 (limited to 'src/onaptests/templates') diff --git a/src/onaptests/templates/reporting/base.html.j2 b/src/onaptests/templates/reporting/base.html.j2 new file mode 100644 index 0000000..cbb4e44 --- /dev/null +++ b/src/onaptests/templates/reporting/base.html.j2 @@ -0,0 +1,231 @@ +{% macro color(failing, total) %} +{% if failing == 0 %} +is-success +{% else %} +{% if (failing / total) <= 0.1 %} +is-warning +{% else %} +is-danger +{% endif %} +{% endif %} +{% endmacro %} + +{% macro percentage(failing, total) %} +{{ ((total - failing) / total) | round }} +{% endmacro %} + +{% macro statistic(resource_name, failing, total) %} +{% set success = total - failing %} +
+
+

{{ resource_name | capitalize }}

+

{{ success }}/{{ total }}

+ {{ percentage(failing, total) }} +
+
+{% endmacro %} + +{% macro pods_table(pods) %} +
+ + + + + + + + + + + + {% for pod in pods %} + + + {% if pod.init_done %} + + {% else %} + + {% endif %} + + + {% if pod.init_done %} + + {% else %} + + {% endif %} + + {% endfor %} + +
NameReadyStatusReasonRestarts
{{ pod.k8s.metadata.name }}{{ pod.running_containers }}/{{ (pod.containers | length) }}Init:{{ pod.runned_init_containers }}/{{ (pod.init_containers | length) }}{{ pod.k8s.status.phase }}{{ pod.k8s.status.reason }}{{ pod.restart_count }}{{ pod.init_restart_count }}
+
+{% endmacro %} + +{% macro key_value_description_list(title, dict) %} +
{{ title | capitalize }}:
+
+ {% if dict %} + {% for key, value in dict.items() %} + {% if loop.first %} +
+ {% endif %} +
{{ key }}:
+
{{ value }}
+ {% if loop.last %} +
+ {% endif %} + {% endfor %} + {% endif %} +
+{% endmacro %} + +{% macro description(k8s) %} +
+

Description

+
+
+ {% if k8s.spec.type %} +
Type:
+
{{ k8s.spec.type }}
+ {% if (k8s.spec.type | lower) == "clusterip" %} +
Headless:
+
{% if (k8s.spec.cluster_ip | lower) == "none" %}Yes{% else %}No{% endif %}
+ {% endif %} + {% endif %} + {{ key_value_description_list('Labels', k8s.metadata.labels) | indent(width=6) }} + {{ key_value_description_list('Annotations', k8s.metadata.annotations) | indent(width=6) }} + {% if k8s.spec.selector %} + {% if k8s.spec.selector.match_labels %} + {{ key_value_description_list('Selector', k8s.spec.selector.match_labels) | indent(width=6) }} + {% else %} + {{ key_value_description_list('Selector', k8s.spec.selector) | indent(width=6) }} + {% endif %} + {% endif %} + {% if k8s.phase %} +
Status:
+
{{ k8s.phase }}
+ {% endif %} + {% if k8s.metadata.owner_references %} +
Controlled By:
+
{{ k8s.metadata.owner_references[0].kind }}/{{ k8s.metadata.owner_references[0].name }}
+ {% endif %} +
+
+
+{% endmacro %} + +{% macro pods_container(pods, parent, has_title=True) %} +
+ {% if has_title %} +

Pods

+ {% endif %} + {% if (pods | length) > 0 %} + {{ pods_table(pods) | indent(width=2) }} + {% else %} +
{{ parent }} has no pods!
+ {% endif %} +
+{% endmacro %} + +{% macro two_level_breadcrumb(title, name) %} +
+ +
+{% endmacro %} + +{% macro pod_parent_summary(title, name, failed_pods, pods) %} +{{ summary(title, name, [{'title': 'Pod', 'failing': failed_pods, 'total': (pods | length)}]) }} +{% endmacro %} + +{% macro number_ok(number, none_value, total=None) %} +{% if number %} +{% if total and number < total %} +{{ number }} +{% else %} +{{ number }} +{% endif %} +{% else %} +{{ none_value }} +{% endif %} +{% endmacro %} + +{% macro summary(title, name, statistics) %} +
+
+
+

+ {{ title | capitalize }} {{ name }} Summary +

+ +
+
+
+{% endmacro %} + + + + + + + Tests results - {% block title %}{% endblock %} + + + {% block more_head %}{% endblock %} + + + + + {% block content %}{% endblock %} + + + + diff --git a/src/onaptests/templates/reporting/reporting.html.j2 b/src/onaptests/templates/reporting/reporting.html.j2 new file mode 100644 index 0000000..5dafe3f --- /dev/null +++ b/src/onaptests/templates/reporting/reporting.html.j2 @@ -0,0 +1,43 @@ +{% extends "base.html.j2" %} +{% block title %}Summary{% endblock %} +{% block content %} + {{ summary('Results', "", [ + { 'title': 'Pythonsdk Tests', 'failing': (failing_steps | length), 'total': (steps | length)}, + ]) + }} + +
+
+

+ {{ usecase }} +

+ Description: {{ details }} +
+ Components: {{ components }} +
+ Logs + +
+ + + + + + + + + {% for step,value in steps.items() %} + + + + + {% endfor %} + +
NameStatus
+ {{ step }} + + {{ value }} +
+
+
+{% endblock %} -- cgit 1.2.3-korg