Commit graph

3289 commits

Author SHA1 Message Date
Tomáš Hozza
90b7de2ad5 test_depsolve.py: allow depsolve command to fail gracefully
Modify the function that executes the depsolve command, so that does not
produce exception in case the command fails. Instead, return the message
returned by `osbuild-depsolve-dnf` and the exit code. This will allow to
test also other scenarios (such as depsolve errors) in the test case.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-08 09:58:41 +02:00
Tomáš Hozza
f9ddab52f5 Update testing c9s BaseOS repodata snapshot
Use the latest c9s BaseOS repodata snapshot, specifically so that it
contains multiple versions of the same packages. This will allow to test
the `osbuild-depsolve-dnf` 'search' command. The previous metadata
contained only single version of each package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-08 09:58:41 +02:00
Tomáš Hozza
ffd261bfff test_dnf4_mark(): disable all plugins when inspecting markings
When subscription-manager DNF plugins are enabled (e.g. on RHEL), they
produce messages to the stdout on any DNF command execution. E.g.
"Updating Subscription Management repositories.".

Disable all plugins when inspecting package markings so prevent them
from modifying the output.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-08 09:51:37 +02:00
Michael Vogt
3a74916655 Makefile: run tox parallel without the spinner
The spinner is mostly distracting IMHO and it makes the CI logs
harder to read as it generates several dozens of lines like:
```
...
⠋ [3/5] pylint | autopep8 | mypy-strict
...
```

I was considering to make it conditional on GH but decided to
just disable globally. If someone feels attached to the spinner
I only disable it in GH.
2024-08-07 17:27:35 +02:00
Michael Vogt
ae72480612 solver: include "solver" key in the dnfjson reply
This commit includes the used sovler in the dnfjson reply. This
is mostly information (e.g. in service logs) but also useful in
tests to ensure that the expected solver was really run.

Note that this needs https://github.com/osbuild/images/pull/723
first.
2024-08-06 21:34:04 +02:00
Paweł Poławski
b516bdca93 Tests: Add unit tests for org.osbuild.gunzip stage 2024-08-02 08:48:06 +02:00
Tomáš Hozza
12f81e053b Test/dnf4.mark: adjust the test for markings used by DNF5
When I rolled back from using 'dnf4', to check package markings, to
using 'dnf', I didn't verify the test case on Fedora Rawhide with DNF5.
It turns out that the strings reported by DNF5 differ and make the test
case fail. This time I tested the change on Fedora Rawhide with DNF5 and
it works.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-01 10:58:58 +02:00
Brian C. Lane
0bbdabfcca tests: Add f41 and update terraform hash 2024-08-01 08:57:30 +02:00
Brian C. Lane
d30fca16c6 spec: Use dnf >= 5.2.1 on Fedora 41 and later 2024-08-01 08:57:30 +02:00
Brian C. Lane
3a22fcbd3f mypy: Ignore missing dnf, hawkey, and libdnf5 imports 2024-08-01 08:57:30 +02:00
Brian C. Lane
857507ecd6 test: Update the depsolve test
Test with no config file (libdnf), with use_dnf5 set to false, and with
it set to true. Make sure the correct dnf library was used.
2024-08-01 08:57:30 +02:00
Brian C. Lane
f17ab5cbaf osbuild-depsolve-dnf: refactor into osbuild.solver module
This moves the dnf and dnf5 code into a new osbuild module called
solver. The dnf specific code is in dnf.py and dnf5 is in dnf5.py

At runtime the osbuild-depsolve-dnf script reads a config file from
/usr/lib/osbuild/solver.json and imports the selected solver. This
currently just contains a 'use_dnf5' bool but can be extended to support
other configuration options or depsolvers.

At build time a config file is selected from tools/solver-dnf.json or
tools/solver-dnf5.json and installed. Currently dnf5 is not installed,
it will be added when dnf5 5.2.1.0 becomes available in rawhide (Fedora
41).

The error messages have been normalized since the top level functions in
osbuild-depsolve-dnf do not know which version of dnf is being used.
2024-08-01 08:57:30 +02:00
Michael Vogt
7b16313ce2 main,monitor: fix total steps in progress reporting
The existing code to record progress was a bit too naive. Instead
of just counting the number os pipelines in a manifest to get the
total steps we need to look at the resolved pipelines.

with this fix `bib` will report the correct number of steps left
when doing e.g. a qcow2 image build. Right now the number of
steps is incorrect because the osbuild manifest contains pipelines
for qcow2,vdmk,raw,ami and all are currently considered steps
that need to be completed. With this commit this is fixed.
2024-07-31 23:00:33 +02:00
schutzbot
89b3221b2c Post release version bump
[skip ci]
2024-07-31 08:15:39 +00:00
Michael Vogt
46db834dee sources(curl): use json like output inside of custom record
When using `--write-out` we are not using %{json} because older curl
(7.76) will write {"http_connect":000} which python cannot parse.

So we had a custom `--write-out` with `\1xc` as "record" separators
between the fields. This is a bit old-school and not very extensible
so Achilleas had the idea to still use json but "define" our own
subset via the variables that curl provides. This commit does that.
2024-07-30 11:12:03 +02:00
Michael Vogt
e535877798 test: add new https_serve_directory() and test certs
This commit adds a new `https_serve_directory()` test helper
and some custom self-signed and worthless certs that are used
during testing. They are not dynamically generated to avoid the
extra compuation time during tests (but they could be).

Generated via:
```
$ openssl req -new -newkey rsa:2048  -nodes -x509  \
   -subj "/C=DE/ST=Berlin/L=Berlin/O=Org/CN=localhost"   \
   -keyout "key1.pem" -out "cert1.pem"
```

This will allow us to test `https` download URLs as well in e.g.
the curl source.
2024-07-29 16:51:48 +02:00
Tomáš Hozza
52200c581d Test/dnf4.mark: make failures to parse dnf output easier to debug
The test case still fails on RHEL-10.0 Beta, even when not using dnf5,
with:

```
            for line in r.stdout.splitlines():
>               package, mark = line.strip().split(",")
E               ValueError: not enough values to unpack (expected 2, got 1)
```

Make debugging of failures like this easier by printing the line when
the issue happens.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-29 15:01:13 +02:00
Tomáš Hozza
a8f3a1e834 Test/dnf4.mark: make the test compatible with all dnf versions
Let's revert to using plain 'dnf', add an explicit newline in the query
format and skip empty lines when processing the output. This makes the
test case compatible with all DNF versions, even with dnf5 once this
issue gets fixed.

The previous approach didn't work on c9s / el9, because there is no
'/usr/bin/dnf4 -> dnf-3' symlink.

Also see:
https://github.com/osbuild/osbuild/actions/runs/10136827918/job/28026181824

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-29 15:01:13 +02:00
Tomáš Hozza
4edbe227d4 Test: fix dnf4.mark stage test with DNF5
DNF5 contains a breaking change in the repoquery --qf output,
specifically it does not include the trailing newline. This breaks the
test case e.g. on the latest Fedora Rawhide [1].

As a fix, explicitly use 'dnf4' for now, until the inconsistency is
fixed in the upstream [2].

[1] https://artifacts.dev.testing-farm.io/3a3a2898-0a6a-42eb-8792-660f03c35c3c/
[2] https://github.com/rpm-software-management/dnf5/issues/709

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-25 12:23:53 +02:00
Gianluca Zuccarelli
3fa8ab8cbc stages/autotailor: fix stage schema
There was a small mistake in the schema since either one of
`new_profile` or `tailored_profile_id` is required. This commit fixes
this and updates the tests to check for this case.
2024-07-25 11:56:07 +02:00
Tomáš Hozza
5bf252a2c1 Test/manifests: start testing on el10.0-nightly
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-24 12:24:43 +02:00
Tomáš Hozza
1c086fd328 Test/manifests: start testing on c10s
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-24 12:24:43 +02:00
Roberto Majadas
ac7379488c mpp: Allow container-storage image resolution
This commit allows to the user to define the "container-transport"
variable when they are defining a container image to be resolved by the
osbuild-mpp tool. When the user defines the "container-storage" as
"container-transport" osbuild-mpp will look for the image in the local
container-storage.

Signed-off-by: Roberto Majadas <rmajadas@redhat.com>
2024-07-23 16:01:33 +02:00
Tomáš Hozza
df83c62920 Mockbuild: workaround a SELinux policy issue on c10s.
SELinux policy forbids systemd-machined from creating a varlink socket,
which it does since v256. This makes it fail to start. Subsequently,
mock fails to build the RPM, because it uses systemd-nspawn as an
isolation and it fails to register the machine with systemd-machined.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-19 09:27:30 +02:00
Tomáš Hozza
dcc08d8bd4 CI: build RPMs for RHEL-10.0-nightly
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-19 09:27:30 +02:00
Tomáš Hozza
71c01da734 Schutzfile: add el10.0 repo snapshots
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-19 09:27:30 +02:00
Tomáš Hozza
3959de8a19 mockbuild.sh: temporarily base missing el10 mock template on el9
There is no RHEL-10 mock template yet. Let's base it on RHEL-9 template
with a few tweaks.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-19 09:27:30 +02:00
Gianluca Zuccarelli
cca6668b42 test/oscap.autotailor: json profile id shadowing 2024-07-17 13:14:48 +02:00
Gianluca Zuccarelli
a87b1ba852 test/oscap: autotailor json schema validation
Add basic schema validation unit test for the JSON autotailor options.
2024-07-17 13:14:48 +02:00
Gianluca Zuccarelli
92bb161501 stages/oscap.autotailor: make profile id required
According to `autotailor(8)` arguments passed in via the cli take
precedence over the JSON tailoring file contents.

Make the `new_profile` a required field for the json tailoring too and
pass it as an option to the `autotailor` command. This approach has some
trade-offs. It allows us to maintain the explicitness of the manifest
that is consumed by `osbuild`. The downside is that it will override the
profile id that is set by the user in the JSON tailoring file.
2024-07-17 13:14:48 +02:00
Gianluca Zuccarelli
2a28acbc85 stages/oscap.autotailor: rename new_profile
Rename the `new_profile` option to `tailoring_profile_id` for clarity.
This also ensures that the change is backwards compatible by falling
back to the `new_profile` option if that was set instead of the
`tailoring_profile` id option.
2024-07-17 13:14:48 +02:00
Michael Vogt
16667ef260 sources(curl): error if curl exists 0 but there are downloads left
As part of the investigation of the CI failure in
https://github.com/osbuild/osbuild-composer/pull/4247
we noticed that curl can return a return_code of `0` even
when it did not downloaded all the urls in a `--config` provided
file. This seems to be curl version dependent, I had a hard
time writing a test-case with the real curl (8.6.0) that
reproduces this so I went with mocking it. We definietly saw
this failure with the centos 9 version (7.76).

Our current code is buggy and assumes that the exit status
of curl is always non-zero if any download fails but that is
only the case when `--fail-early` is used.

The extra paranoia will not hurt even when relying on the
exit code of curl is fixed.
2024-07-17 11:39:35 +02:00
schutzbot
2b2fec85b2 Post release version bump
[skip ci]
2024-07-17 08:16:09 +00:00
Alexander Todorov
33fda9ba50 Update centos-stream-10 repo snapshots to 20240701 2024-07-16 11:30:13 +02:00
Alexander Todorov
207648549c There is no EPEL for EL10 yet so use a custom repository 2024-07-16 11:30:13 +02:00
Alexander Todorov
60d4f56b54 Use CentOS-Stream-10-20240703.2 runner images 2024-07-16 11:30:13 +02:00
Alexander Todorov
3bbf05243c Start building RPMs on CentOS Stream 10 for testing
Related: COMPOSER-2226
2024-07-16 11:30:13 +02:00
Tomáš Hozza
143677f5d9 Tests: force checkout manifest-db
Manifest tests on Fedora 39 sometimes fail, because checking out the
specific manifest-db commit fails with:

"error: The following untracked working tree files would be
overwritten by checkout"

Use --force when checking out the ref, which will hopefully solve any
error like this.

[1] https://gitlab.com/redhat/services/products/image-builder/ci/osbuild/-/jobs/7317097983

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-15 11:06:10 +02:00
Gianluca Zuccarelli
24c26e7787 stages/oscap.remediation: small import adjustment
This is a small adjustment to how the `osbuild.util.mnt.mount` fuction
is imported. While adding unit tests, the tests failed when trying to
patch the function, this commit fixes the issue.
2024-07-11 12:26:13 +02:00
Gianluca Zuccarelli
a1beb4d295 stages/oscap.remediation: setup env helper
Add a small helper function to setup the mountpoints and symlink for the
stage. This will help in making the stage easier to test.
2024-07-11 12:26:13 +02:00
Michael Vogt
9bef57d5a6 sources(curl): disable curl --parallel by default
Disable `curl --parallel` by default until the failure in
https://github.com/osbuild/osbuild-composer/pull/4247

is fully understood. It can be enabled via the environment:
```
OSBUILD_SOURCES_CURL_USE_PARALLEL=1
```
in the osbuild-composer test.
2024-07-08 18:00:59 +02:00
Michael Vogt
4697a3fb84 sources: do not use %{json} when generating curl output
We cannot use `curl --write-out %{json}` because older curl
(7.76 from RHEL9/Centos9) will write `{"http_connect":000}`
which python cannot parse.
2024-07-04 11:53:40 +02:00
Michael Vogt
018c15aae8 sources: run all tests for curl with both old and new curl
To ensure there are no regressions with the old curl make
sure to run all tests that fetch_all() with both old and
new curl.
2024-07-04 11:53:40 +02:00
Michael Vogt
0d3a153c78 sources: add new _fetch_all_new_curl() helper
When using a modern curl we can download download multiple urls
in parallel which avoids connection setup overhead and is generally
more efficient. Use when it's detected.

TODO: ensure both old and new curl are tested automatically via
the testsuite.
2024-07-04 11:53:40 +02:00
Michael Vogt
974c8adff9 source: add helper to detect if curl parallel download is available
Modern curl (7.68+) has a --parallel option that will download
multiple sources in parallel. This commit adds detection for this
feature as it is only available after RHEL 8.

In addition we need some more feature to properly support --parallel,
i.e. `--write-out` with json and exitcode options. This bumps the
requirements to 7.75+ which is still fine, centos9/RHEL9 have
7.76.
2024-07-04 11:53:40 +02:00
Michael Vogt
d20713d7af curl: add gen_curl_download_config() and use in download
Instead of passing the url and options on the commandline this
commit moves it into a config file. This is not useful just yet
but it will be once we download multiple urls per curl instance.
2024-07-04 11:53:40 +02:00
Nikita Dubrovskii
cb978d3c72 stages: add stage for creating dm-verity partitions
Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
2024-07-03 16:54:32 +02:00
schutzbot
8507b32a87 Post release version bump
[skip ci]
2024-07-03 08:16:19 +00:00
Sanne Raymaekers
2e5a9335c9 sources/curl: use --user-agent option to set the user-agent
Setting the user-agent using `--header` is broken in combination with
`--location`, `--proxy`, and an https endpoint which redirects. The
user-agent sent to the proxy changes after the client is redirected,
tripping up proxies.

For more information see https://issues.redhat.com/browse/RHEL-45364
2024-07-02 16:15:56 +02:00
Tomáš Hozza
8db6b8985a schutzbot/mockbuild.sh: let mock bootstrap chroot
Don't instruct mock to not bootstrap the chroot. This is making builds
to fail on F40 due to DNF5. The error message suggests to bootstrap
chroot.

Example:
https://gitlab.com/redhat/services/products/image-builder/ci/osbuild/-/jobs/7239614060#L1363

Note that e.g. osbuild-composer does not specify the
--no-bootstrap-chroot option either.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-07-02 09:46:45 +02:00