Stop trying to validate non-existent metadata
When a compose doesn't build any images, it won't produce any metadata file for them, and thus it makes no sense to validate it. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com> Fixes: https://pagure.io/pungi/issue/1565
This commit is contained in:
parent
7b9e08ab28
commit
9d02f87c99
@ -53,9 +53,9 @@ def check_image_metadata(compose):
|
|||||||
Often caused by isos with duplicate metadata.
|
Often caused by isos with duplicate metadata.
|
||||||
Accessing the `images` attribute will raise an exception if there's a problem
|
Accessing the `images` attribute will raise an exception if there's a problem
|
||||||
"""
|
"""
|
||||||
|
if compose.im.images:
|
||||||
compose = productmd.compose.Compose(compose.paths.compose.topdir())
|
compose = productmd.compose.Compose(compose.paths.compose.topdir())
|
||||||
return compose.images
|
return compose.images
|
||||||
|
|
||||||
|
|
||||||
def check_sanity(compose, variant, arch, image):
|
def check_sanity(compose, variant, arch, image):
|
||||||
|
58
tests/fixtures/invalid-image-metadata/compose/metadata/images.json
vendored
Normal file
58
tests/fixtures/invalid-image-metadata/compose/metadata/images.json
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"header": {
|
||||||
|
"type": "productmd.images",
|
||||||
|
"version": "1.2"
|
||||||
|
},
|
||||||
|
"payload": {
|
||||||
|
"compose": {
|
||||||
|
"date": "20181001",
|
||||||
|
"id": "Mixed-1.0-20181001.n.0",
|
||||||
|
"respin": 0,
|
||||||
|
"type": "nightly"
|
||||||
|
},
|
||||||
|
"images": {
|
||||||
|
"Server": {
|
||||||
|
"x86_64": [
|
||||||
|
{
|
||||||
|
"arch": "x86_64",
|
||||||
|
"bootable": false,
|
||||||
|
"checksums": {
|
||||||
|
"md5": "c7977d67f6522bce7fb04c0818a3c744",
|
||||||
|
"sha1": "c7d65673b2eb477016f9e09f321935bace545515",
|
||||||
|
"sha256": "6d9cfc9be59cba96763dcca5d1b5759127d2f7920055b663dbcf29474bc368de"
|
||||||
|
},
|
||||||
|
"disc_count": 1,
|
||||||
|
"disc_number": 1,
|
||||||
|
"format": "iso",
|
||||||
|
"implant_md5": "340b7dc15b9c74b8576b81c3b33fc3f2",
|
||||||
|
"mtime": 1636012560,
|
||||||
|
"path": "Server-Gluster/x86_64/iso/Gluster-2.3-DP-1-20211104.t.4-Server-x86_64-dvd1.iso",
|
||||||
|
"size": 419840,
|
||||||
|
"subvariant": "Server-Gluster",
|
||||||
|
"type": "dvd",
|
||||||
|
"volume_id": "Gluster-2.3 DP-1 Server.x86_64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"arch": "x86_64",
|
||||||
|
"bootable": false,
|
||||||
|
"checksums": {
|
||||||
|
"md5": "a7977d67f6522bce7fb04c0818a3c744",
|
||||||
|
"sha1": "a7d65673b2eb477016f9e09f321935bace545515",
|
||||||
|
"sha256": "ad9cfc9be59cba96763dcca5d1b5759127d2f7920055b663dbcf29474bc368de"
|
||||||
|
},
|
||||||
|
"disc_count": 1,
|
||||||
|
"disc_number": 1,
|
||||||
|
"format": "iso",
|
||||||
|
"implant_md5": "340b7dc15b9c74b8576b81c3b33fc3f2",
|
||||||
|
"mtime": 1636012560,
|
||||||
|
"path": "Server-Gluster/x86_64/iso/Gluster-2.3-DP-1-20211104.t.4-Server-x86_64-dvd1.iso",
|
||||||
|
"size": 419840,
|
||||||
|
"subvariant": "Server-Gluster",
|
||||||
|
"type": "dvd",
|
||||||
|
"volume_id": "Gluster-2.3 DP-1 Server.x86_64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import mock
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import pungi.phases.test as test_phase
|
import pungi.phases.test as test_phase
|
||||||
from tests.helpers import DummyCompose, PungiTestCase, touch
|
from tests.helpers import DummyCompose, PungiTestCase, touch, FIXTURE_DIR
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dnf # noqa: F401
|
import dnf # noqa: F401
|
||||||
@ -305,3 +305,31 @@ class TestCheckImageSanity(PungiTestCase):
|
|||||||
test_phase.check_image_sanity(compose)
|
test_phase.check_image_sanity(compose)
|
||||||
|
|
||||||
self.assertEqual(compose.log_warning.call_args_list, [])
|
self.assertEqual(compose.log_warning.call_args_list, [])
|
||||||
|
|
||||||
|
|
||||||
|
class TestImageMetadataValidation(PungiTestCase):
|
||||||
|
def test_valid_metadata(self):
|
||||||
|
compose = mock.Mock()
|
||||||
|
compose.im.images = {"Server": mock.Mock()}
|
||||||
|
compose.paths.compose.topdir = lambda: os.path.join(
|
||||||
|
FIXTURE_DIR, "basic-metadata"
|
||||||
|
)
|
||||||
|
|
||||||
|
test_phase.check_image_metadata(compose)
|
||||||
|
|
||||||
|
def test_missing_metadata(self):
|
||||||
|
compose = mock.Mock()
|
||||||
|
compose.im.images = {}
|
||||||
|
compose.paths.compose.topdir = lambda: self.topdir
|
||||||
|
|
||||||
|
test_phase.check_image_metadata(compose)
|
||||||
|
|
||||||
|
def test_invalid_metadata(self):
|
||||||
|
compose = mock.Mock()
|
||||||
|
compose.im.images = {"Server": mock.Mock()}
|
||||||
|
compose.paths.compose.topdir = lambda: os.path.join(
|
||||||
|
FIXTURE_DIR, "invalid-image-metadata"
|
||||||
|
)
|
||||||
|
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
test_phase.check_image_metadata(compose)
|
||||||
|
Loading…
Reference in New Issue
Block a user