Skip to content

Commit

Permalink
test: drop size comparison in assert_fs_customizations
Browse files Browse the repository at this point in the history
The size comparison in the build test is bad.  Customizations control
the size of a partition but the function was comparing the usable size
of a filesystem, which can be very different.  Attempts were made to
cover the difference, by simply reducing the expected size by a fixed
amount, but were ultimately inadequate.

We can do better.
  • Loading branch information
achilleas-k authored and mvo5 committed Aug 15, 2024
1 parent 63a3fbc commit 2713962
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def test_image_boots(image_type):
assert f"image: {image_type.container_ref}" in output

# check the minsize specified in the build configuration for each mountpoint against the sizes in the image
# TODO: replace 'df' call with 'parted --json' and find the partition size for each mountpoint
exit_status, output = test_vm.run("df --output=target,size", user="root",
keyfile=image_type.ssh_keyfile_private_path)
assert exit_status == 0
Expand Down Expand Up @@ -461,23 +462,16 @@ def test_multi_build_request(images):


def assert_fs_customizations(image_type, mountpoint_sizes):
"""
Asserts that each mountpoint that appears in the build configuration also appears in mountpoint_sizes.
TODO: assert that the size of each filesystem (or partition) also matches the expected size based on the
customization.
"""
fs_customizations = testutil.create_filesystem_customizations(image_type.rootfs)
for fs in fs_customizations:
mountpoint = fs["mountpoint"]
if mountpoint == "/":
# / is actually /sysroot
mountpoint = "/sysroot"
assert mountpoint in mountpoint_sizes

minsize_human = fs["minsize"]
# assume all sizes are GiB
minsize_str = minsize_human.removesuffix("GiB").strip()
minsize = int(minsize_str) * 2 ** 30
# TODO: find the exact source of all the discrepancies or compare the actual partition sizes instead of the
# filesystem sizes
if mountpoint == "/sysroot":
minsize -= 2 ** 30 # reduce expected /sysroot size by 1 GiB

# NOTE: xfs filesystems are ~40 MiB and ext4 ~26 MiB smaller than the partition - reduce minsize by 100 MiB
minsize -= 100 * 2 ** 20
assert minsize < mountpoint_sizes[mountpoint]

0 comments on commit 2713962

Please sign in to comment.