Commit graph

278 commits

Author SHA1 Message Date
Christian Kellner
7a6c2df910 stage: add module information about itself
Add a new `info` property that holds the `meta.ModuleInfo` info
for the stage. This gives each instance of a stage access to
meta (or class) information about it, i.e. its schema, docs but,
more importantly, also its name and path to the executable.
Thefore the `name` property is coverted into a transient property
which access the `name` member of `info`.
Change the `formats/v1` load mechanism to carry a new `index`
argument which is used to load the `ModuleInfo` for each stage.
Adapt all tests to load the info as well when creating stages.
2021-01-18 17:44:46 +01:00
Christian Kellner
698635171c pipeline: refactor args for add_stage
All tests and invocations of `add_stage` actually pass a valid
options dictionary. Thefore move the `options` args before
the `sources` arg and remove the default value (`None`).
2021-01-18 17:44:46 +01:00
Tomas Hozza
11ec9744be test: Add test data for org.osbuild.rhsm stage
Add necessary test data to test org.osbuild.rhsm stage.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-01-15 19:07:19 +01:00
Tomas Hozza
723176f063 test: Add python3-iniparse package to f32-build.mpp.json
Add the python3-iniparse package to f32-build.mpp.json, which is a dependency
of the new 'org.osbuild.rhsm' stage. This is needed in order to be able to
test the 'org.osbuild.rhsm' stage.

Regenerate affected manifests in test/data/manifest using 'make --always-make
test-data'.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-01-15 19:07:19 +01:00
Christian Kellner
262877091f osbuild: flatten the pipeline
Instead of having build pipelines nested within the pipeline it is
the build pipeline for, the nested structure is transferred into a
flat list of pipelines. As a result the recursion is gone and all
the pipelines and trees are build one after the other. This is now
possible since floating objects are kept alive by the store itself
and all trees that are being built are transparently via them.
The immediate result dictionary changed accordingly. To keep the
JSON output of osbuild the same, the result is now routed through
a format specific converter.
Additionally, the v1 format module gained a function to retrieve
the global tree_id and output_id. With the new models those global
ids will go away eventually and thus need to go through the format
specific code.
2021-01-15 13:20:31 +01:00
Christian Kellner
f38c48086e pipeline: run method takes store object not dir
Instead of passing the store directory to Pipeline.run, pass an
already initialized ObjectStore object. This binds the lifetime
of the store and its (temporary) objects to the run of osbuild
not the run of the pipeline.
This prepares re-using the stores with multiple (non-nested)
pipelines.
2021-01-15 13:20:31 +01:00
Christian Kellner
d25936a028 formats: describe now takes a manifest
Instead of a pipeline, describe now takes a Manifest instance.
The reason is that a manifest fully describes the build, which
includes the sources. Now that the describe function takes the
manifest, the sources can be included as well.
Adapt the tests to refelect that change.
2021-01-09 18:09:47 +01:00
Christian Kellner
945914b195 osbuild: introduce Manifest class
The 'Manifest' class represents what to build and the necessary
sources to do so. For now thus it is just a combination of the
pipeline the source options.
2021-01-09 18:09:47 +01:00
Christian Kellner
4ab52c3764 formats: move pipeline description here
The description of a pipeline is format dependent and thus needs
to be located at the specific format module.
Temporarily remove two tests; they should be added back to a format
specific test suit.
2021-01-09 18:09:47 +01:00
Christian Kellner
a13783f67b formats: load function takes combined manifest
Instead of having the pipeline and the source option as separate
arguments, the load function now takes the full manifest, which
has those two items combined.
2021-01-09 18:09:47 +01:00
Christian Kellner
0b6f36158d osbuild: use load function via the format module
Instead of importing the load, load_build functions into the osbuild
namespace and using it via that, use the load function via the module
that provides them, i.e. the formats.v1 module.
2021-01-09 18:09:47 +01:00
Christian Kellner
b65211a94d formats/v1: move validation logic here
The validation of the manifest descritpion is eo ipso format
specific and thus belongs into the format specific module.
Adapt all usages throughout the codebase to directly use the
version 1 specific function.
2021-01-09 18:09:47 +01:00
Christian Kellner
ea3dad17fc test/sources: skip if net namespace setup fails
Try to check if we can setup the net namespace and if that fails
skip the test.
2020-12-04 12:28:30 +01:00
Christian Kellner
83aa4a29df test/boot: skip unless we can bind mount
We need to be able to bind-mount in the boot tests, so skip all of
those if we can't (because we are not root).
2020-12-04 12:28:30 +01:00
Christian Kellner
18fc8aa85e test/stages: skip unless we can bind mount
We need to be able to bind-mount in the stages tests, so skip all
of those if we can't (because we are not root).
2020-12-04 12:28:30 +01:00
Christian Kellner
ef5875e1f4 test/assemblers: skip unless we can bind mount
We need to be able to bind-mount in the assembler tests, so skip
all of those if we can't (because we are not root).
2020-12-04 12:28:30 +01:00
Lars Karlitski
f7949d9993 test: add test for osbuild executable
Add two simple tests to check that the osbuild executable fails with the
right exit codes when passed an invalid manifest or checkpoint.

This reuses test.OSBuild, which is extended to raise CalledProcessError
if needed.
2020-10-27 22:04:09 +01:00
Christian Kellner
452e9ddb9e stages/rpm: include sigpgp, siggpg in metadata
Return the SIGPGP, SIGGPG fields, if available, in the packages
metadata. This is needed for the koji integration.
2020-10-22 22:47:22 +01:00
Christian Kellner
d7d84a8eb1 test/mod: use proper host runner
Instead of hard-coding the use of the "org.osbuild.linux" runner,
use the new `osbuild.pipeline.detect_host_runner` function to
dynamically detect the runner for the host system. That should fix
the tests on RHEL systems, where python3 is by default not present
and even if it is manually installed, is an indirection via
alternatives (i.e. a link to /etc/alternatives), which must be
explicitly configured in the build root container for the host.
2020-10-21 11:13:28 +02:00
Christian Kellner
25662fbfbc test/buildroot: more lenient output test checking
In `test_output`, require that the test string is found in the
output, not equal to the output. Other warnings or log messages
might be printed by the runner.
2020-10-21 11:13:28 +02:00
Christian Kellner
9ef642228f test: adapt 'libdir' argument for BuildRoot's ctor
As of commit 1e3c0ae "unified libdir handling", the libdir argument
for the BuildRoot constructor is not a keyword argument anymore.
Adapt the argument accordingly.
2020-10-21 11:13:28 +02:00
Lars Karlitski
88aed72933 test/run/test_stages: respect OSBUILD_TEST_STORE
This environment variable is already used in test_objecttore.py. It's
useful for quick iteration while testing locally.
2020-10-19 17:37:46 +01:00
Lars Karlitski
78c251d332 test/data/stages/zipl: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.

Changed a.json to not include a zipl stage with empty options. This
breaks the test, because the osbuild run of b.json is relying on a
checkpoint of the result of a.json. If that's not present, the rpm
database (and other generated files) are marked as differing, because
the whole pipeline is generated again. This might have worked before,
because the previous package list happened to be deterministic.
2020-10-19 17:37:46 +01:00
Lars Karlitski
ec07482040 test/data/stages/users: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
8acadfc23e test/data/stages/systemd: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
064dd5fee0 test/data/stages/rpm: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
6f8f623918 test/data/stages/timezone: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
147a6a29fb test/data/stages/locale: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
a4da6e0041 test/data/stages/keymap: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
7aa8500174 test/data/stages/kernel-cmdline: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.

Changed a.json to not include a kernel-cmdline stage with empty options.
This breaks the test, because the osbuild run of b.json is relying on a
checkpoint of the result of a.json. If that's not present, the rpm
database (and other generated files) are marked as differing, because
the whole pipeline is generated again. This might have worked before,
because the previous package list happened to be deterministic.
2020-10-19 17:37:46 +01:00
Lars Karlitski
c2cec04b7c test/data/stages/hostname: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
ac02b79222 test/data/stages/groups: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
3554575659 test/data/stages/fstab: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
8904398b50 test/data/stages/firewall: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
49d1c09653 test/data/stages/copy: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
abaa49b8ae test/data/stages/chrony: use mpp to generate manifests
Also, upgrade the test to fedora-32 from https://osbuild.org/rpmrepo.
2020-10-19 17:37:46 +01:00
Lars Karlitski
2066d0fb3b test: switch to rpmrepos' repository snapshots
These are more stable, and closer to where the tests are run (in the
same AWS region).

https://www.osbuild.org/rpmrepo/
2020-10-19 17:37:46 +01:00
Lars Karlitski
d9ef44eb6d test: rename mpp-*.json to *.mpp.json
This simplifies the `test-data` rules in `Makefile` considerably. Also,
it allows adding `*.mpp.json` files in other directories without needing
to copy rules. (make's pattern-based rules only allow a single `%`).

Adjust test/data/README.md accordingly.
2020-10-19 17:37:46 +01:00
Christian Kellner
3318480460 test/stages: re-use downloaded files between runs
Create a cache directory with the scope of the stage test suit and
after each test is run cache the downloaded files for the `files`
source via the new `OSBuild.copy_source_data` method. Initialize
OSBuild with that cache directory, so previously downloaded files
get used between different stage tests.
2020-10-09 15:32:31 +02:00
Christian Kellner
9e5e179128 test: add method to copy source data from cache
Add a new method that will copy the downloaded data for a specified
source to a directory, creating a directory structure so that the
target directory can then be used to initialize the osbuild cache,
i.e. the target directory be used for the `cache_from` parameter in
the `test.OSBuild` constructor.
The main reason why this is done per source, and not for all sources,
is that not all source can be copied via a plain `cp` operation or
easily added to, in case that the `target` directory already contains
data. The `org.osbuild.ostree` source is such an example.
2020-10-09 15:32:31 +02:00
Christian Kellner
71f7bf8930 test/api: assert return code for api.exception
Check that the exit code for `api.exception`, called via the
`api.exception_handler` helper, is the correct one.
2020-10-09 10:47:44 +02:00
Christian Kellner
aaa51e22a6 api: properly serialize the exception's traceback
Use `traceback.print_tb()` to serialize the exceptions' backtrace.
The previously used expression `str(e.__traceback__)` will just
give `<traceback object at 0x…>`, which is not very helpful.
Add a test to check that the method name that raises the exception,
also called `exception`, is in the traceback.
2020-10-09 10:47:44 +02:00
Christian Kellner
7a112c27cb test/api: fix white-space error
No double space between class methods, so say the scriptures.
2020-10-09 10:47:44 +02:00
Christian Kellner
f8de164413 api: properly encode exception type
When using `str(type(exception))` this ends up to be something like
`<class 'ValueError'>` for a `ValueError` exception. Get the vanilla
name of the exception type via `type(exception).__name__`.
Add a test to ensure that we encode this properly.
2020-10-09 10:47:44 +02:00
Christian Kellner
f5d00dd043 api: use more generic error member for exceptions
Rename the `API.exception` member to `API.error`, to make it more
generic, so it can also be used for other sort of errors in the
future. Also add a layer of additional structure with `type` and
`data` members so different types of errors apart. Currently only
`exception` is used.
Adapt the tests in test/mod/test_api.py to check for the new
structure and its content.
2020-10-09 10:47:44 +02:00
Christian Kellner
17fbe41b03 test/api: check api.exception exits the process
The `api.exception` method, which is internally also used by
`api.exception_handler` helper, calls `sys.exit` and this no
statement after a call to either method should be reached.
Add an assertion to make sure of that.
2020-10-09 10:47:44 +02:00
Christian Kellner
cbcb335b3e osbuild: fix spelling mistakes found by codespell
Run codespell on the source ('codespell -f -L msdos -S coverity
-S rpmbuild -S samples') and fix all uncovered mistakes.
2020-10-06 14:41:00 +02:00
Chloe Kaubisch
5dc5ddcf29 api: add exception endpoint
Create a new api endpoint called exception, that communicates
exception backtraces separately back to osbuild, as opposed to
dumping them into the normal log. Additionally, add a corresponding
test to check that a call to api.exception correctly sets
API.exception.
2020-10-02 17:49:45 +02:00
chloenayon
01aae91949 api: remove setup_stdio
API.setup_stdio was replaced in PRs 506 and 507,
remove setup_stdio functions and call sites.
2020-09-09 12:52:50 +02:00
Christian Kellner
fc0c75f40e test/api: race-free api.metadata access
Access metadata.api only after `api` has exited the context and
thus the event loop has stopped and all incoming messages, like
the one setting the metadata, have been processed.
See commit 803433fb62 for a lecture
about the internals and all the details involved.
2020-08-31 15:06:36 +02:00