test images for metadata deserialization error

Merges: https://pagure.io/pungi/pull-request/1559
Jira: https://issues.redhat.com/browse/RHELCMP-6685
Signed-off-by: fdiprete <fdipretre@redhat.com>
This commit is contained in:
fdiprete 2021-11-01 16:54:34 +00:00 committed by Lubomír Sedlář
parent e2b3002726
commit 7b9e08ab28

View File

@ -18,6 +18,7 @@ import os
from pungi.phases.base import PhaseBase from pungi.phases.base import PhaseBase
from pungi.util import failable, get_arch_variant_data from pungi.util import failable, get_arch_variant_data
import productmd.compose
class TestPhase(PhaseBase): class TestPhase(PhaseBase):
@ -25,6 +26,7 @@ class TestPhase(PhaseBase):
def run(self): def run(self):
check_image_sanity(self.compose) check_image_sanity(self.compose)
check_image_metadata(self.compose)
def check_image_sanity(compose): def check_image_sanity(compose):
@ -45,6 +47,17 @@ def check_image_sanity(compose):
check_size_limit(compose, variant, arch, img) check_size_limit(compose, variant, arch, img)
def check_image_metadata(compose):
"""
Check the images metadata for entries that cannot be serialized.
Often caused by isos with duplicate metadata.
Accessing the `images` attribute will raise an exception if there's a problem
"""
compose = productmd.compose.Compose(compose.paths.compose.topdir())
return compose.images
def check_sanity(compose, variant, arch, image): def check_sanity(compose, variant, arch, image):
path = os.path.join(compose.paths.compose.topdir(), image.path) path = os.path.join(compose.paths.compose.topdir(), image.path)
deliverable = getattr(image, "deliverable") deliverable = getattr(image, "deliverable")