Commit graph

66 commits

Author SHA1 Message Date
Christian Kellner
f7af3042ca test: fix executable test
During the rework done in commit "use and require explicit exports"
with commit id 7ae4a7e78, the test got overlooked. Add an empty
list of checkpoints to the `obs.compile` invocation as to actually
trigger the osbuild invocation.

Reported-By: Thomas Lavocat <tlavocat@redhat.com>
2022-02-15 13:25:23 +00:00
Alexander Larsson
693e44e412 sources test: Support custom mimetypes in http server
By creating a `foo.mimetype` file you can override the mimetype returned
for the file `foo`.
2022-02-10 14:43:17 +01:00
Christian Kellner
0aea72e44e ci: run ostree image tests via Schutbot
OSTree tests, especially the fedora-ostree-image one, will soon
need the tight integration with the host for LVM2/LUKS support.
This we cannot run them in github action containers. Move them
to Schutzbot.
Explicitly install the new sub-package until composer gains the
needed requirement.
2021-12-09 00:44:21 +00:00
Christian Kellner
80414299cd test/stages: export tree and compare that
Instead of checkpointing the tree and then accessing the generated
tree inside the store via the `map_object` function we not just
export the tree and use that. This better hides the internals of
the store and also allows us to activate on-demand building that
does not rely on checkpoints being implicitly built like exports.
2021-12-02 12:51:30 +00:00
Christian Kellner
7ae4a7e785 test: use and require explicit exports
Require all the tests that compile a manifest to either specify
checkpoints or exports. Convert all the tests that were relying
on implicit exports with v1 manifests to use explicit exports.
2021-12-02 12:51:30 +00:00
Christian Kellner
a5e07cf506 devices: introduce new device manager class
Introduce a new class to manage devices, `DeviceManger` and move the
code to open devices from the `Device` here. The main insight of why
the logic should be place here is that certain information is needed
to open the devices, independently of specific type: the path to the
device node directory, `devpath`, the actual `tree` and the service
manager instance to start the actual service. Instead of passing all
this information again and again to the `Device` class, we now have
a specialized (service) manager class for devices that has all the
needed information all the time. Additionally, the special handling
of parent devices is moved from the pipeline to the service manager,
which is where it belongs.
This will make even more sense for mounts, where the `DeviceManger`
can then be passed to access the individual devices.
Port the test to use the `DeviceManager`.
2021-10-30 15:32:44 +01:00
Christian Kellner
074741cc27 test/stages: add check for parted stage
Include a new test that writes a partition table to a disk and
then reads it back via `sfdisk` compares it against an layout
that was generated.
NB: This test needs `sfdisk` with `--json` support on the use host.
2021-10-30 00:54:09 +01:00
Christian Kellner
c902a7a754 sources: port to host services
Port sources to also use the host services infrastructure that is
used by inputs, devices and mounts. Sources are a bit different
from the other services that they don't run for the duration of
the stage but are run before anything is built. By using the same
infrastructure we re-use the process management and inter process
communcation. Additionally, this will forward all messages from
sources to the existing monitoring framework.
Adapt all existing sources and tests.
2021-09-22 00:00:20 +02:00
Christian Kellner
45d0594b1b device: add support for parent devices
This allows device nesting, i.e. one device being opened inside another
one.
2021-08-13 12:20:54 +02:00
Thomas Lavocat
1b145701f4 test: convert to pytest test_noop.py
Split the tests and add verification for access to mount when necessary.
2021-08-12 09:34:33 +02:00
Christian Kellner
78bc042bae test/run: add devices test for loopback devices
Add a new devices run time test and add basic checks for the
org.osbuild.loopback device.
2021-08-11 20:59:51 +02:00
Christian Kellner
2c64c65608 test/assembler: use new loop_for_fd helper
Use the new `loop_for_fd` helper that got added to `LoopControl`,
which is basically a version of the existing code.
2021-08-11 20:59:51 +02:00
Christian Kellner
7f97f2c12e test/stages: new test for the tar stage
Include a simple test for the `tar` stage that does basic checks,
i.e. that a tarball was successfully created, but also checks
that we do not create entries with a `./` prefix.
2021-07-22 15:23:39 +02:00
Christian Kellner
2e1105cea5 test/ostree: add v2 tarball build
Build the ostree commit wrapped in a tarball added in the previous
commit.
2021-06-21 18:56:38 +02:00
Christian Kellner
8cf35b4728 test/ostree: use pytest and split out tests
Convert the test to use `pytest` and split out the individual
tests. The temp-directory fixture has the session scope so
that checkpoints can be shared between the individual tests.
2021-06-21 18:56:38 +02:00
Christian Kellner
a47a40cf26 test: remove unittest dependency for OSBuild
Remove the dependency on unittest for the `OSBuild` class which
used the `unittest` instance only for `assertEqual`, which can
easily also be done via a plain `assert`.
2021-06-21 18:56:38 +02:00
Christian Kellner
97ff9eb780 test/ostree: build the ostree raw image
Build the newly included fedora ostree image artifact. This should
test the new devices and mounts.
2021-06-09 18:37:47 +01:00
Tomas Hozza
8d43a78918 test: update test manifests to use Fedora 34
Move from using 'zram' to 'zram-generator-defaults' in the ostree bootiso
testing manifest. More information is available in Fedora 33 Change
document [1].

Add org.osbuild.kernel-cmdline stage to fedora-boot.json manifest
because of change in how grub handles the kernel command line arguments
[2].

GRUB2 Stage 2 checksums in assemblers test are updated. The change have
been verified by building the fedora-boot.json manifest with each checked
filesystem and booting the image in QEMU with legacy mode.

[1] https://fedoraproject.org/wiki/Changes/SwapOnZRAM
[2] https://github.com/osbuild/osbuild-composer/pull/982#issuecomment-697356929

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-07 12:15:26 +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
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
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
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
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
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
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
Achilleas Koutsou
4455b953ae test: Fix temporary network revert in tests
The netns() function sets up a new namespace for tests.  The function is
also used to determine whether those tests can be run (using
unittest.skipUnless()).  A bug in the function made the changes stick if
the function failed early.  Specifically, when the "ip link" line fails,
the function exits without reverting to the old namespace.

Since the code is used in "skipUnless()", it's run during test
collection, which means that even if the relevant tests aren't selected,
they affect the environment for other tests.
2021-01-20 21:18:29 +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
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
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
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
Christian Kellner
cf48fe8afe test/assembler: check metadata for ostree asm
Check the metadata is in the result and that it has the 'compose'
entry, which should match what is in `compose.json`.
2020-08-13 10:50:34 +02:00
Christian Kellner
f9fc99fe8f test/stages: support for metadata checking
If the stage test folder contains a `metadata.json` file, it will
contain a dictionary where the keys are stage ids and the values
are dictionaries containing the metadata to verify. For each of
those the stage will be looked up in the pipeline result of 'b'
and verified that the metadata matches.
2020-08-13 10:50:34 +02:00
Christian Kellner
fdded58cdd test/assembler: check for ostree version metadata
Set the OS version of the commit via the new `os_version` option
and make sure that it is in the compose info as well as in the
commit metadata.
2020-08-12 08:08:17 +02:00
Davide Cavalca
a5f4de85cd test: bump filesystem size to 1G 2020-08-04 10:49:37 +02:00
Davide Cavalca
38c1ed52ce test: xfs also needs a different l2hash 2020-08-04 10:49:37 +02:00
Davide Cavalca
04204d585d test: lost+found really is just ext4 2020-08-04 10:49:37 +02:00
Davide Cavalca
fc6eb5c4c4 test: btrfs needs a different l2hash 2020-08-04 10:49:37 +02:00
Davide Cavalca
925530ac0a assemblers: add btrfs support to qemu and rawfs 2020-08-04 10:49:37 +02:00
Ondřej Budai
3cc8c91092 test/assemblers: use smaller images
640k ought to be enough for anybody!

Err... I mean...

The assembler tests now install only the filesystem and selinux packages and
their dependencies. For this, we don't need the  luxury of 2 GiB.

This commit changes the image size to 512 MiB. This has some advantages:

- the tests are faster - I measured the qemu assembler test and the running
  time went down from 290s to 260s.
- the tests can be run in environments with smaller disk space
2020-07-29 07:35:32 +02:00
Ondřej Budai
5842bbb93e test: make osbuild.compile method take output_dir as a parameter
Previously, the osbuild executor had its internal temporary directory that
served as the output directory. However, this approach gives no power to
the caller to control the lifetime of the produced artifacts. When more
images are built using one executor, the results will accumulate in one
place possibly leading to exhaustion of disk space.

This commit removes the executor's internal output directory. The output
directory can now be passed to osbuild.compile, so the caller can control
its lifetime. If no directory is passed in, the compile method will use
its own temporary directory - this is useful in cases when the caller
doesn't care about the built artifacts or the manifest doesn't have any
outputs.
2020-07-29 07:35:32 +02:00
Ondřej Budai
06db7834f9 test/assemblers: use one osbuild executor for all qemu and tar tests
This way the test can benefit from osbuild's internal cache:

The first subtest builds all the stages and  runs the assembler
The next subtests can reuse the built stages and just run the assembler

Some data from my machine running the qemu test:

Building the manifest takes about 120 seconds
Running just the assembler on the cache's content takes 30 seconds.

Before this change, the whole manifest was built 3 times:
3 * 120 = 360 seconds

After this change, the whole manifest is built once and the cache
is reused 2 times:
1 * 120 + 2 * 30 = 180 seconds
2020-07-27 13:18:40 +01:00
Ondřej Budai
49049276f5 test/assemblers: pass osb executor to run_assembler explicitly
Let the caller decide which executor instance should be used to build
the manifest. This change allows us to use osbuild's built-in cache
in the following commit.
2020-07-27 13:18:40 +01:00