Commit graph

7238 commits

Author SHA1 Message Date
Jacob Kozol
3ae39e54c5 weldr/tests: add and update sources tests
Add tests for adding and deleting user defined sources. Update existing
tests for source info. The source being added is the fish repository.
This is the same source that the cockpit-composer tests attempt to add.
2019-11-06 21:40:31 +00:00
Jacob Kozol
a1d2f77ff1 api: add support for user defined sources
The api now supports user defined sources alongside the existing base
repository. The routes /projects/source/new and
/projects/source/delete/<name> have been added.
/projects/source/info/<names> and /projects/source/list have been
updated.

The SourceConfig type is now called from the store instead of being
declared in the api.
2019-11-06 21:40:31 +00:00
Jacob Kozol
29ebb9ff51 store: add sources to store
The api is initialized with a base repo but users may want to add their
own custom repos. Based on lorax's implementation, the store now
supports sources. The source object is similar to but not the same as
the repos used by dnf. The store can now add, delete, and get info about
sources.
2019-11-06 21:40:31 +00:00
Martin Sehnoutka
24e3e5f8be enable passing of a blueprint to osbuild-pipeline
It is enabled via a command-line argument `-blueprint`.
2019-11-04 18:37:03 +01:00
Lars Karlitski
0616844a25 dnf-json: remove 'list' command
It's not used by anything.
2019-11-04 00:17:25 +01:00
Lars Karlitski
c3e029ae82 dnf-json: don't hard-code Fedora 30
Make each command accept a `repos` key containing repository
descriptions.

Make weldr API pass the repository like this. Nothing should change,
because the repos were the same (Fedora 30).
2019-11-04 00:17:25 +01:00
Lars Karlitski
8ed07ed9cb dnf-json: move releasever and basearch into URL 2019-11-04 00:17:25 +01:00
Lars Karlitski
cae1fdd04d dnf-json: read arguments as JSON from stdin
This allows us to have more expressive input arguments.
2019-11-04 00:17:25 +01:00
Ondřej Budai
0feb4e4d44 api: improve error handling when compose push fails
There was missing condition for the case when compose push fails.
As the previous commit introduces customizations which can return even more
errors it is important to report such errors.

For now the API is returning only 500 HTTP code. In future we should
distinguish between failures and blueprint validation errors.
2019-11-02 14:10:13 +01:00
Ondřej Budai
913dc8d6c9 blueprint: integrate customizations with all output types
Customizations are ready to be used, this commit enables them. There are still
some unresolved TODOs to be solved in future. Also, tests are missing.
2019-11-02 14:10:13 +01:00
Tom Gundersen
d9e3f1f173 1
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-31 23:05:32 +01:00
Tom Gundersen
27230d3b3c submodule: bump to osbulid-5
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-31 23:05:32 +01:00
Ondřej Budai
4b546f1bbf blueprint: don't create group with the same as one of the users 2019-10-31 21:51:02 +01:00
Ondřej Budai
dc359fca3a blueprint: add support for extra packages, "modules" and groups
"modules" because they're not actual modules. Currently, it's just
a synonym to packages. This is the same behavior as lorax-composer has.
2019-10-31 21:49:09 +01:00
Ondřej Budai
93e7a26785 blueprint: fix groups definition
Group has no version field, remove it.
2019-10-31 21:49:09 +01:00
Ondřej Budai
705338c5b3 blueprint: add support for unencrypted passwords in user customization 2019-10-31 21:46:39 +01:00
Ondřej Budai
189b2b4547 crypt: fix gcc warning
Newer gcc doesn't really like strncpy producing following warnings:
warning: ‘strncpy’ specified bound depends on the length of the source argument

I switched the function to the plain old strcpy as strncpy is not necessary anyway
because we allocate the destination buffer using size returned from strlen.
2019-10-31 21:46:39 +01:00
Ondřej Budai
5b0c2cac9f Import crypt library
Copied from b3e2912865/crypt_r.go

Original sources are under MIT license
2019-10-31 21:46:39 +01:00
Jacob Kozol
2c2a20fdb7 weldr/tests: update tests to specify ignored fields
Compose tests ignore the id and timestamps and verify that the rest
of the response is as expected. The testRoute function now accepts
fields to ignore and uses dropFields to remove them from the test and
response objects.
2019-10-31 19:08:34 +01:00
Jacob Kozol
6515946369 weldr/tests: Add ability to ignore fields in the response
Certain fields (timestamps, uuids, etc.) are difficult to test for. The
dropFields function allows specific fields to be removed from an
unmarshalled json response body.
2019-10-31 19:08:34 +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
Tom Gundersen
aa404dcb99 worker: move Job type to the jobqueue package
The main purpose of this is to share the structs between the server
and the client, and let the compiler ensure that our marshaling and
unmarshaling matches.

In the future we also want to make it easier to write unittests for
this code.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-29 16:08:54 +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
Jacob Kozol
eeb657fb5b api: refactor image size in composeImageHandler
The composeImageHandler no longer needs to get the file size for an
Image because the image struct now contains the file size.
2019-10-28 02:02:16 +01:00
Jacob Kozol
4366e390cf store: add image size to compose status response
All composes now include the image size in their status response. The
image size will be 0 except for finished composes where it will be the
file length in bytes.
2019-10-28 02:02:16 +01:00
Jacob Kozol
4d94207488 store: update Image to include size
Alongside File, Name, and Mime type, each Image in the store will
contain the image size. This will default to 0 unless the compose's
status is FINISHED. Then, it  will be the length in bytes of the file.
2019-10-28 02:02:16 +01:00
Jacob Kozol
320eaf4b0c store: update ComposeEntry to include version and type
Each compose now includes the blueprint version and compose type it is
based off of.
2019-10-28 02:02:16 +01:00
Ondřej Budai
8d010c0466 blueprint: add support for kernel customization 2019-10-25 14:37:21 +02:00
Ondřej Budai
ead3ae6cab Add spec file for building RPM package
The version is set to 0 as we haven't release the first version yet.
2019-10-25 14:21:04 +02: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
Tom Gundersen
fd33ea1cc7 weldr/tests: add first version of a compose/queue test
This can serve as a starting point, but it shows there are a few
problems to solve: we need to verify json that depends on the setup,
in particular, the json the queue contains will contain UUID's that
are generated out of our control.

Moreover, the setup for this test only makes sense for internal test,
so I think we may want to change the logic for whether or not a test
sholud be supported to be run externally to be per test-function,
rather than per call to sendHTTP().

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
26995d7a1d weldr/tests: refactor tests
This does not change the behavior, but refactors according to these principles:
1) No two routes are tested in the same function (but it would be ok to split
   tests for one route over several funcions)
2) At most one testRoute() call is made per API object, and the state is
   completely set up and tore down between tets.

On top of this we should add more test cases to each of the tables, but
I'm leaving this to future PRs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
8c3cd245d8 weldr/test: split out sendHTTP helper method
This simplifies the code a bit, and will be used in follow-up patches
to distinguish between setup calls and explicit tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
f055ba2e07 store: change semantics of queue states
A job is now in "WAITING" state exactly when it is in the channel,
once it is popped it enters "RUNNING" state. It is only possible
to update the state of a job that is in the running state.

This mean that updating to "RUNNING" is entirely optional, but in
the future we may want to use this as a watchdog logic, and require
the worker to update at regular intervals to avoid being restarted.

The job queue API is updated to require a POST followed by one
or several PATCH messages to the returned ID. If a patch is sent
to an ID before the POST it is as if the object does not exist
(regarldess of it being in the queue in WAITING state or not).

Once a job has been POSTed it can be PATCHed to update it zero or
more times with (still) RUNNING before exactly oncee with either
FINISHED or FAILED.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Ondřej Budai
967b0e8ce0 blueprint: add initial support for customizations
List of currently unsupported ones:
- [[repos.git]]
- [customizations.kernel]
- [[groups]]
- [[packages]] and [[modules]]

Some of customizations have unimplemented behaviour, see TODOs
2019-10-24 15:13:47 +02:00
Ondřej Budai
86c47bc1d6 pipeline/stages: Add support for various stages defined in osbuild 2019-10-24 15:13:47 +02:00
Martin Sehnoutka
ed2dd9829c Adjust Openstack output to the Lorax one 2019-10-24 15:12:21 +02:00
Jacob Kozol
72a54b9c0e tests: specify if each test runs against external API
Not all tests will be compatible with external APIs such as Lorax. When
calling testRoute each test now declares if it can run against an
external API or not. This change allows us to test against Lorax but
skip the cases that will be invalid when not run against
osbuild-composer's API.
2019-10-23 20:53:50 +02:00
Martin Sehnoutka
bf73ee019e Adjust VHD output to the Lorax one 2019-10-23 20:52:22 +02:00
Jacob Kozol
81d9fef76a api: update api error responses to equal lorax's
In order to maintain parity with lorax the api needs to reply with an
error message equivalent to that used by lorax. Error messages are now
returned inside an error object that contains an id, message, and
optional status code.

For some routes, there are errors when no url parameters are passed. The
httprouter was using named parameters of the form /:param which does not
match for empty parameters. Now, it has been updated to use the
catch-all parameters of the form /*param. This change allows the case of
no parameters. However, parameters will now include a "/" as
their first character. This needs to be removed from the string in the
route handler.

In order to provide the proper error message for
/modules/list/<modules>, searching for the modules needed to be updated.
The requested modules and known packages are iterated over and if there
is a match the module is added to the response. Also, the found module
is dropped from the list of requested modules. If this list is not empty
after searching all of the modules then an error is returned containing
the name of the non-existant module.
2019-10-23 01:08:03 +02:00
Martin Sehnoutka
4ef4112a12 Adjust AMI output to the Lorax one 2019-10-23 01:05:14 +02:00