Commit graph

25 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Ondřej Budai
4b290dd2a4 test: use a dummy pipeline when testing assemblers
#471 extends the assembler test suite to also test xfs and btrfs filesystems
in raw and qemu assemblers. However, this change leads to long running times
of this suite.

The running time of these test consist of 3 main steps:

1) Building the build pipeline
2) Building the stages
3) Running the assembler

There are two optimization approaches:

1) Caching
   OSBuild supports caching, therefore it's possible to cache results of first
   two steps.

2) Minimizing the operating system tree
   Assemblers don't care about the image contents. Therefore, it's possible
   to create just a small tree which would be used to test the assemblers.
   This should lead to speed up in the step 2 (smaller tree should be built
   quicker) and in step 3 (big part of assembling is just copying files over
   to the image).

This commit implements the second approach. A new test manifest is now added,
which just installs the filesystem package and its dependencies and this tree
is then labeled. This solution was chosen, so that the assemblers get
something that looks as a proper filesystem tree but also can be built pretty
quickly.

Before this change, the test_rawfs method with #471 merged ran for 842 seconds.
After this change, it ran for 391 seconds.
2020-07-21 10:25:47 +02:00
Christian Kellner
00f06dff16 test/assemblers/ostree: check rpm-ostree.inputhash
Verify the rpm-ostree.input hash is set correctly for the repository
itself as well. This will in turn also verify that the repository
is existent and can be accessed.
2020-06-15 13:44:01 +02:00
Christian Kellner
da80259ea0 test: add a test for the ostree.commit assembler
Create a ostree commit and check that it successfully was created
by inspecting the resulting `compose.json`.
2020-06-15 13:44:01 +02:00
Christian Kellner
cf03ca0715 test/assemblers: remove the need to use nbd
Using the network block device (nbd) kernel module to test all
the non-raw image formats often caused tests to fail due to nbd
not being stable itself (see below).
Instead convert non-raw images to the raw format via qemu-img
convert and mount those with loop-back devices. All the testing
code itself stays the same.

Example nbd error messages:
  kernel: block nbd15: NBD_DISCONNECT
  kernel: block nbd15: Disconnected due to user request.
  kernel: print_req_error: 89 callbacks suppressed
  kernel: blk_update_request: I/O error, dev nbd15, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
  kernel: buffer_io_error: 134 callbacks suppressed
  kernel: Buffer I/O error on dev nbd15, logical block 0, async page read
  kernel: blk_update_request: I/O error, dev nbd15, sector 1 op 0x0:(READ) flags 0x0 phys_seg 7 prio class 0
2020-06-15 11:51:31 +02:00
Christian Kellner
21e0475031 test/assemblers: split partition reading and test
Split up the partition table test into reading the partition table
and then asserting it has the correct entries. Prepares the usage
of the partition information later.
2020-06-15 11:51:31 +02:00
David Rheinsberg
06af246f38 test/assemblers: use F32 manifest
Switch to the fedora-boot.json manifest, so we automatically use the
latest fedora manifest for assembler-tests.
2020-06-05 09:27:40 +02:00
David Rheinsberg
0010514c4a test: move assembler-tests into ./test/run/
Move the last remaining test into the correct subdir. With this done,
all our tests run in one of the 3 groups:

   * `make test-src`
     Run tests against the source-code, including linters.

   * `make test-mod`
     Run unit-tests on the individual python modules. This needs no
     special permissions (unless noted in each test) or runtime
     environments. It is meant to be fast and easy to run in all
     circumstances.

   * `make test-run`
     Run tests that execute the osbuild pipeline. This requires
     superuser privileges and will likely take a while. Furthermore,
     this might produce large artifacts.
2020-06-05 09:27:40 +02:00
Renamed from test/test_assemblers.py (Browse further)