Commit graph

537 commits

Author SHA1 Message Date
Lars Karlitski
5c019cd092 test/helpers: mark TestRoute() as a helper function
This makes the calling function/location appear when a test fails.
2020-05-08 14:53:00 +02:00
Jiri Kortus
9315ccb88e Assert existing pipelines in TestDistro_Manifest
Without the assertion some tests can just pass without actually doing
anything if no matching pipeline jsons exist.

Refs: #442
2020-05-08 10:12:28 +03:00
Jiri Kortus
3cea1f27cf Fix paths in TestDistro_Manifest
It turned out the paths contained more ../s than appropriate.

Refs: #442
2020-05-08 10:12:28 +03:00
Jiri Kortus
50df564caf Improve coverage for distro packages - F32
Refs: #442
2020-04-30 11:26:27 +02:00
Jiri Kortus
72192a0f7c Improve coverage for distro packages - F31
Refs: #442
2020-04-30 11:26:27 +02:00
Jiri Kortus
0150adae7a Use assert.NoError in F30 distro test
Refs: #442
2020-04-30 10:58:47 +02:00
Major Hayden
4f86db8ea4 🐞 Fix worker https logic
Use https scheme for workers with TLS configuration set.

Fixes #568.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-29 21:07:28 +02:00
Ondřej Budai
6513263a14 upload/azure: force .vhd extension
Azure cannot create an image from a storage blob without .vhd extension.
This commit ensures that image always has the right extension.
2020-04-29 18:15:13 +02:00
Ondřej Budai
1d52dfcc2b upload/azure: fix typos 2020-04-29 18:15:13 +02:00
Ondřej Budai
5415be465f upload/azure: remove an unneeded custom error type
The errorString was not exported and used anywhere else, this commit replaces
it with a standard method of creating simple errors.
2020-04-29 18:15:13 +02:00
Ondřej Budai
e52a35d84e upload/azure: add a context to errors
Debugging azure upload fails is currently pretty hard, this commit adds
a context to all errors Azure upload can emit.
2020-04-29 18:15:13 +02:00
Ondřej Budai
771f9bf849 azure: normalize the terms for Azure credentials
The account field is actually a storage account and the secret key is actually
a storage secret key. This is clearer to the user.
2020-04-29 18:15:13 +02:00
Jacob Kozol
51c610e1ae osbuild: remove tar image size
Image size should not be specified for a tar image. When the tar
assembler was being created image size was not passed to it. However,
the TarAssemblerOptions contained a Size field which would default to 0.
This field is removed so that the tar assembler options no longer
specify a size. The assembler tests are also updated to reflect this
change.
2020-04-29 12:36:43 +02:00
Alexander Todorov
7ce08bc788 tests: Make sure TestMain cleans up after itself
os.Exit() doesn't execute defer-ed functions, OTOH we call panic()
in case of setup errors, which does run defer-ed functions. So move
the actual test setup and execution in a separate function which will
execute all defer-ed functions and return the exit code from the
test suite to TestMain.
2020-04-27 11:53:45 +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
Jakub Rusz
32844d605a vendor: add github.com/stretchr/testify/suite 2020-04-24 11:46:13 +02:00
Jakub Rusz
42efce2811 tests: add coverage for store.go
This adds coverage for the methods working with Blueprints
2020-04-24 11:46:13 +02:00
Jiri Kortus
ae5924d29a Improve coverage for distro packages - F30
Refs: #442
2020-04-24 11:16:39 +02:00
Jiri Kortus
46e230212b Make TestDistro_Manifest more versatile
Move TestDistro_Manifest to a separate package and make it parametric,
so that it can be used to test specific distros.

Refs: #442
2020-04-24 11:16:39 +02:00
Jiri Kortus
c4d40b4b0f Fedora31 - fix Size() for vhd
Refs: #442
2020-04-24 08:30:02 +02:00
Major Hayden
1d743f048a 🐣 Add initial RHEL 8.3 support
The osbuild changes were made in osbuild/osbuild#341.

Signed-off-by: Major Hayden <major@redhat.com>
2020-04-22 15:25:59 +02:00
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
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
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
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
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
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
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
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
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
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
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
Lars Karlitski
2ac76602bb jobqueue/api: add additional test cases 2020-04-06 19:51:36 +02:00
Lars Karlitski
6083eb3867 jobqueue/api: don't redundantly set 200 OK
This wasn't done in all cases and is redundant, because the default
status is 200 OK.
2020-04-06 19:51:36 +02:00
Lars Karlitski
4cc459c5cc jobqueue: move remaining request struct to json.go 2020-04-06 19:51:36 +02:00
Alexander Todorov
bd4793eb58 tests: verify system-wide sources can't be deleted. Closes #315
make sure this test can be run both as a unit test and as an
integration test on a running system
2020-04-06 19:49:23 +02:00
Alexander Todorov
a1eb6b4cd5 tests: verify user defined sources can be deleted. Refs #315 2020-04-06 19:49:23 +02:00
Brian C. Lane
0eb3bfe89a weldr: Adding sources with empty name should return an error
Currently, if a TOML source is added with no name, or the source is
incorrectly inside a [section] it will add an empty source, causing
depsolving to crash.

This adds tests for 'name' and 'type' fields as a minimum requirement,
and returns an API error if they are empty or missing.

This also includes unit and integration tests.

Closes PR#462
2020-04-06 19:34:37 +02:00