diff --git a/test/test_build.py b/test/test_build.py index 7c8ffd13..2ec265f1 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -694,6 +694,9 @@ def assert_disk_customizations(image_type, test_vm): keyfile=image_type.ssh_keyfile_private_path) assert exit_status == 0 findmnt = json.loads(output) + exit_status, swapon_output = test_vm.run("swapon --show", user="root", + keyfile=image_type.ssh_keyfile_private_path) + assert exit_status == 0 if dc := image_type.disk_config: if dc == "lvm": mnts = [mnt for mnt in findmnt["filesystems"][0]["children"] @@ -707,3 +710,7 @@ def assert_disk_customizations(image_type, test_vm): assert "btrfs" == mnts[0]["fstype"] # ensure sysroot comes from the "root" subvolume assert mnts[0]["source"].endswith("[/root]") + elif dc == "swap": + # XXX: drop once this actually runs + print(swapon_output) + assert "1234" in swapon_output diff --git a/test/test_manifest.py b/test/test_manifest.py index c869bdb4..367133e1 100644 --- a/test/test_manifest.py +++ b/test/test_manifest.py @@ -633,3 +633,34 @@ def test_manifest_disk_customization_btrfs(tmp_path, build_container): st = find_bootc_install_to_fs_stage_from(output) assert st["mounts"][0]["type"] == "org.osbuild.btrfs" assert st["mounts"][0]["target"] == "/" + + +def test_manifest_disk_customization_swap(tmp_path, build_container): + container_ref = "quay.io/centos-bootc/centos-bootc:stream9" + + config = { + "customizations": { + "disk": { + "partitions": [ + { + "minsize": "2 GiB", + "fs_type": "swap", + } + ] + } + } + } + config_path = tmp_path / "config.json" + with config_path.open("w") as config_file: + json.dump(config, config_file) + + output = subprocess.check_output([ + *testutil.podman_run_common, + "-v", f"{config_path}:/config.json:ro", + build_container, + "manifest", f"{container_ref}", + ]) + fstab_stage = find_fstab_stage_from(output) + filesystems = fstab_stage["options"]["filesystems"] + # XXX: find swap + print(filesystems) diff --git a/test/testcases.py b/test/testcases.py index ed0ee45e..ea10622f 100644 --- a/test/testcases.py +++ b/test/testcases.py @@ -84,17 +84,14 @@ def gen_testcases(what): # pylint: disable=too-many-return-statements TestCaseCentos(image="anaconda-iso"), ] if what == "qemu-boot": - # test partition defaults with qcow2 test_cases = [ - klass(image="qcow2") - for klass in (TestCaseCentos, TestCaseFedora) + # test default partitioning + TestCaseFedora(image="qcow2"), + # test with custom disk configs + TestCaseCentos(image="qcow2", disk_config="swap"), + TestCaseFedora(image="raw", disk_config="btrfs"), + TestCaseCentos(image="raw", disk_config="lvm"), ] - # and custom with raw (this is arbitrary, we could do it the - # other way around too - test_cases.append( - TestCaseCentos(image="raw", disk_config="lvm")) - test_cases.append( - TestCaseFedora(image="raw", disk_config="btrfs")) # do a cross arch test too if platform.machine() == "x86_64": # TODO: re-enable once diff --git a/test/testutil.py b/test/testutil.py index 8ee8682d..46a922cb 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -159,6 +159,10 @@ def maybe_create_disk_customizations(cfg, tc): "minsize": "10 GiB", "fs_type": "xfs", "mountpoint": "/", + }, + { + "minsize": "2 GiB", + "fs_type": "swap", } ] } @@ -179,6 +183,15 @@ def maybe_create_disk_customizations(cfg, tc): } ] } + elif tc.disk_config == "swap": + cfg["customizations"]["disk"] = { + "partitions": [ + { + "minsize": "1234567890", + "fs_type": "swap", + } + ] + } else: raise ValueError(f"unsupported disk_config {tc.disk_config}")