Commit graph

3260 commits

Author SHA1 Message Date
Achilleas Koutsou
8a9dac5258 tools/test: include optional metadata in tests
Run depsolve tests both with and without adding filelists to optional
metadata.
2024-05-29 01:39:05 +02:00
Achilleas Koutsou
31362772dd tools/osbuild-depsolve-dnf5: support optional metadata
We originally enabled filelists unconditionally in dnf5.  Let's make it
optional as part of the 'optional-metadata' option in the arguments so
that the caller can decide if it's needed, for example when using dnf5
with older repositories that have packages with file dependencies, but
don't download them when they're not needed, since the filelists are
quite large.
2024-05-29 01:39:05 +02:00
Achilleas Koutsou
806a1caba7 tools/osbuild-depsolve-dnf: support optional metadata
Filelist repo metadata is required when using newer versions of libdnf
with old repositories or packages that specify dependencies on files.
For example, depsolving with RHEL 9.3 repos on Fedora 40 fails to
resolve platform-python with the message

  nothing provides /usr/libexec/platform-python needed by platform-python-...

Not loading filelists is beneficial because it greatly reduces the size
of the metadata to download.  Filelists were downloaded by default for
repositories in the past, but with newer versions of dnf/libdnf (in
Fedora 40), they are downloaded on-demand (e.g. when running a query
that requires file information).  Newer package guidelines prohibit
depending on file paths, so filelists are not needed for package
depsolving with newer distro repositories.

Add an 'optional-metadata' property to the 'arguments' object of the
depsolve request, so that callers can enable any optional metadata they
need.

Further reading:
- https://libdnf.readthedocs.io/en/stable/tutorial-py/#case-for-loading-the-filelists
- https://github.com/rpm-software-management/dnf/releases/tag/4.19.0
- https://dnf.readthedocs.io/en/stable/user_faq.html#starting-with-fedora-40-i-noticed-repository-metadata-is-synchronized-much-faster-what-happened
2024-05-29 01:39:05 +02:00
Michael Vogt
ad13333f36 test: tweak test_osbuild_mount_failure_msg() for tmt/fc40
The `test_osbuild_mount_failure_msg` currently fails on fc40 when
run in tmt, see:
https://artifacts.dev.testing-farm.io/c6588a82-a2cb-46df-8ca8-85dd809465f2/

This is because the failure output is slightly different between
a container and a VM/real-machine. The test ensures that we capture
the output of mount and present to the user (for easier debugging).
So this commit updates this test once more for the error string
(that part of the error comes directly from the kernels fsconfig).

If we need another update of the string we should reconsider this
test and e.g. just use `testutil.mock_command()` for this. But
for now it's easier to just add this one more failure string.
2024-05-23 14:56:41 +02:00
schutzbot
6b8f2ad20b Post release version bump
[skip ci]
2024-05-22 08:15:46 +00:00
Andre Marianiello
4dbf8e2d59 stages(users): add additional tests for force_password_reset 2024-05-20 14:13:56 -07:00
Michael Vogt
af7485b406 stages(users): add small unit test that passwd is called correctly 2024-05-20 14:13:56 -07:00
Andre Marianiello
b722bef9cb stages/org.osbuild.users: Add force password reset option
Add the force_password_reset field to the users option in the
org.osbuild.users stage. This option forces the user to change their
password on first login.
2024-05-20 14:13:56 -07:00
Michael Vogt
2a17756f45 Revert "runners: clean up temp files before exiting the runner"
This reverts commit bc04bfc366.

The `remove_tmpfiles()` helper is nice but it is also problematic
because it creates extra output after the command was run and
created output. E.g. a test failure on centos stream9 [0]
```
            r = root.run(["stat", "--format=%a", "/var/tmp"], monitor)
            assert r.returncode == 0
>           assert r.stdout.strip().split("\n")[-1] == "1777"
E           AssertionError: assert '/usr/lib/tmp... such process' == '1777'
E
E             - 1777
E             + /usr/lib/tmpfiles.d/rpcbind.conf:2: Failed to resolve user 'rpc': No such process
```
Here the output from "stat" is not the last output because the
rempve_tmpfiles runs `systemd-tmpfiles --clean --remove` which
produces some noisy output after stat was run.

This was found by @thozza (thanks!) and discussed in osbuild PR#1785.

There are various ways to fix this, the one is to use the
`--graceful` option of systemd-tmpfiles. However that only got added in
systemd v256 and centos-stream9 has v252 so that is sadly not an option.

Plus even when avaialble it will produce some informational output like
```
All rules containing unresolvable specifiers will be skipped.
```

Another way would be to sent the output from systemd-tmpfiles cleanup
to /dev/null. Not really great as we will not know about real problems
or warnings that we should care about.

None of the option above is good. So I started looking at the tmpfiles.d
rules and the cleanup and why we are doing it. It was added relatively
recently in https://github.com/osbuild/osbuild/pull/1458 and after
some medidiation not having it seems to do no harm (details below). The
tl;dr is that the buildroot is created inside bubblewrap and the
dirs that `--clean` and `--remove` touch are already tmpdirs created
just for the buildroot so the cleanup in the runner is redundant
(and because the cleanup is now run for each buidlroot.run() command
there *might* be unintended conequences but the current rules seem
to not have any).

In detail, the tmpfiles_cleanup() does two things:
1. `--clean`
It will remove files that are older then the given age
in tmpfiles.d. The tmpfiles in centos9 give me the following ages:
```
$ systemd-tmpfiles --cat-config|grep -E '[0-9]+d$'
d /var/lib/systemd/pstore 0755 root root 14d
d /var/lib/systemd/coredump 0755 root root 3d
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d
D! /tmp/.X11-unix 1777 root root 10d
D! /tmp/.ICE-unix 1777 root root 10d
D! /tmp/.XIM-unix 1777 root root 10d
D! /tmp/.font-unix 1777 root root 10d
```
Given that we run our commands inside a bubblewrap environment and
give it a fresh /run, /tmp, /var [1] there really should be no long
lived things and even if there are they are cleaned up from the
buildroot itself

2. `--remove`
It will remove files marked for removal in tmpdfiles.d. Running
it on a centos9 env it yields for me:
```
$ systemd-tmpfiles --cat-config|grep -E '^[rRD]'
R /var/tmp/dnf*/locks/*
r /var/cache/dnf/download_lock.pid
r /var/cache/dnf/metadata_lock.pid
r /var/lib/dnf/rpmdb_lock.pid
r /var/log/log_lock.pid
r! /forcefsck
r! /fastboot
r! /forcequotacheck
D! /var/lib/containers/storage/tmp 0700 root root
D! /run/podman 0700 root root
D! /var/lib/cni/networks
R! /var/tmp/container_images*
D     /run/rpcbind 0700  rpc  rpc  -  -
D /run/sudo/ts 0700 root root
R! /tmp/systemd-private-*
R! /var/tmp/systemd-private-*
r! /var/lib/systemd/coredump/.#*
D! /tmp/.X11-unix 1777 root root 10d
D! /tmp/.ICE-unix 1777 root root 10d
D! /tmp/.XIM-unix 1777 root root 10d
D! /tmp/.font-unix 1777 root root 10d
r! /tmp/.X[0-9]*-lock
```
which is also covered by the bwrap cleanup.

[0] https://artifacts.dev.testing-farm.io/2d07b8f3-5f52-4e61-b1fa-5328a0ff1058/#artifacts-/plans/unit-tests
[1] https://github.com/osbuild/osbuild/blob/main/osbuild/buildroot.py#L218
2024-05-20 11:55:24 -07:00
Achilleas Koutsou
88974ab052 stages/systemd.unit.create: validation function
Cleaner and makes the linter happy (too-many-branches).
2024-05-17 14:26:14 +02:00
Achilleas Koutsou
e92b683e11 test/systemd_unit_create: mount unit type creation 2024-05-17 14:26:14 +02:00
Achilleas Koutsou
f085714a7e test/systemd_unit_create: filename-config validation 2024-05-17 14:26:14 +02:00
Achilleas Koutsou
425ba46f50 test/systemd_unit_create: Mount schema validation 2024-05-17 14:26:14 +02:00
Achilleas Koutsou
5d57f84d4d stages/systemd.unit.create: validate filename sections
Based on the filename, different sections of the unit configuration are
valid.  Service (.service) units require a [Service] section and mount
(.mount) units requires a [Mount] section.

It might be possible to validate this in the schema but it would
probably require a major rewrite and could get complicated.  For now,
validate it in the stage code itself.
2024-05-17 14:26:14 +02:00
Achilleas Koutsou
835b49d052 stages/systemd.unit.create: update schema to support [Mount] 2024-05-17 14:26:14 +02:00
schutzbot
b77b071598 schutzfile: Update snapshots to 20240514 2024-05-16 07:13:05 -07:00
Tomáš Hozza
2161798312 Test/buildroot: fix checking /var/tmp mode
The motivation for this change is to fix a failing unit test in c9s
CI. Specifically an instance of:

https://artifacts.dev.testing-farm.io/2d07b8f3-5f52-4e61-b1fa-5328a0ff1058/#artifacts-/plans/unit-tests
https://gitlab.com/redhat/centos-stream/rpms/osbuild/-/merge_requests/135

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-05-16 09:58:38 +02:00
Achilleas Koutsou
a42b797787 test/systemd_unit_create: add Before value
Add test value for Before.
2024-05-14 11:17:02 +02:00
Achilleas Koutsou
361614c202 stage/systemd.unit.create: add Before option
Support the Before option in the Unit section of the unit file.
2024-05-14 11:17:02 +02:00
Paweł Poławski
cae97bb73a Tests: Add unit tests for org.osbuild.mkfs.fat stage 2024-05-14 09:34:40 +02:00
Paweł Poławski
91c6352c80 tests: Update stage tests readme
Readme was pointing to the dead ling with manifest v2 documentation.
I have redirected it to the documentation presented in repo.
2024-05-13 11:19:26 -07:00
schutzbot
77ce02c3d3 Post release version bump
[skip ci]
2024-05-08 08:13:38 +00:00
Achilleas Koutsou
86f3459eef stages: add unit test for bootc.install.config stage 2024-05-06 14:09:47 +02:00
Achilleas Koutsou
e94aef7dce stages: new bootc.install.config stage
New stage for writing a bootc-install-config with all the options
currently supported.  See bootc-install-config(5).
2024-05-06 14:09:47 +02:00
schutzbot
c3da95780a schutzfile: Update snapshots to 20240502 2024-05-03 15:07:44 +02:00
Michael Vogt
4f4bddcc75 test: add "functional" test for devices/mounts acceptance
This test ensures that the inputs of devices/mounts we generate for
bootc are actually considered valid by the schema. This is a more
blackbox style test compared to `test_get_schema_automatically_added`
which just checks that we get the expected schema but not that the
expected schema actually parses our inputs.
2024-05-03 11:26:22 +02:00
Michael Vogt
11d41ab5a2 stages: remove test_schema_supports_bootc_style_mounts tests
With PR#1727 merged there is no need to test for individual stages
if they support the bootc style mounting in their schema. All
stages now support devices/mounts now. So let's remove this
redundant code.
2024-05-03 11:26:22 +02:00
Ondřej Budai
5da9a2fb63 stages/kickstart: add support for the dir transport
Also, let's adjust the test.
2024-05-03 11:13:44 +02:00
Alexander Todorov
4b66874824 Start building RPMs on 9.5 nightly
Related: COMPOSER-2227
2024-05-03 11:09:38 +02:00
Michael Vogt
a0d4dfa575 osbuild: fix error match in mount test for fc40
Similar to 4a51baf this fixes another issue in the mount error
checking where the error message changed.
2024-05-02 12:09:44 +02:00
Michael Vogt
ed0239c808 workflow: bump osbiuld-ci container to include podman, et al.
This will include the latest osbuild-ci container changes from
https://github.com/osbuild/containers/pull/73

This includes a bunch of binaries that were missing and lead
to skpped tests.
2024-05-02 12:09:44 +02:00
Brian C. Lane
107593a1fd spec: Install osbuild-depsolve-dnf not dnf5
On Fedora 40 we switched to dnf5 too early. There is going to be a new
version in Fedora 41 soon, with breaking API changes, so in order to
reduce the number of things we need to support, switch back to using
libdnf on Fedora 40 (and 41 until dnf5 version 5.2.0 is available,
see #1769)
2024-05-02 10:50:53 +02:00
Ondřej Budai
1b5b015fef stages/skopeo: Fix the remove-signatures option
It's defined on the options level, not on the destination level.
A previous commit added a test for this.
2024-05-01 00:23:02 +02:00
Ondřej Budai
2e771692a7 stages/test: Check that remove_signatures is passed to skopeo-copy
Quite a dirty test, but it will get the job done.
2024-05-01 00:23:02 +02:00
Ondřej Budai
af0e849081 sources/curl: Use our own User-Agent
Currently, osbuild downloads are identified as coming from `curl`. This
is unfortunate because some RPM mirrors block requests from curl. Let's
"fix" that by introducing our own user-agent. While this can certainly
be seen as "circumventing" a policy, I think that this change is
actually helpful: Now, the mirror maintainers can actually distinguish
osbuild requests from regular curl calls. If they want to block osbuild,
they certainly can, we have no power there, but at least this allows
more fine-grained filtering. Also, our new user-agent contains our
domain name, so if there's a problem, they can contact us.
2024-04-30 03:10:44 +02:00
Michael Vogt
d50857e5aa stages: fix test values for "images" inputs
The "images" inputs in the tests were bad test values and only worked
"by accident" [0]. Thanks to Achilleas for discovering this!

This commit fixes this.

[0] https://github.com/osbuild/osbuild/pull/1752#discussion_r1580891435
2024-04-29 14:11:44 +02:00
Michael Vogt
bd8f361851 stages: tweak the skopeo copy test
Small tweaks to the skopeo copy stage integration test to split
the tests into their own test-cases.
2024-04-29 14:11:44 +02:00
Brian C. Lane
2269554829 osbuild-depsolve-dnf5: Fix sslverify setting
It was accidentally switched to being set on repo instead of conf when
it was renamed in commit ffa1e91707
2024-04-27 00:29:02 +02:00
Brian C. Lane
3ef6e684e5 test: Add a depsolve test for sslverify
Also fix the test, it wasn't updated to use sslverify instead of
ignoressl. This now correctly passes on -dnf and fails on -dnf5 which
will be fixed in the next commit.
2024-04-27 00:29:02 +02:00
Florian Schüller
8b5e2a67a6 test_clamp_mtime: avoid clashing with chrony
Any sub-second or larger time adjustments by chrony or similar
would corrupt this time sensitive test without a
counter measure like this
2024-04-27 00:00:10 +02:00
Brian C. Lane
15213fd3cf Revert "Disable F40 CI (CVE-2024-3094 response)"
F40 is safe to use again

This reverts commit dc85702553.
2024-04-26 18:20:16 +02:00
Florian Schüller
fc6dc1ea8b stages/org.osbuild.skopeo: support for "--remove-signatures" 2024-04-26 15:51:00 +02:00
Florian Schüller
7de7838534 stages/org.osbuild.skopeo: support for dir and oci-archive 2024-04-26 15:51:00 +02:00
Michael Vogt
a3f86a0736 testutil: fix make_container() cleanup
During the work on PR#1752 Florian discovered that make_containers()
is broken for nested containers like:
```
with make_container(tmp_path, {"file1": "file1 from base"}) as base_tag:
    with make_container(tmp_path, {"file1": "file1 from final layer"}, base_tag) as cont_tag:
```
It errors with:
```
Error: 5b947de461ee21b858dd5b4224e80442b2f65b6410189147f2445884d9e4e3d8: image not known
```
The reason is that we work with hashes for the image and then call
`podman image rm` which by default will also remove all dangling
references. Those are defined by not having a tag and not referenced
anymore. So the inner container cleanup also removes the outter.

There are many ways to fix this, I went with re-adding tags to the
test containers because it also makes it easy for the user to see if
we left any containers (accidently) around.
2024-04-25 21:59:40 +02:00
Michael Vogt
15e969c4c6 workflow: show summary why tests are skipped
In PR#1752 Florian noticed that `make_containers` is buggy [0] in
one specific testcase. However the GH actions did not trigger and
uppon inspection the test is skipped:
```
stages/test/test_container_deploy.py::test_container_deploy_integration SKIPPED [  7%]
```
This commit adds `-rs` to get a summary why the tests are skipped.

This is useful in general, I suspect the test container might miss
podman but this commit will bring clarity.

[0] https://github.com/osbuild/osbuild/pull/1752#discussion_r1578294358
2024-04-25 20:44:32 +02:00
Michael Vogt
4a51bafa46 osbuild: fix error match in mount test for rawhide
Latest util-linux mount uses fsconfig(2) instead of mount(2) so the
error is different.

See https://artifacts.dev.testing-farm.io/53b552b6-5753-47e2-9cd0-43fa8b6e5f9f/

Closes: https://github.com/osbuild/osbuild/issues/1753
2024-04-25 11:07:49 +02:00
schutzbot
59bff6d742 Post release version bump
[skip ci]
2024-04-24 08:16:01 +00:00
Achilleas Koutsou
1f0f18d281 test/stages/systemd: add -.mount unit to test
Create a unit using an inline file called -.mount with the following
content:

  [Unit]
  Before=local-fs.target
  After=blockdev@dev-disk-by\x2duuid-af34257d\x2d3e14\x2d4a51\x2db91d\x2dc430a956dcba.target

  [Mount]
  What=/dev/disk/by-uuid/af34257d-3e14-4a51-b91d-c430a956dcba
  Where=/
  Type=ext4
  Options=rw,noatime

  [Install]
  RequiredBy=local-fs.target

and enable it in the systemd stage to test that we can enable units with
a - prefix.
2024-04-23 19:59:44 +02:00
Achilleas Koutsou
901fa24905 stages/systemd: add -- before unit names
Units can start with a -, for example, -.mount.  Trying to enable,
disable, or mask a service like that fails with

  systemctl: invalid option -- '.'
  Hint: to specify units starting with a dash, use "--":
        systemctl [OPTIONS...] COMMAND -- -.mount ...

Adding -- to all 'systemctl' calls lets us specify unit files that start
with -.
2024-04-23 19:59:44 +02:00
Brian C. Lane
106a9af937 test_depsolve: Use host python3 for libdnf check 2024-04-23 07:42:09 +02:00