Repository navigation
test: close filesystem/disk customization coverage gaps with osbuild-composer - #2329
Conversation
achilleas-k
left a comment
There was a problem hiding this comment.
Thanks. Love to see more stuff being moved from osbuild-composer down into images again.
Needs some changes though (the image type names in the config at least). Comments inline.
| for _, line := range strings.Split(string(data), "\n") { | ||
| fields := strings.Fields(line) | ||
| if len(fields) >= 2 { | ||
| mounts[fields[1]] = true | ||
| } | ||
| } |
There was a problem hiding this comment.
Parsing /proc/mounts isn't very nice. It's not likely the format will change any time soon, but lsblk -J is a machine-readable alternative, so let's use that instead.
| "image-types": [ | ||
| "generic-qcow2", | ||
| "server-qcow2" | ||
| ], | ||
| "distros": [ | ||
| "centos-10", | ||
| "centos-9", | ||
| "fedora*", | ||
| "rhel-10*", | ||
| "rhel-9*" |
There was a problem hiding this comment.
generic-qcow2 and server-qcow2 are the Fedora image type names. CentOS and RHEL should be move to the next item alongside RHEL 8.
| // TestCheckMountpointsPolicyForbiddenPaths verifies that a blueprint containing | ||
| // forbidden mountpoints (the same set tested in osbuild-composer's filesystem.sh | ||
| // fail case) is properly rejected by CheckMountpointsPolicy. | ||
| func TestCheckMountpointsPolicyForbiddenPaths(t *testing.T) { |
There was a problem hiding this comment.
This seems to be duplicating the tests above in the same file only going through the blueprint method rather than directly calling the policies method. I'm not sure how useful it is. Perhaps having a generic test in the blueprint library would be good, one that sets an arbitrary policy and test if it works as expected.
| "image-types": [ | ||
| "generic-qcow2", | ||
| "server-qcow2" | ||
| ], | ||
| "distros": [ | ||
| "centos-10", | ||
| "centos-9", | ||
| "fedora*", | ||
| "rhel-10*", | ||
| "rhel-9*" | ||
| ] |
b66e424 to
dcbb901
Compare
These tests have been ported to the images repository where they now run as part of the config-driven integration test framework with post-boot verification via check-host-config. The equivalent coverage is provided by: - filesystem-customizations.json (legacy customizations.filesystem API) - filesystem-no-explicit-rootfs.json (RHBZ#2049500 regression) - check-host-config filesystem check (mountpoint verification) - pkg/policies unit tests (forbidden mountpoint rejection) See: osbuild/image-builder#2329
Add a new "filesystem" check to check-host-config that verifies expected mountpoints from the build config are present in the booted image. It collects all mountpoints from both customizations.filesystem (legacy API) and customizations.disk (plain partitions, LVM logical volumes, btrfs subvolumes), then runs lsblk to verify they exist. This closes a verification gap where partitioning configs only checked that the image builds and boots, but never asserted that the requested partitions, LVs, or subvolumes actually appeared.
Add a test configuration that exercises the full set of legacy customizations.filesystem mountpoints (/, /var, /var/log, /var/log/audit, /usr, /tmp, /var/tmp, /home, /home/shadowman, /opt, /srv, /app, /data, /boot, /boot/firmware, /foobar). This brings coverage parity with osbuild-composer's filesystem.sh test for the legacy filesystem customization API.
Add a config that specifies customizations.filesystem for /data but omits an explicit / entry. This covers the RHBZ#2049500 regression where a compose without an explicit root filesystem definition would fail. The build is expected to succeed with the default root filesystem implicitly created by the image builder.
dcbb901 to
6ba8925
Compare
|
I noticed that the changes addressing my comments were squashed into the last commit instead of fixing up the relevant ones so I cleaned up the history a bit and force pushed. I also added manifest checksums for the new configurations. Unfortunately, our manifest checksum check doesn't fail when there are missing checksums, only when there are changes that weren't committed. |
|
200 new configs is a bit much though. Maybe we don't need to test all distros here. (but maybe let's let this one build and merge and we can trim things down later) |
These tests have been ported to the images repository where they now run as part of the config-driven integration test framework with post-boot verification via check-host-config. The equivalent coverage is provided by: - filesystem-customizations.json (legacy customizations.filesystem API) - filesystem-no-explicit-rootfs.json (RHBZ#2049500 regression) - check-host-config filesystem check (mountpoint verification) - pkg/policies unit tests (forbidden mountpoint rejection) See: osbuild/image-builder#2329
These tests have been ported to the images repository where they now run as part of the config-driven integration test framework with post-boot verification via check-host-config. The equivalent coverage is provided by: - filesystem-customizations.json (legacy customizations.filesystem API) - filesystem-no-explicit-rootfs.json (RHBZ#2049500 regression) - check-host-config filesystem check (mountpoint verification) - pkg/policies unit tests (forbidden mountpoint rejection) See: osbuild/image-builder#2329
supakeen
left a comment
There was a problem hiding this comment.
Building 200 extra images every time we refresh snapshots or osbuild commit is going to be ... fun. Like @achilleas-k says, it's probably pretty high priority to cut that down but let's see if it actually makes CI slow first.
lzap
left a comment
There was a problem hiding this comment.
Hmm why don't we merge some image configs together?
These tests have been ported to the images repository where they now run as part of the config-driven integration test framework with post-boot verification via check-host-config. The equivalent coverage is provided by: - filesystem-customizations.json (legacy customizations.filesystem API) - filesystem-no-explicit-rootfs.json (RHBZ#2049500 regression) - check-host-config filesystem check (mountpoint verification) - pkg/policies unit tests (forbidden mountpoint rejection) See: osbuild/image-builder#2329
These tests have been ported to the images repository where they now run as part of the config-driven integration test framework with post-boot verification via check-host-config. The equivalent coverage is provided by: - filesystem-customizations.json (legacy customizations.filesystem API) - filesystem-no-explicit-rootfs.json (RHBZ#2049500 regression) - check-host-config filesystem check (mountpoint verification) - pkg/policies unit tests (forbidden mountpoint rejection) See: osbuild/image-builder#2329
|
So we missed this, but this PR did not bump the seed and thus these tests didn't actually get ran on all configs. They are now failing in other PRs as the columns requested in |
Summary
The
osbuild-composerrepository has integration tests for filesystem and disk customizations (filesystem.sh,regression-no-explicit-rootfs-definition.sh) that verify partitioning layouts, forbidden mount paths, and edge cases. This PR brings equivalent coverage to theimagesrepository so tests are not lost as functionality migrates.Changes
check-host-config: add filesystem mountpoint verification
Add a new
filesystemcheck tocheck-host-configthat verifies all expected mountpoints from bothcustomizations.filesystemandcustomizations.disk(plain, LVM, btrfs) are present in the booted VM by reading/proc/mountsand/proc/swaps. Previously, builds were verified to boot but never asserted the requested partition layout actually appeared.test: add filesystem-customizations integration config
Add a
filesystem-customizations.jsontest config exercising the full set of 16 mountpoints fromosbuild-composer'sfilesystem.sh(/,/var,/var/log,/var/log/audit,/usr,/tmp,/var/tmp,/home,/home/shadowman,/opt,/srv,/app,/data,/boot,/boot/firmware,/foobar).pkg/policies: add mountpoint policy tests for forbidden and allowed paths
Add explicit unit tests verifying
CheckMountpointsPolicyrejects all 14 forbidden paths (/etc,/sys,/proc,/dev,/run,/bin,/sbin,/lib,/lib64,/lost+found,/sysroot,/usr/bin,/var/run,/var/lock) and accepts the full valid set. This is theimages-equivalent of the negative test inosbuild-composer'sfilesystem.sh.test: add filesystem-no-explicit-rootfs regression config
Add a
filesystem-no-explicit-rootfs.jsonconfig that specifies/datawithout an explicit/entry, covering the RHBZ#2049500 regression where such composes would fail. The build must succeed with the default root filesystem implicitly created.Test plan
go test ./cmd/check-host-config/check/ -run TestFilesystem— all 7 subtests passgo test ./pkg/policies/ -run TestCheckMountpointsPolicy— all 30 subtests passpython3 test/scripts/validate-config-list— both new configs validated against known build configurations