Commit graph

3039 commits

Author SHA1 Message Date
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
Brian C. Lane
eca54c03ab test_depsolve: Use host environment's /usr/bin/python3
Using just 'python3' uses the venv version when running from tox which
fails even when libdnf5 is available in the host environment.
2024-04-23 07:42:09 +02:00
Achilleas Koutsou
562d30cf59 tools/test: shell out to python3 to check for libdnf5
We run tests using tox to set up environments for different python
versions to test against.  The problem is that when a test shells out to
a python script, like osbuild-depsolve-dnf5, it's not run inside the
environment but in the system environment.  The `has_dnf5()` check
returns False because it fails to import dnf5 in the tox environment,
even though the script can be run and the test will succeed.

Use `python3 -c "import libdnf5"` to decide if the script is runnable
instead of using `importlib`.  This doesn't solve the problem of our
tests running python scripts in a different environment than the one (we
think) we are testing, but it will enable tests of osbuild-depsolve-dnf5
for now.
2024-04-23 07:42:09 +02:00
Brian C. Lane
ffbf75073a osbuild-depsolve-dnf5: Handle null transactions and exclude-specs
The JSON output by go will use 'null' for nil slices, so we need to
use a [] when the field is missing, or when it is set to null.
Previously this was handled by checking the value before iterating but
when the code moved for the directory handling it was changed.

This implements the same behavior in a slightly cleaner way.
2024-04-23 07:42:09 +02:00
Brian C. Lane
4c3dba0db9 test_depsolve: Test with empty exclude-specs
The go json serialize process takes a nil slice and converts that to a
'null' instead of an '[]' or leaving off the field. This means that the
json generated by python is not representative of what is output by
images/dnfjson and we have not been properly testing
osbuild-depsolve-dnf5

Testing dnf5 depsolving *also* requires that libdnf5 be present in the
environment, which is a separate problem that still needs to be fixed.
2024-04-23 07:42:09 +02:00
Brian C. Lane
970b9409b7 workflow: Use new container ghcr.io/osbuild/osbuild-ci:latest-202404161303 2024-04-23 07:42:09 +02:00
Tomáš Hozza
3ae8f25f55 Testutil/importlib: don't write bytecode when importing modules
Cache files will split the extension, this means that all pyc cache
files looks like we get many clashing `org.osbuild.cpython-py311.pyc
files. Moreover, the cache bytecode invalidation is based on the
timestamp (which is the same after git checkout) and the file size
(which may be the same for two different files). This means that we
can't rely on the cache files.

This issue has been found after the previous commit made the
`org.osbuild.systemd` and `org.osbuild.selinux` stages to have exactly
the same size, which caused the interpreter to reuse the bytecode for
the selinux stage when running unit tests for the systemd stage. This
resulted in consistent and weird failures when the systemd stage
options were passed to the selinux stage code.

The credit for this fix goes to Michael Vogt, who found the cause and
fix. Also thanks to Simon de Vlieger for his help with debugging the
problem.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-04-22 16:33:59 +02:00
Tomáš Hozza
13c098cfdd Stages/SELinux: force auto-relabel of full contexts
Previously, the SELinux stage would not force full contexts reset when
forcing auto-relabel on first boot. As a result, all files remained
`unconfined_u` after the auto-relabeling on first boot and only the type
part was reset.

We really need to mimic the behavior of `fixfiles -F onboot` command,
which creates the `/.autorelabel` file with "-F" in it.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-04-22 16:33:59 +02:00
Michael Vogt
06e310b54f tools: extract common test_depsolve() with pytest parameters
Given that the tests `test_depsolve{,_dnf5}` are identical except
the `command` extract them into a common test that is just parameterized.

This will also help to avoid drift between the two resolvers.
2024-04-22 11:08:35 +02:00
Michael Vogt
2f18beba17 stages: allow bootloader --append via kickstart
This commit allows use to append kernel commandline options via
the kickstart file. This is useful for e.g. the bootc installer
where we support customizing this via blueprints.
2024-04-19 13:14:14 +02:00
Achilleas Koutsou
f255fba09f stage/systemd.unit.create: move systemd-analyze verify to tests
Verifying the systemd unit also checks if any referred systemd units
(Wants, Requires, After) exist and if all commands in Exec exist and are
executable.  Without '--root', the systemd-analyze verify command is
testing this against files in the build root, which isn't valid.

Units and binaries might not exist in the build root when referenced in
the image root tree, making the unit fail when when it's valid.
Conversely, the verification can succeed by finding executables in the
build root that don't exist in the image root tree when it should be
failing.

When verifying user units, systemd expects runtime directories.

All of this makes it quite difficult to verify systemd units properly
when building an image.  The call is useful for making sure the unit is
structured properly, but the user unit verification setup is difficult
to accomplish in a general way while building.

Remove the systemd-analyze verify step from the stage.  Move it to the
unit test so that we have some assurance that our unit file structure is
correct and things work as expected.  Create referenced unit files and
commands to make the unit valid.
2024-04-18 17:20:57 +02:00
Achilleas Koutsou
86baf802d5 test/systemd_unit_create: Wants, Requires, After
Add test values for Wants, Requires, and After.
Adding multiple values to test that arrays work and made sure they're
all different.
The units need to be valid, real unit names otherwise the
'systemd-analyze verify' check will fail.
2024-04-18 17:20:57 +02:00
Achilleas Koutsou
d40948ce61 stage/systemd.unit.create: add After option
Support the After option in the Unit section of the unit file.
2024-04-18 17:20:57 +02:00
Michael Vogt
b47ac7f59f tools: fix error when releasever cannot be found
See https://github.com/osbuild/osbuild/pull/1724/files#diff-15816f60793fa39af2d7cbd2c9a78fb4b4a1867f2a60e915e21e1efa8662976eR447
2024-04-18 10:17:22 +02:00
Michael Vogt
1b33251919 Makefile: make sure that make test-all really runs all tests
The current `make test-all` will only run tests under `test/`. This
is no longer the only place we have tests so update the code to
just run `pytest` to collect all tests.
2024-04-18 08:35:05 +02:00
Michael Vogt
388e367392 stages: add support for --target-imgref to bootc install to-filesystem
We currently do not set the `--target-imgref` and do not allow to
override it. This means that on a fresh deploy it is set to an
incorrect value. This commit allows to set it via the
org.osbuild.bootc.install-to-filesystem stage.
2024-04-17 15:06:33 +02:00
Michael Vogt
2586a748fd testutil: skip tests for missing ThreadingHTTPServer in py36
Only py3.7+ has ThreadingHTTPServer and SimpleHTTPRequestHandler
that can take a directory argument. We could reimplement this
on py36 (easy for threading, harder for missing directory) but
instead this commit just skips tests that try to use a
ThreadingHTTPServer.

Remove once we no longer support py3.6.
2024-04-16 15:16:49 +02:00
Michael Vogt
d9a228d3e8 workflow: simplify unit test running in the GH workflow
Run only two jobs in the GH runner for the unittest. The `test_stage.py`
because it takes a very long time and needs to run in parallel and
all the other tests.

This split avoid that we forget to add new unittests to the matrix
as we did before (see e.g. https://github.com/osbuild/osbuild/pull/1731)
and it will also enable the tests in:
- sources/test
- inputs/tests
- mounts/test

to run.

This will reduce the "granularity" of the test output a bit, in the
GH runner we only see two unit test matrix jobs now. However that
should not be too bad because the non-stage tests are really quick
to run.
2024-04-16 15:16:49 +02:00
Michael Vogt
5d3dac9fb9 tox,workflow: pass tests to run via tox {posargs} instead of env
Using an environ for passing the tests is a bit of a headache when
it comes to quoting which is important when trying to write something
like: `-k "not test_stages.py"`.

I (personally) also find it slightly nicer/more intuitive to be able to do:
```
$ tox -e py36 -- ./test/mod
```
compared to
```
$ TEST_CATEGORY="./test/mod" tox -e py36
```
2024-04-16 15:16:49 +02:00
Michael Vogt
659f1f06f2 meta: automatically allow devices as input in the stages schemas
With the new `bootc install to-filesystem` support many stages
will need a devices/mount setup to bind mount the deployment root
from the bootc deployment root of the generated image. To make
this globally available just allow "devices/mounts" for all stages
in the schema validation.

Note that `mounts` is already globally allowed so this just adds
devices (this was added in `7e776a076` with ostree as the use-case).
Nothing will change for the filesystem stages that already define
"devices" in a more specialized way.
2024-04-16 08:04:43 +02:00
Tomáš Hozza
5b75592fef Stages/cloud-init: support additional datasources
Add "Ec2" and "None" datasources, which is needed for RHEL-7.9 EC2
images.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-04-16 07:50:09 +02:00
Achilleas Koutsou
9b3a157a91 tox: enable verbose output for pytest
This will list the test names and the reason for any skipped tests,
which can be useful for troubleshooting and tracing.
2024-04-16 07:38:18 +02:00