Skip to content

Commit

Permalink
fixup! add quick outline of how this could be tested
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Jan 26, 2024
1 parent 5baf643 commit 81389b7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@


# image types to test
DIRECT_BOOT_IMAGE_TYPES = ["qcow2", "ami", "raw"]
DIRECT_BOOT_IMAGE_TYPES = ["qcow2,aarch64", "ami", "raw"]
INSTALLER_IMAGE_TYPES = ["iso"]
SUPPORTED_IMAGE_TYPES = DIRECT_BOOT_IMAGE_TYPES + INSTALLER_IMAGE_TYPES


class ImageBuildResult(NamedTuple):
img_type: str
img_path: str
img_arch: str
username: str
password: str
journal_output: str
Expand All @@ -49,7 +50,12 @@ def image_type_fixture(tmpdir_factory, build_container, request, force_aws_uploa
ImageBuildResult with the resulting image path and user/password
"""
# image_type is passed via special pytest parameter fixture
image_type = request.param
image_type_inp = request.param
target_arch = None
if "," in image_type_inp:
image_type, target_arch = image_type_inp.split(",")
else:
image_type = image_type_inp

username = "test"
password = "password"
Expand All @@ -64,7 +70,7 @@ def image_type_fixture(tmpdir_factory, build_container, request, force_aws_uploa
"raw": pathlib.Path(output_path) / "image/disk.raw",
"iso": pathlib.Path(output_path) / "bootiso/install.iso",
}
assert len(artifact) == len(SUPPORTED_IMAGE_TYPES), \
assert len(artifact) == len(set([t.split(",")[0] for t in SUPPORTED_IMAGE_TYPES])), \
"please keep artifact mapping and supported images in sync"
generated_img = artifact[image_type]

Expand Down Expand Up @@ -95,6 +101,8 @@ def image_type_fixture(tmpdir_factory, build_container, request, force_aws_uploa

upload_args = []
creds_args = []
if target_arch:
target_arch_args = ["--target-arch", target_arch]

with tempfile.TemporaryDirectory() as tempdir:
if image_type == "ami":
Expand Down Expand Up @@ -124,6 +132,7 @@ def image_type_fixture(tmpdir_factory, build_container, request, force_aws_uploa
container_to_build_ref(),
"--config", "/output/config.json",
"--type", image_type,
*target_arch_args,
*upload_args,
])
journal_output = testutil.journal_after_cursor(cursor)
Expand All @@ -137,7 +146,7 @@ def del_ami():

journal_log_path.write_text(journal_output, encoding="utf8")

return ImageBuildResult(image_type, generated_img, username, password, journal_output, metadata)
return ImageBuildResult(image_type, generated_img, target_arch, username, password, journal_output, metadata)


def test_container_builds(build_container):
Expand Down

0 comments on commit 81389b7

Please sign in to comment.