Commit graph

232 commits

Author SHA1 Message Date
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
Martin Sehnoutka
385df479f3 distro/rhe8: introduce ppc64le qcow2 image type
This patch introduces a qcow2 image type for RHEL8 distro and associated
test case.
2020-06-06 16:56:39 +02:00
Martin Sehnoutka
1f580738db tools: fix generate-test-case script
Commit 8dd4554491 introduced a bug because
the output from osbuild is not captured. The problem is that osbuild
itself writes JSON document to STDOUT so two different JSON documents
are written to STDOUT: osbuild output and generated test case. The
generate-test-cases script then fails because it cannot json.loads() the
test case.

This patch simply supresses the output which fixes the issue.
2020-06-05 12:00:50 +02:00
Tom Gundersen
cc231e0ed1 distro/rhel-8: merge all the RHEL-8 minor releases into one
As it turns out, the default expectation is not to distinguish between
these. We will now produce whatever is the most recent minor release by
default, and image tests will still be pinned at a given snapshot to be
reproducible.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-21 17:57:28 +02:00
David Rheinsberg
8dd4554491 test-case-generator: use --output-directory of osbuild
Use the --output-directory switch of osbuild to avoid poking into the
osbuild-cache.
2020-05-13 13:31:23 +02:00
Tom Gundersen
1d1dcfefb6 tools/generate-test-cases/repos: add GPG keys and update to most recent
Update RHEL-8.2 to the most recent RC now that it has been released.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-04-28 11:10:12 +02:00
Ondřej Budai
e235fdedb3 tests/image: boot the vhd images on Azure
Previously, vhd images were tested using QEMU. This commit changes that to
boot them in the actual Azure infrastructure.

Azure VMs have quite a lot of dependencies - a network interface, a virtual
network, a network security group, a public ip address and a disk. Azure CLI
and Azure Portal handle the creation of all these resources internally.
However, when using the API, the caller is responsible to create all these
resources before creating an actual VM.

To handle the creation of all the resources in the right order, a deployment
is used. A deployment is a set of resources defined in a JSON document.
It can optionally take parameters to customize each deployment. After the
deployment is finished, the VM is up and ready to be tested using SSH.

Sadly, the deployments are a bit hard to clean-up. One would expect that
deleting a deployment removes all the deployed resources. However, it doesn't
work this way and therefore it's needed to clean up all resources "manually".
For this reason, our deployment sets a unique tag on all the resources created
by the deployment. After this test is finished, the API is queried for all
the resources with the tag and then, they're deleted in the right order.
2020-04-27 20:34:20 +02:00
Major Hayden
8dd6fd24b5 Use download.fp.o for downloading packages
Requests to download.fedoraproject.org are redirected to a regional
mirror that is fairly close to the system that is making the request.
This could speed up downloads slightly since it avoids using the
Fedora proxies.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-27 11:57:17 +02:00
Ondřej Budai
8f351026d8 tests/image: drop the qemu-extract boot type
Previous commit switched the ami output type to qemu boot type, therefore
qemu-extract is not needed anymore.
2020-04-24 15:27:39 +02:00
Ondřej Budai
83a3a8d821 change the format of the ami image type to vhdx
Prior this commit the ami image type produced raw.xz images. This was bad for
two reasons:

- The upload was broken because AWS doesn't support tar.xz format
- XZ compression is terribly slow

This commit changes the format to vhdx, which is supported by AWS and also
quite quick. See https://github.com/osbuild/osbuild-composer/issues/257
why vhdx was chosen.

Fixes #257
2020-04-24 15:27:39 +02:00
Ondřej Budai
d9cbdede41 tools/prepare-source: use a well-defined go version
go mod works differently in go 1.12 and go 1.13. When someone uses the
prepare-source tool with go >= 1.13, the ci complains because it uses
go 1.12. This commit changes the script to use a well-defined go version.
2020-04-23 08:54:29 +02:00
Martin Sehnoutka
bceb51b330 tools/image-info: dont fail if /boot/grub2/grubenv is missing
The file is missing on non-bootable images and we skip missing files in
all other cases. Do it in this one as well.
2020-04-11 13:10:13 +02:00
Martin Sehnoutka
f51932974a test-case-generators: use unxz also for aws
In PR #400:
https://github.com/osbuild/osbuild-composer/pull/400
we changed the boot type of AWS images from qemu-extract to aws, which
resulted in a bug in the generate-test-case script. It tried to attach
xz archive using qemu-nbd which works just fine from qemu-nbd
perspective but sfdisk and blkid of course failed, because the xz
archive is not a disk image.

This patch makes sure we extract the image before attaching it to
/dev/nbdX.
2020-04-08 11:20:23 +02:00
Martin Sehnoutka
1ae1131fe4 image-info: report errors from subprocess calls
The subproces.check_output function hides the output of the subprocess
it runs, using subprocess.run directly enable us to see the errors.
2020-04-08 10:27:26 +02:00
Martin Sehnoutka
24b25bd06c test-case-generators: report errors from child processes
The current implementation does not report any errors because it uses
the subprocess.check_output function from Python std library. The
function is convenient to use but it hides all the errors from us which
makes it very inconvenient when the test generation often fails (like
developing support for alternative architecture). This patch introduces
a wrapper around the subprocess.run function which dumps the
subprocess's stdout to stderr in case of failure and forwards it to the
caller in case of success. This way the generation code is still very
straight forward, but the errors are reported properly.
2020-04-06 19:48:29 +02:00
Ondřej Budai
7dd09443cf tests/image/ami: test ami images on AWS
Prior this commit the ami images were tested locally using qemu. This does
not reflect at all how they're used in practice. This commit introduces
the support for running them in the actual AWS. Yay!

The structure of code reflects that we want to switch to osbuild-composer
to build the images soon.
2020-04-06 16:38:28 +02:00
Ondřej Budai
28d0c4f640 tools: remove accidentally added line in test case generator
The line slipped in f945c505 when testing the changes. Let's remove it,
it breaks the script.
2020-03-31 14:40:37 +02:00
Tom Gundersen
380029b572 test/cases: move to stable mirror
Rather than use the round-robin mirror, use a fixe stable one.

We should not over-use this, but it seems the round-robin one is
simply too unstable for our tests.

Eventually, we want to use metalink here instead, but we need to
rework the file source first, so we can do that in a way that
does not make the tests dependent on the time/place the test
case was generated (currently the URL to a specific mirror ends
up pinned in the test-case).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +02:00
Tom Gundersen
f945c5057e osbuild-pipeline: always pass repositories as input
Require repository informaiton to be passed as input, rather than
read from the current directory.

Reading from the repository informaiton meant to be used by weldr
has several drawbacks.
 - it makes it impractical to use the tool outside a git checkout
 - it makes it awkward to adapt the repositories to different use
   cases
 - it means that the shipped repositories cannot be extended with
   update repos, as the same repos are used for testing, and that
   would render our tests non-reproducible.

Overall, we are moving towards making repositories something the
caller must always pass in, rather than something that composer
maintains. For the weldr API we need to keep working as before,
but for new APIs we are avoiding that.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +02:00
Tom Gundersen
7825132ae2 test/cases: include repository information
This means that the unit tests no longer need to load the
repositories from the git repo, and in a follow-up, osbuild-composer
won't need to either.

By splitting the repositories used for testing from the system
repositories available through the weldr API we are able to extend
the system repositories without affecting the reproducibility of
the tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +02:00
Tom Gundersen
a949843f1e test/cases: rename output-format to image-type
Bring this in line with our naming convention.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +02:00
Ondřej Budai
a040369513 tools/image-info: deduplicate and sort the services
systemctl list-unit-files doesn't produce machine readable output.
parse_unit_files isn't very good at reading it and can produce duplicate
records.

This commit fixes it by deduplicating and sorting the units. This is a bit
hacky solution, but should work just alright. In the future we might
dump list-unit-files and do the job ourself, but let's not recreate the
systemd logic for now.
2020-03-25 16:14:43 +01:00
Ondřej Budai
9b3375ccca tools/image-info: fix crash when parsing output from systemd >245
systemd 245 added a third column to systemctl list-unit-files, causing
the unpacking to fail.
2020-03-25 16:14:43 +01:00
Ondřej Budai
4c93d5a045 tools/image-info: fix warning when running with python 3.8
Python 3.8 introduced this warning:

tools/image-info:53: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if line[0] is '#':

This commit fixes this warning. More info in Python 3.8 release notes:
https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-python-behavior
2020-03-25 16:14:43 +01:00
Jacob Kozol
afa4975a15 tools: add script to generate multiple test cases
This script generates json test cases for each supported output format.
It requires an architecure, distro, osbuild store, and output directory
as input. There is also a json object which maps from output format to a
test case request which includes the compose request and boot type.
The script uses these test case requests to call the generate-test-case
script and then outputs the resulting json test cases to files in the
specified output directory.
2020-03-20 13:55:36 +01:00
Jacob Kozol
1909620660 tools: add boot parameters as input to generate-test-case
The generate-test-cases no longer maps from output format to boot
type. Instead, the boot data is passed in through the standard input
alongside the composer-request object.
2020-03-20 13:55:36 +01:00
Jacob Kozol
ab930e7a0c tools: move and rename generate-test-case
The script generate-test-cases only creates a single test case per run.
Therefore, the name should be singular. Also, this script has been moved
to a directory which will contain all test case generators.
2020-03-20 13:55:36 +01:00