Commit aee4f9dd authored by Luis Araujo's avatar Luis Araujo

Show only valid test cases for an image deployment type

This commit improves the main test case table page to show only the valid
test cases for an image deployment type in the report page.
Signed-off-by: Luis Araujo's avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent 900ff3c0
Pipeline #4183 passed with stage
in 1 minute and 34 seconds
......@@ -33,6 +33,24 @@ priority_color_table = {
'critical' : 'danger'
}
# List of platforms (image types) reported.
REPORT_PLATFORMS = [
'minimal-armhf-internal',
'minimal-armhf-public',
'minimal-arm64-public',
'minimal-amd64-public',
'target-armhf-internal',
'target-amd64-public',
'basesdk-amd64-public',
'sdk-amd64-public',
'tiny-lxc-armhf-public',
'tiny-lxc-arm64-public',
'tiny-lxc-amd64-public',
'nfsroot-armhf-public',
'nfsroot-arm64-public',
'nfsroot-amd64-public'
]
def generate_index(username=None):
jobs_versions = set()
# Limit the result to 500 jobs in descending order.
......@@ -86,6 +104,42 @@ def generate_submit_report(username, form, image_release,
def generate_submitted():
return render_template('submitted.html')
def _create_report_table(test_cases, testcases_table, image_deployment):
"""
This method generates the main report table passed to the html template.
It does so by processing the saved `test_cases` results against the
`testcases_table` data.
It generates a structure of the form:
[ (suite, priority, notes, { image_type: (result, url) ... }), ... ]
"""
report_table = []
for suite, exec_type, priority, deployments, platforms in testcases_table:
suite_images = {}
# Don't add any test case row if deployment is not valid.
if image_deployment in deployments:
for platform in REPORT_PLATFORMS:
if platform in platforms:
if suite in test_cases and platform in test_cases[suite]:
suite_images[platform] = test_cases[suite][platform]
else:
suite_images[platform] = ('not_tested', '')
else:
# Platform is not supported , so mark as N/A.
suite_images[platform] = ('na', '')
# Add notes (if any) for all the platforms of a suite (test case)
notes = ''
if suite in test_cases:
notes = test_cases[suite].get('__notes', '')
report_table.append((suite, priority, notes, suite_images))
return report_table
def generate_report(image_release, image_version,
image_deployment, testcases_table):
logging.info('Generating report for release: %s , build: %s',
......@@ -137,9 +191,12 @@ def generate_report(image_release, image_version,
if job.visibility == 'public':
image_urls[image_type_id] = job.image_url
# Create report table
report_table = _create_report_table(test_cases, testcases_table,
image_deployment)
return render_template('report.html',
test_cases=test_cases,
tc_table=testcases_table,
report_table=report_table,
test_cases_url=config['test-cases-url'],
image_urls=image_urls,
image_release=image_release,
......
......@@ -11,30 +11,22 @@
<h2>Test Report</h2>
<hr />
{% macro set_cell(image_type, supported_deployments, supported_platforms, suite) -%}
{% if image_deployment in supported_deployments and image_type in supported_platforms %}
{% if suite in test_cases and image_type in test_cases[suite] %}
{{ set_cell_result(test_cases[suite][image_type]) }}
{% else %}
<td>NOT TESTED</td>
{% endif %}
{% else %}
<td class="table-secondary">N/A</td>
{% endif %}
{%- endmacro %}
{% macro set_cell_result(results) -%}
{% set result, url = results %}
{% macro set_cell(image_type, platforms) -%}
{% set result, url = platforms[image_type] -%}
{% if result == 'pass' %}
<td class="table-success"><a href="{{ url }}">PASS</a></td>
{% elif result == 'fail' %}
<td class="table-danger"><a href="{{ url }}">FAIL</a></td>
{% elif result == 'incomplete' %}
<td class="table-danger"><a href="{{ url }}">INCOMPLETE</a></td>
{% elif result == 'not_tested' %}
<td class="table-light">NOT TESTED</td>
{% elif result == 'na' %}
<td class="table-secondary">N/A</td>
{% else %}
<td class="table-info">UNKNOWN</td>
{% endif %}
{%- endmacro %}
{% endmacro %}
{% macro set_image_url(name, image_url) -%}
<em><a href="{{ image_url }}">{{ name }}</a></em>
......@@ -43,19 +35,25 @@
<div class="container mb-md-3">
<p>
Build: <b>{{ image_version }}</b> / Release: <b>{{ image_release }}</b> / Images:
{{ set_image_url('Minimal ARM', image_urls['minimal-armhf-public']) }} ,
{{ set_image_url('Minimal ARM64', image_urls['minimal-arm64-public']) }} ,
{{ set_image_url('Minimal AMD64', image_urls['minimal-amd64-public']) }} ,
{{ set_image_url('Target AMD64', image_urls['target-amd64-public']) }} ,
{{ set_image_url('BaseSDK AMD64', image_urls['basesdk-amd64-public']) }} ,
{{ set_image_url('SDK AMD64', image_urls['sdk-amd64-public']) }} ,
{% if image_deployment == 'nfs' %}
{{ set_image_url('Nfsroot ARM', image_urls['nfs-armhf-public']) }} ,
{{ set_image_url('Nfsroot ARM64', image_urls['nfs-arm64-public']) }} ,
{{ set_image_url('Nfsroot AMD64', image_urls['nfs-amd64-public']) }}
{% else %}
{{ set_image_url('Minimal ARM', image_urls['minimal-armhf-public']) }},
{{ set_image_url('Minimal ARM64', image_urls['minimal-arm64-public']) }},
{{ set_image_url('Minimal AMD64', image_urls['minimal-amd64-public']) }},
{{ set_image_url('Target AMD64', image_urls['target-amd64-public']) }}
{% if image_deployment != 'ostree' %}
,
{{ set_image_url('BaseSDK AMD64', image_urls['basesdk-amd64-public']) }},
{{ set_image_url('SDK AMD64', image_urls['sdk-amd64-public']) }}
{% endif %}
{% endif %}
</p>
<div class="row">
<div class="col-md-9"><h5><span class="badge table-secondary">Low</span> <span class="badge table-info">Medium</span> <span class="badge table-warning">High</span> <span class="badge table-danger">Critical</span></h5></div>
<div class="col"><em class="text-muted">{{ tc_table|count }} test cases</em></div>
<div class="col"><em class="text-muted">{{ report_table|count }} test cases</em></div>
</div>
</div>
......@@ -63,42 +61,52 @@
<thead class="thead-light">
<tr>
<th scope="col">ID</th>
{% if image_deployment == 'nfs' %}
<th scope="col">Nfsroot ARM</th>
<th scope="col">Nfsroot ARM64</th>
<th scope="col">Nfsroot AMD64</th>
{% else %}
<th scope="col">Minimal ARM (internal)</th>
<th scope="col">Minimal ARM</th>
<th scope="col">Minimal ARM64</th>
<th scope="col">Minimal AMD64</th>
<th scope="col">Target ARM (internal)</th>
<th scope="col">Target AMD64</th>
{% if image_deployment != 'ostree' %}
<th scope="col">Base SDK AMD64</th>
<th scope="col">SDK AMD64</th>
<th scope="col">Tiny ARM</th>
<th scope="col">Tiny ARM64</th>
<th scope="col">Tiny AMD64</th>
<th scope="col">Nfsroot ARM</th>
<th scope="col">Nfsroot ARM64</th>
<th scope="col">Nfsroot AMD64</th>
{% endif %}
{% endif %}
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
{% for suite, exec_type, priority, deployments, platforms in tc_table %}
{% for test_case, priority, notes, image_types in report_table %}
<tr>
<th scope="row" class="table-{{ priority_color_table[priority] }}" style="min-width: 300px;"><a href="{{test_cases_url}}/{{ suite|e }}.html">{{ suite|e }}</a></th>
{{ set_cell('minimal-armhf-internal', deployments, platforms, suite) }}
{{ set_cell('minimal-armhf-public', deployments, platforms, suite) }}
{{ set_cell('minimal-arm64-public', deployments, platforms, suite) }}
{{ set_cell('minimal-amd64-public', deployments, platforms, suite) }}
{{ set_cell('target-armhf-internal', deployments, platforms, suite) }}
{{ set_cell('target-amd64-public', deployments, platforms, suite) }}
{{ set_cell('basesdk-amd64-public', deployments, platforms, suite) }}
{{ set_cell('sdk-amd64-public', deployments, platforms, suite) }}
{{ set_cell('tiny-lxc-armhf-public', deployments, platforms, suite) }}
{{ set_cell('tiny-lxc-arm64-public', deployments, platforms, suite) }}
{{ set_cell('tiny-lxc-amd64-public', deployments, platforms, suite) }}
{{ set_cell('nfsroot-armhf-public', deployments, platforms, suite) }}
{{ set_cell('nfsroot-arm64-public', deployments, platforms, suite) }}
{{ set_cell('nfsroot-amd64-public', deployments, platforms, suite) }}
<td style="min-width: 300px;">{% if test_cases[suite] %}{{ test_cases[suite]["__notes"] }}{% endif %}</td>
<th scope="row" class="table-{{ priority_color_table[priority] }}" style="min-width: 300px;"><a href="{{test_cases_url}}/{{ test_case|e }}.html">{{ test_case|e }}</a></th>
{% if image_deployment == 'nfs' %}
{{ set_cell('nfsroot-armhf-public', image_types) }}
{{ set_cell('nfsroot-arm64-public', image_types) }}
{{ set_cell('nfsroot-amd64-public', image_types) }}
{% else %}
{{ set_cell('minimal-armhf-internal', image_types) }}
{{ set_cell('minimal-armhf-public', image_types) }}
{{ set_cell('minimal-arm64-public', image_types) }}
{{ set_cell('minimal-amd64-public', image_types) }}
{{ set_cell('target-armhf-internal', image_types) }}
{{ set_cell('target-amd64-public', image_types) }}
{% if image_deployment != 'ostree' %}
{{ set_cell('basesdk-amd64-public', image_types) }}
{{ set_cell('sdk-amd64-public', image_types) }}
{{ set_cell('tiny-lxc-armhf-public', image_types) }}
{{ set_cell('tiny-lxc-arm64-public', image_types) }}
{{ set_cell('tiny-lxc-amd64-public', image_types) }}
{% endif %}
{% endif %}
<td style="min-width: 300px;">{{ notes }}</td>
</tr>
{% endfor %}
</tbody>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment