Skip to content

Commit b3f6981

Browse files
achilleas-ksupakeen
authored andcommitted
test: update tests to look for mount units and not fstab
Some tests rely on reading the fstab options from the manifest to verify that filesystems and swap partitions generate the right options. These have been changed to instead look for org.osbuild.systemd.unit.create stages with filenames ending in .mount and .swap.
1 parent d096fcd commit b3f6981

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

test/test_manifest.py

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,36 @@ def test_manifest_anaconda_module_customizations(tmpdir_factory, build_container
405405
assert "org.fedoraproject.Anaconda.Modules.Timezone" not in st["options"]["activatable-modules"]
406406

407407

408-
def find_fstab_stage_from(manifest_str):
408+
def find_fs_mount_info_from(manifest_str):
409409
manifest = json.loads(manifest_str)
410+
mount_stages = []
411+
# normally there should be only one swap partition, but there's no technical reason you can't have multiple
412+
swap_stages = []
410413
for pipeline in manifest["pipelines"]:
411-
# the fstab stage in cross-arch manifests is in the "ostree-deployment" pipeline
414+
# the mount unit stages in cross-arch manifests are in the "ostree-deployment" pipeline
412415
if pipeline["name"] in ("image", "ostree-deployment"):
413416
for st in pipeline["stages"]:
414-
if st["type"] == "org.osbuild.fstab":
415-
return st
416-
raise ValueError(f"cannot find fstab stage in manifest:\n{manifest_str}")
417+
if st["type"] == "org.osbuild.systemd.unit.create":
418+
options = st["options"]
419+
if options["filename"].endswith(".mount"):
420+
mount_stages.append(st)
421+
elif options["filename"].endswith(".swap"):
422+
swap_stages.append(st)
423+
424+
if not mount_stages:
425+
raise ValueError(f"cannot find mount unit creation stages in manifest:\n{manifest_str}")
426+
427+
mounts = []
428+
for stage in mount_stages:
429+
options = stage["options"]["config"]
430+
mounts.append(options["Mount"])
431+
432+
swaps = []
433+
for stage in swap_stages:
434+
options = stage["options"]["config"]
435+
swaps.append(options["Swap"])
436+
437+
return mounts, swaps
417438

418439

419440
@pytest.mark.parametrize("fscustomizations,rootfs", [
@@ -480,25 +501,23 @@ def test_manifest_fs_customizations_smoke_toml(tmp_path, build_container):
480501

481502

482503
def assert_fs_customizations(customizations, fstype, manifest):
483-
# use the fstab stage to get filesystem types for each mountpoint
484-
fstab_stage = find_fstab_stage_from(manifest)
485-
filesystems = fstab_stage["options"]["filesystems"]
504+
mounts, _ = find_fs_mount_info_from(manifest)
486505

487506
manifest_mountpoints = set()
488-
for fs in filesystems:
489-
manifest_mountpoints.add(fs["path"])
490-
if fs["path"] == "/boot/efi":
491-
assert fs["vfs_type"] == "vfat"
507+
for mount in mounts:
508+
manifest_mountpoints.add(mount["Where"])
509+
if mount["Where"] == "/boot/efi":
510+
assert mount["Type"] == "vfat"
492511
continue
493512

494-
if fstype == "btrfs" and fs["path"] == "/boot":
513+
if fstype == "btrfs" and mount["Where"] == "/boot":
495514
# /boot keeps its default fstype when using btrfs
496-
assert fs["vfs_type"] == "ext4"
515+
assert mount["Type"] == "ext4"
497516
continue
498517

499-
assert fs["vfs_type"] == fstype, f"incorrect filesystem type for {fs['path']}"
518+
assert mount["Type"] == fstype, f"incorrect filesystem type for {mount['Where']}"
500519

501-
# check that all fs customizations appear in fstab
520+
# check that all fs customizations appear in the manifest
502521
for custom_mountpoint in customizations:
503522
assert custom_mountpoint in manifest_mountpoints
504523

@@ -699,14 +718,12 @@ def test_manifest_disk_customization_swap(tmp_path, build_container):
699718
mkswap_stage = find_mkswap_stage_from(output)
700719
assert mkswap_stage["options"].get("uuid")
701720
swap_uuid = mkswap_stage["options"]["uuid"]
702-
fstab_stage = find_fstab_stage_from(output)
703-
filesystems = fstab_stage["options"]["filesystems"]
721+
_, swaps = find_fs_mount_info_from(output)
722+
what_node = f"/dev/disk/by-uuid/{swap_uuid}"
704723
assert {
705-
'uuid': swap_uuid,
706-
"vfs_type": "swap",
707-
"path": "none",
708-
"options": "defaults",
709-
} in filesystems
724+
"What": what_node,
725+
"Options": "defaults",
726+
} in swaps
710727

711728

712729
def test_manifest_disk_customization_lvm_swap(tmp_path, build_container):
@@ -744,14 +761,12 @@ def test_manifest_disk_customization_lvm_swap(tmp_path, build_container):
744761
mkswap_stage = find_mkswap_stage_from(output)
745762
assert mkswap_stage["options"].get("uuid")
746763
swap_uuid = mkswap_stage["options"]["uuid"]
747-
fstab_stage = find_fstab_stage_from(output)
748-
filesystems = fstab_stage["options"]["filesystems"]
764+
_, swaps = find_fs_mount_info_from(output)
765+
what_node = f"/dev/disk/by-uuid/{swap_uuid}"
749766
assert {
750-
'uuid': swap_uuid,
751-
"vfs_type": "swap",
752-
"path": "none",
753-
"options": "defaults",
754-
} in filesystems
767+
"What": what_node,
768+
"Options": "defaults",
769+
} in swaps
755770
# run osbuild schema validation, see gh#748
756771
if not testutil.has_executable("osbuild"):
757772
pytest.skip("no osbuild executable")

0 commit comments

Comments
 (0)