Commit graph

335 commits

Author SHA1 Message Date
Christian Kellner
e97285e00a test/sources: add checks for org.osbuild.ostree
Add basic checks for the ostree source, which includes a successful
pull of a commit, an empty source entry and one where the specified
commit is non-existant. For this create a simple commit in a ostree
repo is checked in. The commit was created via:

  mkdir "/tmp/data"
  echo "Hello World" > /tmp/data/hello.txt
  ostree init --repo test/data/sources/org.osbuild.ostree/data/repo \
              --mode=archive

  ostree commit --repo test/data/sources/org.osbuild.ostree/data/ \
                --branch "test/ostree" /tmp/data \
                --timestamp="1995-05-13 12:34:56 +0000"
This should give an commit with the following commit id:
  d6243b0d0ca3dc2aaef2e0eb3e9f1f4836512c2921007f124b285f7c466464d8
2021-04-29 12:58:01 +02:00
Christian Kellner
92fad13dbf test/sources: tmpdir as fixture
Instead of creating the temporaroy directory within the unit test,
provide it to the test via a test fixture.
2021-04-29 12:58:01 +02:00
Christian Kellner
fd21da3aa6 test/sources: use pytest.mark.parameterize
Parameterize `test_sources` via `pytest.mark.parameterize`, so that
now the product of source and test cases for that source is visible
to pytest and thus also the caller.
2021-04-29 12:58:01 +02:00
Christian Kellner
7a48c3b734 test/sources: check Source.download
Instead of testing the legacy `SourcesServer` and `sources.get`,
test the `Source.download` method, which is the new and exclusive
way how sources are used in osbuild. For this, the complete info
for a specific source is now included the specific test case.
For the `org.osbuild.curl` source this means that the respective
information is moved from `sources.json`, which is then unused
and thus removed. The test case that checks for an unknown
checksum is also removed because `Source.download` just fetches
everything instead of a subset.
2021-04-29 12:58:01 +02:00
Christian Kellner
3c66d1e4f5 test/sources: convert to pytest
Use `pytest`, which is a dependency of osbuild since a few versions,
instead of `unittest` for the source tests. The main reason is to be
able to use `pytest.mark.parameterize` in the near future to easily
generate a test matrix.
2021-04-29 12:58:01 +02:00
Christian Kellner
1329fc2ca7 stages/rpm: sort packages metadata
In order to have a more stable package metadata representation,
sort the generated metadata by name. Adapt the tests' metadata
file to reflect that change.
2021-03-17 00:32:53 +00:00
Christian Kellner
b4f58ccc72 tests/stages: write out produced metadata
When the expected metadata does not match the produced metadata,
write the latter to `/tmp` for closer inspection; additionally
this should help update the metadata file in case the changes
are expected.
2021-03-17 00:32:53 +00:00
Christian Kellner
c616afa87e test: dynamically generate stage test_stages
This is a partial revert of commit d584a1e, which converted the
dynamically generate stage tests to sub tests. The problem with
the latter is that they can't be individually run, which makes
testing changes to specific stages cumbersome to develop.
Therefore switch back to a model where the stage tests are
dynamically generated via a class decorator.
2021-03-11 12:46:24 +00:00
Christian Kellner
428a9fd58c test/stages: checks for org.osbuild.resolv-conf
Implement a new stage test that checks that the new resolv-conf
stage works as expected.
2021-03-11 12:46:24 +00:00
Christian Kellner
eb6461c165 test/fmt_v1: check result is complete
In the output test, check that for a successful pipeline run all
the elements are present: main result, assembler result, stage
result.
NB: Build result is hard to test because we would need to actually
build a valid build root.
2021-03-09 21:40:47 +00:00
Christian Kellner
74e6302860 test/fmt_v1: check assembler failures propagate
Check that if an assembler fails the result is propagated to the
overall result status, i.e. the main `success` is also `False`.
2021-03-09 21:40:47 +00:00
Ondřej Budai
555b5d0f2b schutzbot/deploy: remove the RHEL 8.3 Beta workaround
These days are long gone, we no longer test osbuild against development RHEL
versions. This is covered by osbuild-composer's test suite.
2021-03-07 12:50:06 +00:00
Christian Kellner
4a7efa087e test/ostree: add installer test
Extend the current ostree container test case to use the new
bootiso manifest to build a bootable iso. This is done in the
existing container test case in order to share the build root
and ostree commit results and speed up testing. In the future,
the test infrastructure should be extended so that the cache
can be optionally shared between test cases.
2021-02-19 14:42:32 +00:00
Christian Kellner
283f8d0de8 test/data: add ostree based boot iso manifest
This new manifests creates an boot iso which contains an ostree
commit that is build in the same manifest. The boot iso can then
be installed via the ISO.
2021-02-19 14:42:32 +00:00
Christian Kellner
e1f1f64cf1 test/data: add iso tools to v2 build root
Add the necessary tools to build boot isos to the build root.
Most notably the lorax templates, bootloader as well as iso
creation tools.
2021-02-19 14:42:32 +00:00
Christian Kellner
1a19e48ae6 test/util_lorax: add basic checks
Add checks for the lorax utility methods, like rendering a template
and executing the basic set of commands.
2021-02-19 14:42:32 +00:00
Christian Kellner
7a503100c8 test/data: set saved_entry in boot manifest
This is to test the functionality of the new `saved_entry` grub2
config file. Ideally an integration test would install a new non-
default kernel and check that it does not get selected. Something
for the future.
2021-02-19 14:41:26 +00:00
Christian Kellner
8ad2eef13f test/initrd: remove unneeded f-string
No interpolation was done via this f-string, remove it.
2021-02-16 22:58:15 +00:00
Christian Kellner
d4ebbb821a stages/oci-archive: support additional layers
In addition to the required base layer, provided via the the input
of the same name, the oci-archive stage now accepts up to nine
additional layers that get added on top of each other, sorted in
ascending order, i.e. `layer.1` to `layer.9`.

Adapt the `fedora-ostree-container` example manifest so that the
ostree commit is now in a separate layer, which makes it possible
to share the base layer between different commits container.
2021-02-16 22:58:15 +00:00
Christian Kellner
47c15e5b41 test: add basic dracut test
Add a new basic test for the dracut stage. It uses a osbuild
pipeline to build an initrd and inspects it via the initrd.py
module. The content is compared to a reference located in the
same directory as the pipeline (test/data/stages/dracut/).
2021-02-14 00:01:24 +00:00
Christian Kellner
0fdbfa3c93 test: add initrd module to inspec initrds
Add a new module that contains a utilities to inspect an initrd.
It contains a `Initrd` class that loads a given initrd and can
then be used get the list of files via Initrd.filelist, the dracut
modules via `Initrd.modules` and the kernel modules via the
`Initrd.kmods` properties. Another top level function `read_initrd`
returns a dict that contains the name of the initrd as key and as
value another dictionary with `modules`, `kmods` as well as the
`compression` & `early_cpio` metadata.
The initrd.py can also use as a script that will print the dict
from `read_initrd` as JSON.
The implementation is a heavily based on dracut's `lsinitrd` bash
script and additionally contains a python port of the skipcpio.c
utility.
2021-02-14 00:01:24 +00:00
Christian Kellner
965b4e94ee test/data: don't install docs in containers
Change the test manifests that use containers to not include
docs when installing. Also don't install docs in the build root
for those manifests. Since the fedora-ostree-container.mpp is
being built in CI, this also tests that the new option.
2021-02-12 19:27:25 +01:00
Christian Kellner
81c8374d3e sources: rename org.osbuild.{files -> curl}
The `org.osbuild.files` source provides files, but might in the
future not be the only one that does. Therefore rename it to
match the internal tool that is being used to fetch the files.
This is done for most other osbuild modules that target tools.

The format v1 loader is adapted to make this change transparent
for users of the v1 format, so we are backwards compatible.

Change the MPP depsolve preprocessor so that for format v2 based
manifest `org.osbuild.curl` source is used. Also rename the
corresponding source test. Adapt the format v2 mod test to use
the curl source.
2021-02-12 19:27:08 +01:00
Christian Kellner
36129c164b test: start a new ostree integration test suite
Add a v2 manifest to builds an ostree commit, then builds a small
container with a webserver and puts that commit into it.
Start a new test suit where this manifest is built and then checked
that the artifact exists. In the future the artifact should also be
inspected and run by a container engine and the commit be pulled
via ostree.
2021-02-12 15:55:43 +01:00
Christian Kellner
95811c1c0d test/fmt_v2: add an sample input to the manifest
Add a sample input to the basic test manifest so we check schema
validation, loading and describing of inputs.
2021-02-12 15:55:43 +01:00
Christian Kellner
36f195fe6b test/fmt_v2: check for describe
Add a basic check to verify that loading and then describing the
pipeline results in the same description that was put in. This
test is esp. valuable because it checks the runner mapping and
name, id mappings.
2021-02-12 15:55:43 +01:00
Christian Kellner
994c59a06c test/fmt_v2: add validation testing
Add a new test to check that validation works for the basic test
pipeline. This needs to be extended in the future to check that
invalid data is being caught properly, but it is a start.
2021-02-12 15:55:43 +01:00
Christian Kellner
6ab52d50b0 test: add support for export command line argument
Add support for `--export` in `OSBuild.{compile, compile_file}`.
2021-02-12 15:55:43 +01:00
Christian Kellner
5b2783be53 test/noop: add format version 2 noop test
Add a simple noop pipeline, with a noop stage and a noop input,
which all in all does nothing much; but it will validate, load
exectue the pipeline, stage and inputs. So maybe not really
"nothing" in the strictest sense.
2021-02-12 15:55:43 +01:00
Christian Kellner
a065df5654 test/fmt_v2: add simple v2 format test
Check that module info and basic loading is working for format
version 2.
2021-02-12 15:55:43 +01:00
Christian Kellner
b6e42d8b25 test/data: add container example (format v2)
Add an example that builds a small container, based on the minimal
container fedora kickstart (see [1, 2]). There is a deviation
because osbuild currently does not support removing
random files like it is done in [2].
The build pipeline "build" in f32-build-v2.json) is a port of the
existing build pipeline in f32-build.json.

This manifest is currently not used in any automated tests (yet),
but is there as a showcase for the new format. It does however
test the format version 2 support for mpp, since that is called
in CI.

[1] https://pagure.io/fedora-kickstarts/blob/main/f/fedora-container-common.ks
[2] https://pagure.io/fedora-kickstarts/blob/main/f/fedora-container-base-minimal.ks
2021-02-12 15:55:43 +01:00
Christian Kellner
24f6ed471d test/osbuild: check version 1 and 2 schemata
Iterate through all modules and check they have valid schema
information for format version 1 and 2.
2021-02-12 15:55:43 +01:00
Christian Kellner
5008b7703f meta: ModuleInfo.{schema -> get_schema()}
Change the `ModuleInfo.schema` propertly into a `get_schema`
method call. This is in preparation to allow for different
schemata versions to be supported.
2021-02-12 15:55:43 +01:00
Christian Kellner
749f59cc9a buildroot: make var a positional argument
Commit d028ea5b16 introduced bug when introducing the `store`
argument to `Stage.run`, instead of passing `var=var`, i.e.
`var` is being passed as keyword argument, it is now being
passed as a positional one. Since the `path=/run/osbuild`
keyword argument comes before the `var=/var/tmp` argument,
`var` is now being passed as `path` instead of var.
Since `var` is always being passed in throughout the entire
codebase, make it a positional argument, and move it before
`path`.
Adapt the tests to pass `var` as positional argument.
2021-02-11 23:49:18 +01:00
Christian Kellner
598cfd0d76 test/fmt_v1: add format info checks
Add basic checks to make sure the format version 1 is detected
for manifest of version 1.
2021-02-09 13:08:24 +01:00
Christian Kellner
0256396270 osbuild: convert rpm stage to use inputs
Convert the `org.osbuild.rpm` stage to use inputs instead of
sources. When loading v1 formats the input is generated from
the stage options.
2021-02-06 12:04:30 +01:00
Christian Kellner
f450338809 test/fmt_v1: schema validate the basic manifest
Incldue the basic test manifest in the schema validation test.
2021-02-06 12:04:30 +01:00
Christian Kellner
d3e85fe6a4 test/fmt_v1: use noop stages in test manifest
Instead of using `org.osbuild.test` stages, so `org.osbuild.noop`
stages so that the options we pass are actually valid and we can
use the manifest in schema validation checking.
2021-02-06 12:04:30 +01:00
Christian Kellner
ae1a1a140e test/fmt_v1: add sources to test manifest
Include two samples sources in the test manifest so that those
will be checked in the various tests as well.
2021-02-06 12:04:30 +01:00
Christian Kellner
12c9173faf manifest: use newly introduced Source class
Add a new `add_source` method that will add an individual `Source`
to a `Manifest` give its `ModuleInfo` and options. The dictionary
of source options in the manifest is replaced with a list of such
`Sources` and `add_source` will append to it. Adap the version 1
format code to use `add_source` and reconstruct the source options
from the list of source on `describe`.
Remove the `sources_options` constructor parameter for `Manifest`
and adapt all the source base for this.
2021-02-06 12:04:30 +01:00
Christian Kellner
5a6a53714a stages/copy: remove the stage
The stage was structured in a way so that it supports many different
inputs, like, `archive` and in the future maybe trees, git checkouts.
This does not fit very well into the new input model, where instead
seperate `copy.tree` and `copy.files` stages might make more sense.
Since the stage is not been used anywhere, and mainly got added
as a way to get the ignition dracut module via an archive of a git
repo, remove the stage for now. A replacement will be brought back
in the future.
2021-02-04 16:13:40 +00:00
Jacob Kozol
b77ba2c5f6 stages: add org.osbuild.sysconfig stage
The sysconfig directory contains a variety of system configuration files. The
values found in each of the configuration files may need to be specified
before first boot.

Currently, only the kernel and network configs can be modified and will
override existing files.
2021-01-27 17:39:54 +01:00
Christian Kellner
89c3df8de4 test/assembler: verify the tar'ed content
In the test case for the tar assembler, actually verify the
content by un-tar-ing the result again and comparing it to
the tree. This would have spotted missing SELinux labels.
2021-01-26 12:09:23 +01:00
Christian Kellner
53e9ec850b osbuild: assemblers are pipelines now
Convert the assembler phase of the main pipeline in the old format
into a new Pipeline that as the assembler as a stage, where the
input of that stage is the main pipeline. This removes the need of
having "assemblers" as special concepts and thus the corresponding
code in `Pipeline` is removed. The new assembler pipeline is marked
as exported, but the pipeline that builds the tree is not anymore.
Adapt the `describe` and `output` functions of the `v1` format to
handle the assembler pipeline. Also change the tests accordingly.

NB: The id reported for the assembler via `--inspect` and the result
will change as a result of this, since the assembler stage is now
the first and only stage of a new pipeline and thus has no base
anymore.
2021-01-22 15:03:19 +01:00
Christian Kellner
289d943d94 test/fmt_v1: checks for nested build pipelines
Add a level of nesting for build pipelines, which will test the
loading but also the output and results for nested build pipelines
in the old format.
2021-01-22 15:03:19 +01:00
Christian Kellner
949f63d760 test/osbuild: basic checks for manifest
Build a simple pipeline and check that the order of the pipelines
is correct and all the accessor methods and iteration is working
as expected.
2021-01-22 15:03:19 +01:00
Christian Kellner
569345cc72 pipeline: identify pipelines by name
Every pipeline that gets added to the `Manifest` now need to have
a unique name by which it can be identified. The version 1 format
loader is changed so that the main pipeline that builds the tree
is always called `tree`. The build pipeline for it will be called
`build` and further recursive build pipelines `build-build`, where
the number of repetitions of `build` corresponds to their level of
nesting. An assembler, if it exists, will be added as `assembler`.
The `Manifest.__getitem__` helper is changed so it will first try
to access pipeline via its name and then fall back to an id based
search. NB: in the degenrate case of multiple pipelines that have
exactly the same `id`, i.e. same stages, with the same options and
same build pipeline, only the first one will be return; but only
the first one here will be built as well, so this is in practice
not a problem.
The formatter uses this helper to get the tree pipeline  via its
name wherever it is needed.
This also adds an `__iter__` method `Manifest` to ease iterating
over just the pipeline values, a la `for pipeline in manifet`.
2021-01-22 15:03:19 +01:00
Christian Kellner
c923457683 test/fmt_v1: checks for result formatting
Build two some simple pipelines and check that the formatted result
is as expected.
2021-01-20 21:27:17 +01:00
Christian Kellner
105670e3f9 test/fmt_v1: rework description test
The current description test took a hand crafted Manifest. Since
the internal `Manifest` representation and the format (version 1)
representation are becoming more and more different, it might
soon not be possible to go from `Manifest` to the format specific
description unless it was previously loaded and thus an internal
mapping table can aid the serialization. Thus the description
test is re-worked to load a manifest and then describe it and
compare that the result is the same.
Also rename the test from `test_pipeline` to `test_describe`
as this is a better description of the test.
2021-01-20 21:27:17 +01:00
Christian Kellner
a20bac5171 test/fmt_v1: extrat basic pipeline description
Extract the pipeline description that is used in test_canonical,
so that it can be re-used in other tests.
2021-01-20 21:27:17 +01:00