Commit graph

43 commits

Author SHA1 Message Date
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
Tom Gundersen
4dda272d8b test/cases: include the full rpmmd structs
This includes the packgase and build-packages used by each pipeline.
For now, this information is not used anywhere, but when we move
from dnf to rpm-based pipelines, this is what will be used instead
of the repo metadata checksum.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
2220a76acf generate-test-cases: don't build images unless we intend to run image-info
For tarballs, this is currently not supported, so no point in generating
the images in the first place. This will still be done during testing to
boot-test them.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
f97ab01b4c image-info: cleanup
Follow standard python coding style.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Jacob Kozol
b7dad71420 tools: add script to generate test cases
The test case json files will increase in complexity with the move from
dnf to json. They quantity of them will also continue to grow as new
distros, architectures, boot methods, image types, and blueprint
customizations become available. The generate-test-cases script
simplifies the process of creating new test cases. It accepts a compose
request and boot method as input and then uses osbuild-pipeline,
osbuild, and image-info to generate the test case.

[tomegun: some clean-ups and allow store to be reused]
2020-03-13 15:00:24 +01:00
Lars Karlitski
049969911d tools: add prepare-source.sh
A script that runs various go tools (mod tidy, mod vendor, and fmt for
now).

The idea is that it prepares the source to be ready for master. As such,
running it on master shouldn't modify any files. Make sure of that by
adding a test.
2020-02-17 16:09:17 +01:00
Christian Kellner
0cf8a20744 image-info: mount ESP at /boot/efi if found
If we detect a ESP (via its type UUID) remember it and mount it at
any filesystem that has a /boot/efi (there should in theory be
only one). This is needed so grubenv can be read, which is likely
a link from /boot/grub2/grubenv to ../efi/EFI/$vendor/grubenv.
Additionally this will make rpm verify not report that all the efi
binaries are missing, e.g.:
"missing": [
      "/boot/efi/EFI",
      "/boot/efi/EFI/BOOT",
      "/boot/efi/EFI/BOOT/BOOTIA32.EFI",
      "/boot/efi/EFI/BOOT/BOOTX64.EFI",
      "/boot/efi/EFI/BOOT/fbia32.efi",
      "/boot/efi/EFI/BOOT/fbx64.efi",
      "/boot/efi/EFI/fedora",
      "/boot/efi/EFI/fedora",
      ...
2019-12-09 18:08:52 +01:00
Tom Gundersen
d1d3768d9d image-info: include more properties
This gets us closer to returning all the properties we support as
customizations.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-11-26 13:48:09 +01:00
Tom Gundersen
eee08c41ac image-info: support images with empty partitions
Official RHEL EC2 images come with an empty partition, simply ignore
it rather than fail.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-11-24 17:43:00 +01:00
Lars Karlitski
e7ae3b4c47 test: move image-info tests to test/
These tests (will) test more than just image-info: they'll take a
blueprint, verify that `osbuild-pipeline` generates the correct
pipeline, run osbuild with that pipeline and verify that the resulting
image has the expected image-info output.

This change only includes the latter half (i.e., only moves the already
existing tests).

Also drop python's unittest. It was hard to control output (important
for quickly spotting failures and to make travis happy). This introduces
test/run, which runs all test cases in test/cases or the ones given on
the command line.

When a failure occurs, it prints a diff of the actual and the expected
image info.
2019-10-30 01:25:44 +01:00
Lars Karlitski
fabd40da1c blueprint: always run selinux stage last
A few output types had it before the fix-bls stage.
2019-10-29 16:01:37 +01:00
Lars Karlitski
6a6144c2d9 blueprint: always exclude the rescue kernel
Its BLS entry always expects a separate boot partition. Skip it on all
images until the rescue kernel package is usable.
2019-10-29 16:01:37 +01:00
Lars Karlitski
930347c56e blueprint: move vmdk towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.

Also, lorax generates an image with a separate /boot partition. This is
not yet addressed here, because osbuild doesn't support it yet.
2019-10-29 16:01:37 +01:00
Lars Karlitski
cde1325bc3 blueprint: move tar towards lorax parity
The main difference (according to `rpm -qa`) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.
2019-10-29 16:01:37 +01:00
Lars Karlitski
d4e1ecea7e blueprint: move partitioned-disk towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.

Also, lorax generates an image with a separate /boot partition. This is
not yet addressed here, because osbuild doesn't support it yet.
2019-10-29 16:01:37 +01:00
Lars Karlitski
fe46fd3a89 blueprint: move ext4-filesystem towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.
2019-10-29 16:01:37 +01:00
Tom Gundersen
e8bd3cba45 image-info: add expected image info
This is the output of disk info ran against the images produced
by the specified pipelines.

Skip the actual test for now, because it is taking too long to run.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-29 16:01:37 +01:00
Tom Gundersen
8c0561c054 blueprint/test: express test-cases in json
A test case is now expressed purely by dropping in a json document in
`tools/test_image_info/pipelines`. It should contain the input compose
(output format and blueprint) as well as the expected pipeline. All the
existing tests are moved over to this format.

This shares the same infrastructure as the image tests, ideally we want
to run the blueprint tests and the image tests against the same pipelines.

For now, test cases are skipped from the blueprint tests if they do not
contain a 'compose' section, and from the image tests if they do not
cotain an 'expected' section. In the future we may want to make both
mandatory.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-28 17:32:45 +01:00
Lars Karlitski
fd50ef4a73 test/image-info: print osbuild output on failure 2019-10-28 14:37:36 +01:00
Tom Gundersen
2e0deff629 submodule: bump to current head
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-28 14:14:09 +01:00
Tom Gundersen
18934d4249 tools/image-info: add support for naked partitions
In case there is no partition table, we assume the whole image is
one big partition and treat is as such.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 11:46:25 +02:00
Lars Karlitski
329964f2ab image-info: add test
Add two kinds of tests, with one case each:

1. Run image-info against an osbuild pipeline. Uses osbuild
from a submodule to make an image from the pipeline.

2. Run image-info against an existing image, fetched from the internet.
2019-10-05 14:47:35 +02:00
Lars Karlitski
2854b2938e image-info: don't use rpm --verify with --root
RPM uses the host's passwd instead of that in the target to get uid
and gid mappings.

Run it in a chroot to work around this bug.
2019-10-05 14:47:35 +02:00
Lars Karlitski
5040e6b427 image-info: sort bootmenu entries
The order doesn't matter, but should be the same between different runs
of image-info.
2019-10-04 01:51:07 +02:00
Tom Gundersen
41c6f5dd0b image-info: include partition table id
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-03 12:35:51 +02:00
Lars Karlitski
b170ea036c image-info: include output from rpm --verify
This shows the changes an image has relative to what its rpm database
thinks is installed. Output is:

    "rpm-verify": {
        "missing": [ <missing files> ],
        "changed": { <map from filename to rpm attribute octet > }
    }

Alas, this makes running image-info slower.
2019-10-01 17:05:10 +02:00
Lars Karlitski
01b7402ce2 image-info: include partition label and uuid 2019-09-30 22:28:28 +02:00
Lars Karlitski
9867846ff4 tools/image-info: consistent use of - over _
And remove a stray comment and whitespace.
2019-09-30 22:28:28 +02:00
Tom Gundersen
e43955a4c5 image-info: include the image format
Use qemu-img to query the image format and include that in the report.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-30 15:15:14 +02:00
Lars Karlitski
bf3d7fcdca image-info: add basic support for multiple partitions
For each partition, find out if its the root or boot partition and
gather only the relevant information. Make sure that we don't get
information from /boot twice.
2019-09-30 13:32:53 +02:00
Lars Karlitski
172a23bdb2 image-info: bootloader=unknown instead of creashing 2019-09-30 13:32:53 +02:00
Lars Karlitski
457f5f697e image-info: assume bootable=False if key is not present
sfdisk doesn't include the "bootable" key in its output when a partition
is not marked as bootable.
2019-09-30 13:32:53 +02:00
Lars Karlitski
5fbc734a15 tools: add image-info
Rough draft of image-info, a tool that extracts high-level information
about an os image. It prints this information in JSON form on stdout.
Run it like this:

  $ tools/image-info <image>

It supports all images that qemu-ndb supports.
2019-09-29 13:44:56 +02:00