Skip to content

Commit 1cb887d

Browse files
alexlarssonmvo5
authored andcommitted
test: Add test of --build-container
This just tries to build a cs9 image using a cs10 build container.
1 parent e37bb83 commit 1cb887d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

test/test_build_disk.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ImageBuildResult(NamedTuple):
3535
img_path: str
3636
img_arch: str
3737
container_ref: str
38+
build_container_ref: str
3839
rootfs: str
3940
disk_config: str
4041
username: str
@@ -314,7 +315,7 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload, gpg_
314315
bib_output = bib_output_path.read_text(encoding="utf8")
315316
results.append(ImageBuildResult(
316317
image_type, generated_img, tc.target_arch,
317-
container_ref, tc.rootfs, tc.disk_config,
318+
container_ref, tc.build_container_ref, tc.rootfs, tc.disk_config,
318319
username, password,
319320
ssh_keyfile_private_path, kargs, bib_output, journal_output))
320321

@@ -384,6 +385,7 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload, gpg_
384385
upload_args = []
385386
creds_args = []
386387
target_arch_args = []
388+
build_container_args = []
387389
if tc.target_arch:
388390
target_arch_args = ["--target-arch", tc.target_arch]
389391

@@ -433,10 +435,16 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload, gpg_
433435
# Pull the signed image
434436
testutil.pull_container(container_ref, tls_verify=False)
435437

438+
if tc.build_container_ref:
439+
build_container_args = [
440+
"--build-container", tc.build_container_ref,
441+
]
442+
436443
cmd.extend([
437444
*creds_args,
438445
build_container,
439446
container_ref,
447+
*build_container_args,
440448
*types_arg,
441449
*upload_args,
442450
*target_arch_args,
@@ -476,7 +484,7 @@ def del_ami():
476484
for image_type in image_types:
477485
results.append(ImageBuildResult(
478486
image_type, artifact[image_type], tc.target_arch,
479-
container_ref, tc.rootfs, tc.disk_config,
487+
container_ref, tc.build_container_ref, tc.rootfs, tc.disk_config,
480488
username, password,
481489
ssh_keyfile_private_path, kargs, bib_output, journal_output, metadata))
482490
yield results
@@ -510,6 +518,12 @@ def test_image_is_generated(image_type):
510518
f"content: {os.listdir(os.fspath(image_type.img_path))}"
511519

512520

521+
@pytest.mark.parametrize("image_type", gen_testcases("build-container"), indirect=["image_type"])
522+
def test_build_container_works(image_type):
523+
assert image_type.img_path.exists(), "output file missing, dir "\
524+
f"content: {os.listdir(os.fspath(image_type.img_path))}"
525+
526+
513527
def assert_kernel_args(test_vm, image_type):
514528
exit_status, kcmdline = test_vm.run("cat /proc/cmdline", user=image_type.username, password=image_type.password)
515529
assert exit_status == 0

test/testcases.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
class TestCase:
1515
# container_ref to the bootc image, e.g. quay.io/fedora/fedora-bootc:40
1616
container_ref: str = ""
17+
# optional build_container_ref to the bootc image, e.g. quay.io/fedora/fedora-bootc:40
18+
build_container_ref: str = ""
1719
# image is the image type, e.g. "ami"
1820
image: str = ""
1921
# target_arch is the target archicture, empty means current arch
@@ -141,4 +143,8 @@ def gen_testcases(what): # pylint: disable=too-many-return-statements
141143
TestCaseFedora(target_arch="ppc64le"),
142144
TestCaseFedora(target_arch="s390x"),
143145
]
146+
if what == "build-container":
147+
return [
148+
TestCaseC9S(build_container_ref="quay.io/centos-bootc/centos-bootc:stream10", image="qcow2"),
149+
]
144150
raise ValueError(f"unknown test-case type {what}")

0 commit comments

Comments
 (0)