Skip to content

Commit a33eeeb

Browse files
committed
Restructure CM details page
resolves #1055 Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent 7d3f499 commit a33eeeb

3 files changed

Lines changed: 44 additions & 25 deletions

File tree

Tests/scs_cert_lib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def _resolve_spec(spec: dict):
6464
id_ = testcase['id']
6565
if id_ in testcase_lookup:
6666
raise RuntimeError(f"duplicate testcase {id_}")
67+
testcase['attn'] = 0 # count: how many versions list this in target 'main'?
6768
testcase_lookup[id_] = testcase
6869
tc_script_lookup[id_] = script
6970
module_lookup = {module['id']: module for module in spec['modules']}
@@ -92,7 +93,14 @@ def _resolve_spec(spec: dict):
9293
for inc in version['include']:
9394
for target, tc_ids in inc['module'].get('targets', {}).items():
9495
targets[target].update(tc_ids)
96+
tc_target = {}
97+
for target, tc_ids in targets.items():
98+
for tc_id in tc_ids:
99+
tc_target[tc_id] = target
100+
for tc_id in targets.get('main', ()):
101+
testcase_lookup[tc_id]['attn'] += 1
95102
version['targets'] = {target: sorted(tc_ids) for target, tc_ids in targets.items()}
103+
version['tc_target'] = tc_target
96104
# step 4b. resolve references to versions in timeline
97105
# on second thought, let's not go there: it's a canonical extension map, and it should remain that way.
98106
# however, we still have to look for name errors

compliance-monitor/monitor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949

5050

5151
try:
52-
from scs_cert_lib import load_spec, annotate_validity, add_period, evaluate
52+
from scs_cert_lib import load_spec, annotate_validity, add_period, eval_buckets, evaluate
5353
except ImportError:
5454
# the following course of action is not unproblematic because the Tests directory will be
5555
# mounted to the Docker instance, hence it's hard to tell what version we are gonna get;
5656
# however, unlike the reloading of the config, the import only happens once, and at that point
5757
# in time, both monitor.py and scs_cert_lib.py should come from the same git checkout
5858
import sys; sys.path.insert(0, os.path.abspath('../Tests')) # noqa: E702
59-
from scs_cert_lib import load_spec, annotate_validity, add_period, evaluate
59+
from scs_cert_lib import load_spec, annotate_validity, add_period, eval_buckets, evaluate
6060

6161

6262
class Settings:
@@ -251,6 +251,7 @@ def _evaluate_version(version, scope_results):
251251
return {
252252
'result': target_results['main']['result'],
253253
'targets': target_results,
254+
'tc_target': version['tc_target'],
254255
'validity': version['validity'],
255256
}
256257

@@ -282,6 +283,11 @@ def _evaluate_scope(spec, scope_results, include_drafts=False):
282283
'name': spec['name'],
283284
'testcases': testcases,
284285
'results': scope_results,
286+
'buckets': {
287+
# sort testcase that occur any main target on top of those that don't
288+
res: sorted(tc_ids, key=lambda tc_id: (not testcases[tc_id]['attn'], tc_id))
289+
for res, tc_ids in eval_buckets(scope_results, testcases).items()
290+
},
285291
'versions': version_results,
286292
'relevant': relevant,
287293
'passed': passed,
@@ -724,7 +730,7 @@ async def get_scope(
724730
view_type: ViewType,
725731
scopeuuid: str,
726732
):
727-
spec = get_scopes()[scopeuuid].spec
733+
spec = get_scopes()[scopeuuid]
728734
versions = spec['versions']
729735
# sort by name, and all drafts after all non-drafts
730736
column_data = [
Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Note: testcase occurrences inside scope versions are marked
2+
bold "**X**" for required testcases (target _main_) and
3+
plain "x" for recommended testcases (with the specific target in the tooltip).
4+
15
{% if results | length > 1 %}
26
Jump to
37

@@ -20,30 +24,31 @@ Jump to
2024

2125
No recent test results available.
2226

23-
{% endif -%}
24-
{% for version in scope_result.relevant -%}
25-
{%- set version_result = scope_result.versions[version] -%}
26-
### {{ version }} ({{ version_result.validity }}): {{ version_result.result | verdict }}
27-
{% for target, target_result in version_result.targets.items() -%}
28-
#### Target {{ target }}: {{ target_result.result | verdict }}
29-
30-
| testcase id | result | description |
31-
|---|---|---|
32-
{% for testcase_id in target_result.testcases -%}
33-
{% set testcase = scope_result.testcases[testcase_id] -%}
27+
{% else %}
28+
29+
{% for cat, res in (('FAILED', -1), ('Missing', 0), ('Passed', 1)) -%}
30+
{% set bucket = scope_result.buckets[res] -%}
31+
{% if bucket -%}
32+
### {{cat}} testcases
33+
34+
| testcase id |{% for version in scope_result.relevant %} {{ version }} |{% endfor %} description |
35+
|---|{% for version in scope_result.relevant %}---|{% endfor %}---|
36+
{% for testcase_id in bucket -%}
3437
{% set res = scope_result.results[testcase_id] if testcase_id in scope_result.results else dict(result=0) -%}
35-
| {% if res.result != 1 %}⚠️ {% endif %}{{ testcase.id }} |
36-
{#- #} {% if res.report -%}
37-
[{{ res.result | verdict_check }}]({{ report_url(res.report, version, testcase_id) }})
38+
{#- #} {% if res.report -%}
39+
[{{ testcase_id }}]({{ report_url(res.report, version, testcase_id) }})
3840
{%- else -%}
39-
{{ res.result | verdict_check }}
41+
{{ testcase_id }}
4042
{%- endif -%}
4143
{% if res.report %} { title="{{ res.report }} ({{ res.checked_at }})" }{% endif %} {# -#}
42-
| {{ testcase.description | trim }} |
43-
{% endfor %}
44-
{% endfor -%}
45-
{% endfor -%}
46-
{% endfor -%}
47-
{% endfor -%}
44+
{% for version in scope_result.relevant %}| {%
45+
set tgt = scope_result.versions[version].tc_target[testcase_id]
46+
%}{% if tgt == 'main' %}**X** { title="main" }{% elif tgt %}x { title="{{ tgt }}" }{% endif %} {% endfor -%}
47+
| {{ scope_result.testcases[testcase_id].description | trim }} |
48+
{% endfor %}{# testcase #}
49+
{% endif %}{# bucket nonempty -#}
50+
{% endfor %}{# categories #}
4851

49-
{#{results}#}
52+
{% endif %}{# results available -#}
53+
{% endfor %}{# scope -#}
54+
{% endfor %}{# subject -#}

0 commit comments

Comments
 (0)