Skip to content

Commit 633852c

Browse files
authored
Fix: avoid infinitely lived test results because they obstruct database query optimization (#948)
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent f851a3c commit 633852c

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

Standards/scs-0003-v1-sovereign-cloud-standards-yaml.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,15 @@ TBD
253253

254254
### Test-case descriptor
255255

256-
| Key | Type | Description | Example |
257-
| ----------------- | --------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------- |
258-
| `id` | String | Identifier for this test case (immutable and unique within this module) | `image-md-check` |
259-
| `lifetime` | String | One of: `day`, `week` (_default_), `month`, `quarter`, `infinite`; the test result is valid until the end of the next period | `day` |
260-
| `tags` | List of strings | A tag is a keyword that will be used to select this test case using a selector expression | `[mandatory]` |
261-
| `description` | String | Short description of the test case | |
256+
| Key | Type | Description | Example |
257+
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------- | ----------------- |
258+
| `id` | String | Identifier for this test case (immutable and unique within this module) | `image-md-check` |
259+
| `lifetime` | String | One of: `day`, `week` (_default_), `month`, `quarter`, `year` | `day` |
260+
| `tags` | List of strings | A tag is a keyword that will be used to select this test case using a selector expression | `[mandatory]` |
261+
| `description` | String | Short description of the test case | |
262+
263+
A test result is valid until the end of the next period, except when lifetime is `year`: then the result is
264+
valid until the end of the following month plus one year.
262265

263266
A tag MUST NOT contain any of these characters: space, comma, exclamation mark, forward slash.
264267

Tests/scs-compatible-kaas.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ modules:
2020
testcases:
2121
- id: cncf-k8s-conformance
2222
tags: [mandatory]
23-
lifetime: infinite
23+
lifetime: year
2424
description: >
2525
Must fulfill all requirements of [CNCF Kubernetes conformance](https://github.com/cncf/k8s-conformance/tree/master)
2626
- id: scs-0210-v2

Tests/scs_cert_lib.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ def add_period(dt: datetime, period: str) -> datetime:
141141
if dt.month >= 4:
142142
return datetime(dt.year, 10, 1)
143143
return datetime(dt.year, 7, 1)
144-
if period == 'infinite':
145-
# admittedly HACKY, but this case is better handled by caller
146-
return datetime(dt.year + 1000, 1, 1)
144+
if period == 'year':
145+
if dt.month == 11:
146+
return datetime(dt.year + 2, 1, 1)
147+
if dt.month == 12:
148+
return datetime(dt.year + 2, 2, 1)
149+
return datetime(dt.year + 1, dt.month + 2, 1)
150+
raise RuntimeError(f'unknown period: {period}')
147151

148152

149153
def parse_selector(selector_str: str) -> list[list[str]]:

compliance-monitor/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def convert_result_rows_to_dict2(
514514
continue
515515
# drop value if too old
516516
lifetime = testcase.get('lifetime') # leave None if not present; to be handled by add_period
517-
if lifetime != 'infinite' and now >= add_period(checked_at, lifetime):
517+
if now >= add_period(checked_at, lifetime):
518518
continue
519519
tc_result = dict(result=result, checked_at=checked_at)
520520
if include_report:

0 commit comments

Comments
 (0)