Skip to content

Commit 84dd650

Browse files
Add missing testcase scs-0102-os_purpose-uniqueness (#1132)
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> Signed-off-by: Marvin Frommhold <depressiveRobot@users.noreply.github.com> Co-authored-by: Marvin Frommhold <depressiveRobot@users.noreply.github.com>
1 parent 8be38e6 commit 84dd650

5 files changed

Lines changed: 68 additions & 6 deletions

File tree

Standards/scs-0102-v2-image-metadata.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ require an additional field:
7373
The usage of standardized `os_distro`, `os_version`, `architecture`, and `os_purpose` help cloud users to create
7474
automation that works across clouds without requiring image names to be standardized.
7575

76-
_Uniqueness requirement_: whenever there are two images that have `os_hidden=False`, `visibility=public`,
77-
and that coincide in all three fields `os_distro`, `os_version`, and `architecture`, then only one of them may
78-
have `os_purpose=generic`. In other words, users who search visible public images for a generic OS
76+
_Uniqueness requirement_: For every assignment of values for `os_distro`, `os_version`,
77+
and `architecture`, there MUST be at most one public (`visibility=public`),
78+
non-hidden (`os_hidden=False`) image with this assignment and `os_purpose=generic`.
79+
In other words, users who search visible public images for a generic OS
7980
of a certain distro, version, and architecture will not get more than one result.
8081

8182
The following property is recommended:

Standards/scs-0102-w1-image-metadata-implementation-testing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ The following testcase ensures that each image is as recent as claimed by its `r
4545

4646
- `scs-0102-image-recency`
4747

48+
The following testcase ensures that generic OS images are uniquely identified via the triple
49+
(architecture, os\_distro, os\_version):
50+
51+
- `scs-0102-os_purpose-uniqueness`
52+
4853
## Manual tests
4954

5055
None.

Tests/iaas/openstack_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
compute_scs_0102_prop_image_source, compute_scs_0102_prop_image_description, \
3131
compute_scs_0102_prop_replace_frequency, compute_scs_0102_prop_provided_until, \
3232
compute_scs_0102_prop_uuid_validity, compute_scs_0102_prop_hotfix_hours, \
33-
compute_scs_0102_image_recency
33+
compute_scs_0102_image_recency, compute_scs_0102_os_purpose_uniqueness
3434
from scs_0103_standard_flavors.standard_flavors import \
3535
SCS_0103_CANONICAL_NAMES, compute_flavor_lookup, compute_scs_0103_flavor
3636
from scs_0104_standard_images.standard_images import \
@@ -98,6 +98,7 @@ def make_container(cloud):
9898
c.add_function('scs_0102_prop_uuid_validity', lambda c: compute_scs_0102_prop_uuid_validity(c.images))
9999
c.add_function('scs_0102_prop_hotfix_hours', lambda c: compute_scs_0102_prop_hotfix_hours(c.images))
100100
c.add_function('scs_0102_image_recency', lambda c: compute_scs_0102_image_recency(c.images))
101+
c.add_function('scs_0102_os_purpose_uniqueness', lambda c: compute_scs_0102_os_purpose_uniqueness(c.images))
101102
# scs_0103_standard_flavors
102103
c.add_function('flavor_lookup', lambda c: compute_flavor_lookup(c.flavors))
103104
for canonical_name in SCS_0103_CANONICAL_NAMES:

Tests/iaas/scs_0102_image_metadata/image_metadata.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import calendar
2-
from collections import Counter
2+
from collections import Counter, defaultdict
33
import logging
44
import sys
55
import time
@@ -332,3 +332,28 @@ def compute_scs_0102_image_recency(images):
332332
else:
333333
logger.info(f'Image "{replacement.name}" is a valid replacement for outdated "{img.name}"')
334334
return not errors
335+
336+
337+
def compute_scs_0102_os_purpose_uniqueness(images):
338+
"""
339+
This test ensures that, for each combination of architecture, os_distro and os_version,
340+
there is a most one public image with os_purpose=generic.
341+
"""
342+
# group images by (architecture, os_distro, os_version)
343+
buckets = defaultdict(list)
344+
for image in images:
345+
if image.visibility != 'public' or image.is_hidden:
346+
continue
347+
if not image.os_distro or not image.os_version:
348+
continue
349+
if image.properties.get('os_purpose', '') != 'generic':
350+
continue
351+
key = (image.architecture or '', image.os_distro, image.os_version)
352+
buckets[key].append(image)
353+
num_faulty = 0
354+
for key, bucket in buckets.items():
355+
if len(bucket) < 2:
356+
continue
357+
num_faulty += 1
358+
_log_error(f'os_purpose=generic not unique {key!r}', bucket)
359+
return num_faulty == 0

Tests/scs-compatible-iaas.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ scripts:
8989
- id: scs-0102-image-recency
9090
description: Each image is as recent as properties (if set) suggest.
9191
url: https://docs.scs.community/standards/scs-0102-w1-image-metadata-implementation-testing#automated-tests
92+
- id: scs-0102-os_purpose-uniqueness
93+
description: Generic OS images are uniquely identified via triple (architecture, os\_distro, os\_version).
94+
url: https://docs.scs.community/standards/scs-0102-w1-image-metadata-implementation-testing#automated-tests
9295
- id: scs-0103-flavor-1v-4
9396
description: Check presence of flavor `SCS-1V-4`.
9497
url: https://docs.scs.community/standards/scs-0103-w1-standard-flavors-implementation#automated-tests
@@ -330,6 +333,33 @@ modules:
330333
recommended:
331334
- scs-0102-prop-hash_algo
332335
- scs-0102-prop-os_purpose
336+
- scs-0102-os_purpose-uniqueness
337+
- scs-0102-prop-hypervisor_type
338+
- scs-0102-prop-hw_rng_model
339+
- scs-0102-prop-hotfix_hours
340+
- id: scs-0102-v2
341+
name: Image metadata v2
342+
url: https://docs.scs.community/standards/scs-0102-v2-image-metadata
343+
targets:
344+
main:
345+
- scs-0102-prop-architecture
346+
- scs-0102-prop-min_disk
347+
- scs-0102-prop-min_ram
348+
- scs-0102-prop-os_version
349+
- scs-0102-prop-os_distro
350+
- scs-0102-prop-os_purpose
351+
- scs-0102-prop-hw_disk_bus
352+
- scs-0102-prop-image_build_date
353+
- scs-0102-prop-image_original_user
354+
- scs-0102-prop-image_source
355+
- scs-0102-prop-image_description
356+
- scs-0102-prop-replace_frequency
357+
- scs-0102-prop-provided_until
358+
- scs-0102-prop-uuid_validity
359+
- scs-0102-image-recency
360+
- scs-0102-os_purpose-uniqueness
361+
recommended:
362+
- scs-0102-prop-hash_algo
333363
- scs-0102-prop-hypervisor_type
334364
- scs-0102-prop-hw_rng_model
335365
- scs-0102-prop-hotfix_hours
@@ -487,7 +517,7 @@ versions:
487517
- opc-v2022.11
488518
- scs-0100-v3.1
489519
- scs-0101-v1
490-
- scs-0102-v1
520+
- scs-0102-v2 # instead of scs-0102-v1
491521
- scs-0103-v1
492522
- ref: scs-0104-v1-2
493523
parameters:

0 commit comments

Comments
 (0)