Commit graph

844 commits

Author SHA1 Message Date
Alexander Todorov
cd1e6d3aaf tests: replace cmd.Diff() with require functions 2020-04-20 14:00:49 +02:00
Alexander Todorov
fb7373aa62 tests: Use the require package 2020-04-20 14:00:49 +02:00
Ondřej Budai
5e49b026ca tests: remove the old aws unit test
The old aws unit test is not very useful now, because there's the new
integration test which covers a lot more. Therefore, this commit
removes it.

Fixes #512
2020-04-19 21:54:43 +02:00
Alexander Todorov
869bb2afd7 tests: Use the require/assert package and replace cmp.Diff 2020-04-19 18:20:57 +02:00
Major Hayden
3740e9bc6b 🐎 Allow qemu to use all available CPUs
Speed up the boot tests by allowing qemu to use all of the available
CPUs on the system. Our CI VMs have at least 2 CPUs and this shortens
the time required for a boot test.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-17 17:10:56 +02:00
Major Hayden
af0f3a4585 🦥 Try running some integration tests together
We may be able to shorten test time by running some tests
simultaneously.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-16 15:24:58 +00:00
Lars Karlitski
4a710429de worker: rename API to Server
This makes it symmetric with the client:

    s := worker.NewServer()
    c := worker.NewClient()
2020-04-16 01:02:16 +02:00
Lars Karlitski
ac40b0e73b jobqueue: rename to worker
This package does not contain an actual queue, but a server and client
implementation for osbuild's worker API. Name it accordingly.

The queue is in package `store` right now, but about to be split off.
This rename makes the `jobqueue` name free for that effort.
2020-04-16 01:02:16 +02:00
Jacob Kozol
76bd5ab984 docs: update cockpit-composer repo url
Cockpit-composer has moved from the weldr github organization to the
osbuild organization and its github url has changed. The url in the
man-page source is updated.
2020-04-15 20:26:55 +02:00
Jacob Kozol
39a162368c README: update cockpit-composer repo url
Cockpit-composer has moved from the weldr github organization to the
osbuild organization and its github url has changed. The README's url is
updated.
2020-04-15 20:26:55 +02:00
Ondřej Budai
dbfc2a0929 10
Release osbuild-composer version 10
2020-04-15 16:59:42 +02:00
Martin Sehnoutka
aa39579ff8 travis: disable image tests on arm to workaround kernel bug
The image tests fail in travis because there is a bug in the kernel,
that travis uses. See this upstream bug report for a reference:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1872757
2020-04-15 15:22:57 +02:00
Martin Sehnoutka
e34607b955 travis: plug in arm image test cases
The test generation script we use outputs the test cases prefixed with
"fedora_$RELEASE" so I renamed all the current test cases to follow this
convention and also changed the travis job names so that it can run both
x86_64 test cases and aarch64 test cases.
2020-04-15 15:22:57 +02:00
Martin Sehnoutka
58b550061b test/cases: include fedora test cases for aarch64
These tests were generated by the script in tools/ directory and are not
modified in any way.
2020-04-15 15:22:57 +02:00
Martin Sehnoutka
439b005514 distro: harcode partuuids
We need to make partition uuids stable to be able to run image-info
tests on images using gpt. For example all aarch64 images use gpt.

Also change the type of the (part) UUID to string because that's what
the other UUIDs use and it is easier to work with.
2020-04-15 15:22:57 +02:00
Martin Sehnoutka
e887518736 image-tests: Include qemu command specific for aarch64
The osbuild-image-tests don't currently support boot test for any
alternative architecture because the qemu-system-x86_64 command is
hardcoded. This patch introduces a branch specific to aarch64, but
without a KVM support as I was unable to make it run in Beaker, which is
currently the only offering we have with ARM machines. As a workaround
the boot tests will be skipped if kvm kernel module is not found and only
image-info tests will run.
2020-04-15 15:22:57 +02:00
Brian C. Lane
f960985c17 client: Add functions to support compose testing
Also adds new types to weldr/json.go to support them.
ComposeEntry had to be duplicated instead of used as-is because it
enforces image type strings that do not match what the API uses (the API
types are all lower case, the internal names are capitalized).
2020-04-15 11:35:05 +02:00
Brian C. Lane
7c86dc533c client: Add GetRawBody function to return the io.ReadCloser from the request
And refactor GetRaw to use it.
2020-04-15 11:35:05 +02:00
Brian C. Lane
b6bf49fc46 weldr: Fix /compose/image response for an unknown UUID
If the UUID is unknown it should return UnknownUUID not
BuildMissingFile.
2020-04-15 11:35:05 +02:00
Brian C. Lane
bd061b575d weldr: Fix the compose/delete response
The UUID list should only include UUIDs that are successfully deleted.
If there was an error it should only be listed in the errors list. This
matches the behavior of lorax-composer.
2020-04-15 11:35:05 +02:00
Brian C. Lane
2860398c2a store, weldr: Add support for fake composes
Yes. This goes against my desire not to change code to accommodate
tests. But there is no other good way to test compose results without
long running, and possibly fragile, composes. And this matches lorax's
behavior.

The change adds support for the ?test=1|2 query parameter to the compose
POST, and a new store function - PushTestCompose that handles creating
the fake compose results.

Passing ?test=1 will create a failed compose. Passing ?test=2 will
create a successful compose, but one without any files.

The purpose of these is to be able to test the compose result API
responses like compose/failed, etc.
2020-04-15 11:35:05 +02:00
Martin Sehnoutka
ebeecfaf33 github/workflows: downgrade golang to 1.12
We currently declare compatibility with golang 1.12 so we should also
use it in our CI. Once we agree that we would benefit from some features
in golang 1.13 or 1.14 we can bump it back.
2020-04-15 10:34:32 +02:00
Ondřej Budai
b2048b9796 upload/aws: double the timeout for snapshot import
us-east-1 seems to very slow these days, some imports can take up to
15 minutes. This commit raises the number of attempts before we give up.
Previously, we did 40 attempts, each delayed by 15 seconds, making the total
timeout equal to 10 minutes. Now we do 80 attempts with the same delay,
making the total timeout 20 minutes.
2020-04-15 01:16:33 +02:00
Martin Sehnoutka
7ff15e1fc2 workflow: enable updates-testing repo when installing osbuild
The source of issue here is that our release cycles are synchronized and
if we want to use the latest released osbuild we need to wait for the
bodhi process. It makes sense that we don't want to use latest osbuild
from git master but we should be confident enough in the version we
submit to bodhi.

Using the version from updates-testing therefore fixes the issue with
synchronization and avoids using unreleased versions.
2020-04-14 19:12:44 +02:00
Martin Sehnoutka
cdb4b72cf0 osbuild: add partuuid into the partition struct
The partuuid is a uuid of a specific GPT partition as opposed to the ptuuid
which is associated with the partition table and filesystem uuid which
is associated with a filesystem on a partition.

The support for partuuid was introduced in osbuild 11, see this PR for
reference: https://github.com/osbuild/osbuild/pull/306
2020-04-14 07:55:48 +02:00
Tom Gundersen
bb85acf36f dnf-json: set metadata_expire
We were using dnf's default of 48h, but that does not work for
updates repositories, as they depend on an expiration time of 6h.

Allow the metadata_expire value to be configured per repository.
If the value is unset, then never expire the metadata. Set the
value to 6h for all the fedora testing repos.

This fixes issue #476.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-04-11 19:14:02 +02:00
Martin Sehnoutka
ae294f967d distro: don't include grub2 stage in ext4 images
There is no point in having the grub2 stage in pipelines for image types
that are not bootable. The current version is probably a result of
previous refactoring where the member variable was named `IncludeFSTab`.

Moving the grub2 stage into the conditional branch should also fix test
generation on aarch64.

Finally it is necessary to regenerate test cases for non-bootable image
types.
2020-04-11 13:10:13 +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
Brian C. Lane
4f502a286c store: Set JobStarted time when PopJob is called
If you don't set the time it ends up being the default Go time which is
1/1/1 and when you convert that using UnixNano() you get a nice big
negative number (-6795364578871345152) which then eventually shows up in
the queue, finished, and failed output as 'Fri Aug 30 17:47:39 1754'
and since the Time Travel feature is not yet complete this is
impossible.

The fix is to set it when the job is started.
2020-04-11 12:42:50 +02:00
Lars Karlitski
54c44cf135 README: we're only requiring Go 1.12 right now 2020-04-09 15:18:58 +02:00
Lars Karlitski
47df3820ce jsondb: don't use error wrapping (%w)
This is a Go 1.13 feature. We're trying to run on 1.12 for now.
2020-04-09 15:18:58 +02:00
Major Hayden
a604482f09 📜 Add PR gating docs
Signed-off-by: Major Hayden <major@redhat.com>
2020-04-09 12:33:38 +00:00
Jacob Kozol
105124dd25 store: use default size in image build
If a user creates a compose with a size of 0, the default image size for
the image type should be used. Also, certain image types have
requirements for the image size. In order to ensure that the proper image
size is stored in the compose object, the compose's ImageBuild object
uses ImageType.Size() to get the correct image size for the image type.
2020-04-09 13:56:21 +02:00
Martin Sehnoutka
d702760182 test/cases: regenerate fedora test cases for x86_64
We made few changes to the format of the test cases, regenerate them to
reflect the change and also to make sure it still works.
2020-04-09 13:22:59 +02:00
Martin Sehnoutka
e769377f0e crypt_test: don't run on macOS
The new crypt tests cannot be run on macOS. Making them conditional for
non-macOS platforms fixes running unit tests in the internal directory
on macOS.
2020-04-09 13:21:30 +02:00
Lars Karlitski
17f4281648 jsondb: introduce a simple JSON database
weldr's store is quite complex and handled serialization itself. Move
that part out into a separate package `jsondb`.

This package is more generic than the store needs: it can write an
arbitrary amount of JSON documents while the store only needs one:
state.json. This is in preparation for future work, which introduces a
queue package that builds on top of `jsondb`.
2020-04-09 08:52:31 +02:00
Lars Karlitski
6bf31423a2 codecov: disable codecov/patch status
Codecov's patch status measures lines covered in a given pull request,
which fails when moving code around.

Adding code with no coverage still fails the codecov/project status,
which fails if coverage has gone down.
2020-04-08 22:26:45 +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
2b83a16c37 osbuild requirement: bump to version 11
The newest osbuild is needed for support for aarch64. The aarch64 images
are using GPT which requires stable partuuid which was included in the
latest osbuild release (11). This will be used to produce stable
image-info tests.
2020-04-07 21:14:05 +02:00
Major Hayden
f124b8e0e0 📦 Use prepared containers
We added this to osbuild but it was never added to osbuid-composer.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-07 20:16:58 +02:00
Lars Karlitski
0d3c8329c0 dnf-json: change base error type
Even though `dnf.exceptions.RepoError` is documented as the base error,
`dnf.exceptions.Error` is actually the base error (and also documented
as such).
2020-04-07 14:40:12 +02:00
Lars Karlitski
eb5b198205 dnf-json-tests: use subtests in TestCrossArchDepsolve
For one, this allows us to use `require` instead of `assert` and
`continue`, which was awkward to read. That works because it's ok to
fail a subtest: the remaining subtests are executed after it.

Also, this shows which test was executed, making debugging easier:

    === RUN   TestCrossArchDepsolve
    === RUN   TestCrossArchDepsolve/fedora-30
    === RUN   TestCrossArchDepsolve/fedora-30/x86_64
    === RUN   TestCrossArchDepsolve/fedora-30/x86_64/ami
    ...

You can now also run those sub tests in isolation:

    osbuild-dnf-json-tests -test.run TestCrossArchDepsolve/fedora-30/x86_64/ami

Lastly, it enables running those tests in parallel (not part of this
patch) by calling `t.Parallel()`.
2020-04-07 14:40:12 +02:00
Lars Karlitski
a2a6e79d21 dnf-json-tests: use assert.NoErrorf to check for errors
This function prints the formatted unexpected error message, instead of
the error struct in golang syntax.

It also allows to remove the error in the assertion message.
2020-04-07 14:40:12 +02:00
Lars Karlitski
89447a6a7b dnf-json-tests: rename repositories to repoDir
This variable holds the directory from which to load repository
information, not the repositories themselves.
2020-04-07 14:40:12 +02:00
Lars Karlitski
07d06f1efd dnf-json-tests: sort imports 2020-04-07 14:40:12 +02:00
Major Hayden
abb30b947c 🤏 Little bit more testing: weldr-tests
Signed-off-by: Major Hayden <major@redhat.com>
2020-04-07 12:19:00 +00:00
Major Hayden
af967dd8cc 🤏 Little bit more testing: osbuild-tests
Signed-off-by: Major Hayden <major@redhat.com>
2020-04-07 09:05:52 +02:00
Lars Karlitski
8ef4db816d jobqueue/api: return errors as JSON
The API is always advertising a content type of application/json, but
not sending JSON on errors.

Change it to send simple JSON objects like this:

    { "message": "something went wrong" }

This can be extended to include more structured information in the
future.

Also return an (for now) empty JSON object from `addJobHandler()`. It
returned nothing before, which is invalid JSON.

Stop testing for the actual error strings in `api_test.go`. These are
meant for humans and can change. Only check what a client could
meaningfully check for, which is only the HTTP status code right now.
2020-04-06 19:51:36 +02:00
Lars Karlitski
ce6d3c511a jobqueue/api: don't panic when error cannot be returned
Don't panic when the error message cannot be written to the connection.
Ignore it, because there's nothing we can do in this case. The standard
library has the same behavior.
2020-04-06 19:51:36 +02:00