Commit graph

108 commits

Author SHA1 Message Date
Lars Karlitski
857570980d tools: add deploy-qemu and gen-user-data
tools/gen-user-data generates a cloud-init user-data file from a
configuration directory. It is mostly useful to embed files in the
user-data.

tools/deploy-qemu uses above tool to make a user-data file and spins up
a virtual machine with it. This is useful to locally run, test, and
debug osbuild-composer.

A simple user-data directory for running tests locally is included in
tests/deploy-user-data. It expects a repository with osbuild-composer
rpms to be served on the host's port 8000.
2020-10-07 11:51:33 +02:00
Lars Karlitski
9246727096 image-tests: use RHEL8.3 nightly instead of snapshot
Snapshots are currently broken. Revert to the same nightly that are used
in schutzbot's repositories.

Regenerate the test case as well.
2020-10-06 13:08:26 +02:00
Tom Gundersen
555934e303 koji: move run-koji-containers.sh to tools
Also install it is part of he tests subpackage. This a helper-tool, not
golang code, so should not live in `internal`. We need access to this
from the integration tests, so install it onto the tests system.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
001c7f682a test/integration: move koji-compose.py into tools
This is not an integration test in itself, but a helper tool.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Jacob Kozol
678de9d1ef distro: add fedora 33 support
Fedora 33 images can now be built and test cases are added for the new
images. The fedora 33 qcow2 and vmdk images are based off of the
official images and their kickstarters found here:
https://pagure.io/fedora-kickstarts. The fedora 33 iot image is based
off of the the config found here: https://pagure.io/fedora-iot/ostree.
The openstack, azure, and amazon image types have changes made to them
based off of the changes made to the qcow2. The changes between fedora
32 and fedora 33 are as follows:

Grub now loads its kernel command line options from
etc/kernel/cmdline, /usr/lib/kernel/cmdline, and /proc/cmdline instead
of from grub env. This is addressed by adding kernelCmdlineStageOptions
to use osbuild's kernel-cmdline stage to set these options. Alongside
`ro biosdevname=0 net.ifnames=0`, we also set `no_timer_check
console=tty1 console=ttyS0,115200n8` per what is set in the official
qcow2. For azure and amazon, the kernelOptions are still set as they
were in fedora 32.

The timezone is now set to UTC if a user does not set a timezone in the
blueprint customizations. Also, the hostname is set to
localhost.localdomain if the hostname isn't set in the blueprint.

Finally, the following packages have been removed:

polkit
geolite2-city
geolite2-country
zram-generator-defaults
2020-10-01 10:11:03 +02:00
sanne raymaekers
9404b0640a test: Regenerate the rhel-8 cases to add subscriptions 2020-09-22 11:38:28 +02:00
Lars Karlitski
c07674e1f4 tools/prepare-source: also call go generate ./...
To ensure that all generated code is up to date.
2020-09-08 20:40:08 +02:00
Tom Gundersen
7e0711b805 test/generation/rhel8: move to today's nightly
We need this for greenboot-status, in the RHEL for Edge images. This
updates the generator for x86_64 and aarch64 and updates the test cases
for rhel-edge-commit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-03 11:02:44 +01:00
Ondřej Budai
5e6e77b565 bump minimal Go version to 1.13
All our downstream platforms now support Go 1.13:

RHEL 8.2: golang-1.13.4
Fedora 31: golang-1.13.14

There's no reason anymore to stay on 1.12, therefore this commit bumps
the minimal required Go version to 1.13
2020-08-25 10:42:21 +02:00
Alexander Todorov
02346faff8 Use /var/tmp for temporary files for image-info 2020-08-20 21:59:54 +02:00
Alexander Todorov
0469be7a22 tests: Change boot typo to openstack. Refs #876
this will cause the images to be uploaded and booted in our
OpenStack cluster.
2020-08-07 19:58:37 +02:00
Major Hayden
f2d0f5e6f6 aarch64: Remove updates repo from test cases 2020-07-27 10:27:15 -05:00
Major Hayden
5ef678a57b aarch64: workaround qemu-convert CPU bug
The conversion with `qemu-img convert` often fails on aarch64 systems
with LOTS of CPUs. This is fixed in RHEL 8 for aarch64, but not in
Fedora.

Set the maximum coroutines to 1 to avoid this issue until the bug is
fixed.

Bug: https://bugs.launchpad.net/qemu/+bug/1805256

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-27 10:27:15 -05:00
Major Hayden
48fdc3d831 test case repos: use RHEL 8.3 Beta 1
Switch to RHEL 8.3 Beta 1 for generating test cases.

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-27 10:27:15 -05:00
Martin Sehnoutka
12172adf47 test-case-generators: refactor customizations
This patch contains refactoring of the part where we handle
customizations. Previously customizations were considered an "image
type" which is not obvious. Now it is a command line switch.
2020-07-22 10:47:46 +01:00
Martin Sehnoutka
a38ee2e7a7 test-case-generators: fix printing of osbuild log
Writing to a file followed by reading it results in printing b'' unless
we seek to the beginning. Fix it by calling seek.
2020-07-22 10:47:46 +01:00
Major Hayden
4b0409df5b Update Fedora 31/32 aarch test cases
Add Fedora 32 test cases with the base OS + updates (to work around
aarch64 bugs in the original release). Add updates for Fedora 31 for
consistency.

Fixes #861.

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-15 09:46:06 +02:00
Lars Karlitski
bc1bca1538 generate-test-cases: stop and fail when osbuild fails 2020-07-13 22:17:33 +01:00
Lars Karlitski
c8a918cefa generate-test-cases: fix whitespace 2020-07-13 22:17:33 +01:00
Christian Kellner
aa03f1617a image-info: read sector size, if available
Use the sector size reported by 'sfdisk', if available, otherwise
default to the standard value of '512' (as currently assumed).
2020-07-13 11:31:06 +02:00
Christian Kellner
5bca8bcacd image-info: support for peculiar partitions
Add support for partitions that can 'blkid' can not handle, like
the bios boot partition. For such partitions, 'blkid' will fail;
in that case all additional information will just be 'None'.
2020-07-13 11:31:06 +02:00
Christian Kellner
598c2b6939 image-info: always use raw images and loop devices
Convert any image that is not a raw image, e.g. a qcow2, to a raw
image and open the partitions via loop devices. This replaces the
usage of nbd, which was racy and flaky.
Instead on relying on the kernel for the partition parsing, this
is now done manually via loop devices and start + offset taken
from sfdisk. As a result the read_partition function has been
adapted to be called at later time, after the partitions were
opened via loop devices.

Not using nbd also means that the partition table is not scanned
by the kernel anymore and udev is not triggered. As a result the
'PARTUUID' property is not present for dos/mbr partition layouts,
since it is auto-generated by udev/blkid. Relevant blkid files
and functions are:
  blkid_partition_gen_uuid(par)
    called from probe_dos_pt()
    in file libblkid/src/partitions/dos.c line 295
    defined in libblkid/src/partitions/partitions.c line 1374
    which generates the uuid via snprintf using the format:
      '"%.33s-%02x", par->tab->id, par->partno'
Based on https://github.com/karelzak/util-linux at ce8985cc7

NB: the loop device code is imported from osbuild, making this
tool depend on osbuild's private library.

NB: As of the image conversion, more disk space is required to
examine non-raw images.
2020-07-13 11:31:06 +02:00
Christian Kellner
bd695c79d2 image-info: support for compressed images
If a compressed file is detected (xz, bzip2, gzip), uncompress it
before analyzing it. NB: this has to happen after the is_tarball
check, because a tarball would also count as compressed.
2020-07-13 11:31:06 +02:00
Christian Kellner
9c0fdd9981 image-info: ensure target is an absolute path
Specify the type for the 'target' command line argument to be an
absolute path. Also add a metavar description for the option.
2020-07-13 11:31:06 +02:00
Christian Kellner
ea9b1fa333 image-info: extract fstab reading code
Extract the code that reads /etc/fstab into its own method and
remove the redundant `f.read().split("#")`.
2020-07-13 11:31:06 +02:00
Christian Kellner
68296aac88 image-info: use contextlib.suppress for ENOENT
Instead of using try-except blocks to catch (and ignore) file-not-
found errors (FileNotFoundError/ENOENT), use contextlib.suppress.
2020-07-13 11:31:06 +02:00
Christian Kellner
113631b7c4 image-info: refactor append_partitions
Directly iterate over the partition list entries instead if using
indices. Optimize visual flow for the happy case by immediately
continuing if a partition has no file-system.
2020-07-13 11:31:06 +02:00
Christian Kellner
9a068d918f image-info: extract partition reporting code
Extract the code that reports the content of individual partitions
into its own function to make it overall more readable.
2020-07-13 11:31:06 +02:00
Christian Kellner
07a6be5a2f image-info: return dict from read_partition_table
Instead of return three a triplet of information, directly return
a dictionary, where the name for the keys are the names that are
used in the report.
2020-07-13 11:31:06 +02:00
Christian Kellner
cbc9ed0f11 image-info: remove unused arg in read_partition
Remove the unused 'type' argument.
2020-07-13 11:31:06 +02:00
Christian Kellner
b7a43b5812 image-info: read format info before image opening
Read the image information before opening the image. This prepares
for a change where we will use information about the image to
convert it to raw instead of using nbd.
2020-07-13 11:31:06 +02:00
Major Hayden
0f32f35756 📦 Use raw image format for AWS
Although the vhdx format is smaller than raw, AWS often has some issues
booting instances from an imported vhdx snapshot. The raw format seems
to boot consistently at AWS.

Fixes #754.

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-02 13:11:11 -05:00
Tom Gundersen
b32f0feeae test/cases: add test-cases to verify customizations
Add one test-case per distro that tries to cover all the customizations
we support.

For now omit firewall customizations, as there are open questions about
how to support that on all image types.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-29 16:04:38 +02:00
Christian Kellner
c3c78c2d0c image-info: use /var/tmp for bigger files/dirs
When extracting the commit tarball as well as doing the ostree
commit checkout, use `/var/tmp` instead of `/tmp`, because the
latter might be backed by a tmpfs and thus by RAM; this should
only be used for small files.
2020-06-26 20:25:21 +02:00
Martin Sehnoutka
7be8cefab9 tools: merge generate-test-case{,s} scripts
The fact that we have two scripts and one captures output of the other
makes it hard to use in scenarios where the test case generation often
fails. This output capturing results in subtle bugs like described in
issue: https://github.com/osbuild/osbuild-composer/issues/769

This patch merge these two scripts and use class to organize it
instead of files.
2020-06-19 16:36:16 +02:00
Martin Sehnoutka
1e5c31a7ad distro/rhel8: introduce s390x support
This patch introduces support for s390x architecture. It has some
specific requirements like using kernel-cmdline stage before the RPM
stage because RPM scriptlets require these values to be present in the
system already. It also uses zipl stage and bootloader as opposed to all
the other architectures.
2020-06-11 21:50:09 +02:00
Tom Gundersen
fcd5ff76ac tools/image-info/ostree: don't record the commit sha
This is not stable between builds, instead, record the inputhash, which
is.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-11 20:44:17 +02:00
Tom Gundersen
dec644dec4 tools/test-case-generation: don't skip image info for tar
This is now supported, so default to include tar image info.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-11 20:44:17 +02:00
Tom Gundersen
be3541335e tools/image-info: drop a stray print()
This resulted in invalid JSON on stdout.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-11 20:44:17 +02:00
Tom Gundersen
654eb9d280 tools/test-case-generator: add iot and edge test-case generation 2020-06-11 20:44:17 +02:00
Tom Gundersen
c51de68301 tools/test-case-generator: make image-types a required argument
Also allow a list of them to be passed. Generating 'all' image types
makes less sense now that different distros/arches support different
ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-11 20:44:17 +02:00
Tom Gundersen
ab276bdb77 tools/test-case-generator: add more options
Allow individual test-cases or sub-sets of test-cases to be generated
more easily.

We allow explicit skipping of image-info generation (and hence the
osbuild run), and also individual image types to be specified.

Also drop distros and image types that are no longer supported.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-10 19:25:54 +02:00
Christian Kellner
1e310b61b9 image-info: support for analyzing tarballs
If the target is a tarball, extract the tarball and then analyze
the extracted directory.
2020-06-08 21:22:54 +02:00
Christian Kellner
ee240e2bf4 image-info: read the system passwd for ostrees
When analyzing a ostree filesystem, also parse and add the system
passwd and group files.
2020-06-08 21:22:54 +02:00
Christian Kellner
0479bfc78a image-info: add support for ostree commits
Support analyzing ostree repositories or directory that contain an
ostree commit as created by osbuild. Will return the mode of the
repository along with the references and their commits. For the
first references, the commit is resolved and checked-out to a temp
directory. This directory in turn is then analyzed via the existing
append_filesystem function. The latter has gained some small ostree
specific tweaks.
NB: for the ostree checkout /usr/etc/ is bind mounted to /etc in
order to make append_filesystem happy. The rpm verification step
is NOT run, because that is not really compatible with ostree.
2020-06-08 21:22:54 +02:00
Christian Kellner
18d1dcee20 image-info: extract package listing into function
Move the logic that retrieves the installed packages via rpm into
its own function.
2020-06-08 21:22:54 +02:00
Christian Kellner
7a250188bf image-info: move image opening to own function
Move the code of the current main into is own method and call that
from main. This prepares support for analyzing other types than
images. Additionally, add argument parsing via argparse to get a
help texts.
2020-06-08 21:22:54 +02:00
Tom Gundersen
e20919b494 tools/test-case-generator: add further filtering support
Allow a test case to be generated for a specific image type, rather than
for all at once.

This is useful when adding additional image types, rather than
regenerating the existing ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-08 13:32:59 +02:00
Tom Gundersen
83a63aaf17 distro/rhel8: add tar image type for all architectures
This is a very minimal image type, which is not expected to do anything
with an empty blueprint. It is documented as a way to install RHEL for
Satellite.

This fixes #720.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-08 13:32:59 +02:00
Tom Gundersen
253379a3b9 tests: use more reliable mirrors for Fedora tests
Move away from the round-robin fedora mirrors, and use the most reliable
one we have found (kernel.org).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 13:33:32 +02:00