1717SECURITY_GROUP_NAME = "_scs-0101-group"
1818KEYPAIR_NAME = "_scs-0101-keypair"
1919
20- IMAGE_ATTRIBUTES = {
21- # https://docs.openstack.org/glance/2023.1/admin/useful-image-properties.html#image-property-keys-and-values
22- # type: str
23- "hw_rng_model" : "virtio" ,
24- }
25- FLAVOR_ATTRIBUTES = {
26- # https://docs.openstack.org/nova/2023.1/configuration/extra-specs.html#hw-rng
27- # type: bool
28- "hw_rng:allowed" : "True" , # testing showed that it is indeed a string?
29- }
30- FLAVOR_OPTIONAL = ("hw_rng:rate_bytes" , "hw_rng:rate_period" )
31-
3220
3321TIMEOUT = 5 * 60 # timeout in seconds after which we no longer wait for the VM to complete the run
3422MARKER = '_scs-test-'
7058}
7159
7260
73- def compute_scs_0101_image_property (images , attributes = IMAGE_ATTRIBUTES ):
74- """This test ensures that each image has the relevant properties."""
75- candidates = [
76- (image .name , [f"{ key } ={ value } " for key , value in attributes .items () if image .get (key ) != value ])
77- for image in images
78- ]
79- # drop those candidates that are fine
80- offenders = [candidate for candidate in candidates if candidate [1 ]]
81- for name , wrong in offenders :
82- logger .error (f"Image '{ name } ' missing attributes: { ', ' .join (wrong )} " )
83- return not offenders
84-
85-
86- def compute_scs_0101_flavor_property (flavors , attributes = FLAVOR_ATTRIBUTES , optional = FLAVOR_OPTIONAL ):
87- """This test ensures that each flavor has the relevant extra_spec."""
88- offenses = 0
89- for flavor in flavors :
90- extra_specs = flavor ['extra_specs' ]
91- wrong = [f"{ key } ={ value } " for key , value in attributes .items () if extra_specs .get (key ) != value ]
92- miss_opt = [key for key in optional if extra_specs .get (key ) is None ]
93- if wrong :
94- offenses += 1
95- message = f"Flavor '{ flavor .name } ' missing attributes: { ', ' .join (wrong )} "
96- # only report missing optional attributes if main ones are missing as well
97- # reasoning here is that these optional attributes are merely a hint for implementers
98- # and if the main ones are present, we assume that implementers have done their job already
99- if miss_opt :
100- message += f"; additionally, missing optional attributes: { ', ' .join (miss_opt )} "
101- logger .error (message )
102- return not offenses
103-
104-
10561def compute_scs_0101_entropy_avail (collected_vm_output , image_name ):
10662 """This test ensures that the `entropy_avail` value is correct for a test VM."""
10763 lines = collected_vm_output ['entropy-avail' ]
@@ -115,15 +71,6 @@ def compute_scs_0101_entropy_avail(collected_vm_output, image_name):
11571 return True
11672
11773
118- def compute_scs_0101_rngd (collected_vm_output , image_name ):
119- """This test ensures that the `rngd` service is running on a test VM."""
120- lines = collected_vm_output ['rngd' ]
121- if "could not be found" in '\n ' .join (lines ):
122- logger .error (f"VM '{ image_name } ' doesn't provide service rngd" )
123- return False
124- return True
125-
126-
12774def compute_scs_0101_fips_test (collected_vm_output , image_name ):
12875 """This test ensures that the 'fips test' via `rngtest` is passed on a test VM."""
12976 lines = collected_vm_output ['fips-test' ]
0 commit comments