Skip to content

Commit

Permalink
test: build all disk image types in a single build
Browse files Browse the repository at this point in the history
The vmdk images cannot be booted easily in qemu so we will just
check that the image is there but do no functional testing.
  • Loading branch information
mvo5 authored and achilleas-k committed Mar 14, 2024
1 parent 38f4664 commit 70a639b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
14 changes: 6 additions & 8 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# local test utils
import testutil
from containerbuild import build_container_fixture # noqa: F401
from testcases import CLOUD_BOOT_IMAGE_TYPES, QEMU_BOOT_IMAGE_TYPES, gen_testcases
from testcases import CLOUD_BOOT_IMAGE_TYPES, DISK_IMAGE_TYPES, gen_testcases
from vm import AWS, QEMU

if not testutil.has_executable("podman"):
Expand Down Expand Up @@ -222,11 +222,9 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload):
# upload forced but credentials aren't set
raise RuntimeError("AWS credentials not available (upload forced)")

# qemu boot images can be build with a single invocation
# TODO: ensure that *all* images can be built with the same call, to
# do this we need the "superimage" support in images first
if image_types[0] in QEMU_BOOT_IMAGE_TYPES:
types_arg = [f"--type={it}" for it in QEMU_BOOT_IMAGE_TYPES]
# all disk-image types can be generated via a single build
if image_types[0] in DISK_IMAGE_TYPES:
types_arg = [f"--type={it}" for it in DISK_IMAGE_TYPES]
else:
types_arg = [f"--type={image_types[0]}"]

Expand Down Expand Up @@ -309,7 +307,7 @@ def test_container_builds(build_container):
assert build_container in output


@pytest.mark.parametrize("image_type", gen_testcases("all"), indirect=["image_type"])
@pytest.mark.parametrize("image_type", gen_testcases("multidisk"), indirect=["image_type"])
def test_image_is_generated(image_type):
assert image_type.img_path.exists(), "output file missing, dir "\
f"content: {os.listdir(os.fspath(image_type.img_path))}"
Expand Down Expand Up @@ -413,7 +411,7 @@ def test_iso_installs(image_type):
@pytest.mark.parametrize("images", gen_testcases("multidisk"), indirect=["images"])
def test_multi_build_request(images):
artifacts = set()
expected = {"disk.qcow2", "disk.raw"}
expected = {"disk.qcow2", "disk.raw", "disk.vmdk"}
for result in images:
filename = os.path.basename(result.img_path)
assert result.img_path.exists()
Expand Down
14 changes: 7 additions & 7 deletions test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
# supported images that can be directly booted
QEMU_BOOT_IMAGE_TYPES = ("qcow2", "raw")

# supported images that can be booted in a cloud
CLOUD_BOOT_IMAGE_TYPES = ("ami",)

# images that can *not* be booted directly from qemu
NON_QEMU_BOOT_IMAGE_TYPES = ("vmdk",)

# disk image types can be build from a single manifest
DISK_IMAGE_TYPES = QEMU_BOOT_IMAGE_TYPES + NON_QEMU_BOOT_IMAGE_TYPES

# supported images that can be booted in a cloud
CLOUD_BOOT_IMAGE_TYPES = ("ami",)

# supported images that require an install
INSTALLER_IMAGE_TYPES = ("anaconda-iso",)

Expand Down Expand Up @@ -64,14 +67,11 @@ def gen_testcases(what):
INSTALLER_IMAGE_TYPES:
test_cases.append(f"{cnt},{img_type}")
return test_cases
# TODO: make images generate a superdisk manifest with pipelines for
# qcow2+vmdk+raw so that we can just generate them all via a
# single build
elif what == "multidisk":
# single test that specifies all image types
test_cases = []
for cnt in CONTAINERS_TO_TEST.values():
img_type = "+".join(QEMU_BOOT_IMAGE_TYPES)
img_type = "+".join(DISK_IMAGE_TYPES)
test_cases.append(f"{cnt},{img_type}")
return test_cases
raise ValueError(f"unknown test-case type {what}")

0 comments on commit 70a639b

Please sign in to comment.