Commit graph

433 commits

Author SHA1 Message Date
Brian C. Lane
b5b5bd96df client: Move test setup into unit_test.go
Copy weldrcheck's utils.go into client, switch to using TestState struct
to hold global test data. Only build unit_test.go if integration has not
been selected.

This is in preparation to moving weldrcheck code into client *_test.go
files so that the test code can be shared and run against a mock server
during unit testing, or against a running WELDR API server during
integration testing.
2020-03-27 19:07:33 +01:00
Jiri Kortus
dd3fc6bd7c Add coverage for *assembler.go
Resolves: #363
2020-03-27 16:37:12 +02:00
Jiri Kortus
2d8b9c3178 Add unit test for firewall stage
Refs: #405
2020-03-27 15:22:08 +01:00
Jiri Kortus
dae77de5ac Add unit test for Fix BLS stage
Refs: #405
2020-03-27 15:21:47 +01:00
Tom Gundersen
895a4769e3 osbuild: remove dead code
The helper functions were never used, we should aim to use the
osbuild types just as regular structs for serialization purposes.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-26 00:31:37 +01:00
Lars Karlitski
b5432e78b9 worker: move ComposerClient to jobqueue package
This moves the client code into the same package as the server code,
which makes it easier to change (and version) the two in sync. Also, it
will allow to make some structs private to the jobqueue package and to
test `Client`.

Also rename it to jobqueue.Client.
2020-03-25 14:05:44 +01:00
Lars Karlitski
ee752b0ab8 tree-wide: panic when json marshalling fails
According to the new guidelines in docs/errors.md.

Note that this does not include code that marshals to a writer that
might fail (when a connection drops, for example).
2020-03-25 10:22:16 +01:00
Lars Karlitski
ad1a12f7aa tree-wide: use uuid.MustParse() when possible
According to the new guidelines in docs/errors.md.
2020-03-25 10:22:16 +01:00
Brian C. Lane
899d38422c weldrcheck: Adding integration tests for modules 2020-03-25 10:01:14 +01:00
Brian C. Lane
b5da15e2d8 client: Add /modules/ support 2020-03-25 10:01:14 +01:00
Brian C. Lane
d530d9a87e weldr: Fix projects/depsolve route handling
Return a 400 with json error message when no packages are included, with
or without trailing /
2020-03-25 10:01:14 +01:00
Brian C. Lane
3bddfd3449 weldrcheck: Adding integration tests for projects 2020-03-25 10:01:14 +01:00
Brian C. Lane
271d27a41d client: Add /projects/ support 2020-03-25 10:01:14 +01:00
Brian C. Lane
5ac3cb3f46 rpmmd: Fix the format of BuildTime to match the weldr API
The format of the BuildTime returned by /projects/list and /modules/list
does not include the 'Z' at the end. This fixed the format and adjusts
the tests.
2020-03-25 10:01:14 +01:00
Lars Karlitski
ce6dc53a12 weldr: also pass custom sources to Store.PushCompose()
Also move assembly of a list of all repositories (base + custom sources)
into its own function.
2020-03-24 22:29:41 +01:00
Lars Karlitski
3544590036 store: move adding the local target to weldr
The automatic local target is only needed when accessing the API via
weldr.

In the store, the target was only added when `stateDir` was not `nil`.
This is only used for testing which doesn't exercise the branch in
weldr. Thus, the same check is not needed there.
2020-03-24 22:29:41 +01:00
Lars Karlitski
7594cb262e store: remove job.ImageType
It is not used.

We probably need it at some point to decide which worker to give which
job to.
2020-03-24 22:29:41 +01:00
Lars Karlitski
25e926bc36 store: use Job.ImageBuildID to fetch image build
ImageBuildID is an index into Compose.ImageBuilds. Use that directly
instead of looping over ImageBuilds and matching on OutputType.
2020-03-24 22:29:41 +01:00
Lars Karlitski
f386ae43dc jobqueue: remove Job.OutputType
It is not used. The worker does not need to know the name of the
originating output type. It has all information it needs in the
manifest.
2020-03-24 22:29:41 +01:00
Martin Sehnoutka
e1e5c1bb0b distro: include xz in distro build packages
xz compression is used for the ami and tar output types, it should be in
the buildroot. This fixes Weldr integration test (/cmd/osbuild-tests) on
ARM architecture (aarch64).

The fact that it worked on x86_64 was just a happy coincidence because
we require grub2-pc which in turn requires dracut which requires xz. We
should not rely on these implicit dependencies because we need xz
unconditionaly, therefore adding it to build packages for all platforms.
2020-03-24 20:45:30 +01:00
Martin Sehnoutka
9d2dacbcab internal: pass architecture from the APIs to dnf-json
The following commit will introduce support for forced architecture in
dnf-json. The APIs already have this kind of information, so we can
simply pass it to the Depsolve and FetchMetadata functions.
2020-03-24 20:45:30 +01:00
Jakub Rusz
6f1c461c32 tests: use testify for existing blueprint_test functions 2020-03-24 20:37:10 +01:00
Jakub Rusz
833e798f1b tests: test for blueprint.GetPackages()
This also tests Package with "*" specified as version
2020-03-24 20:37:10 +01:00
Tom Gundersen
f903601ec4 distro: add ListArchs() to Distro interface
Similar to ListImageTypes() add a helper to enumerate the supported
architectures.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 15:46:57 +01:00
Tom Gundersen
4a7519807e common/Architecture: drop unused code
The intended use for this will be repalced by Arch objects, currently
it was unused, so drop it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 15:46:57 +01:00
Tom Gundersen
c66db42677 weldr/upload: uploadRequestToTarget() cannot fail
Drop the error return and simplify code accordingly.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 14:13:03 +01:00
Tom Gundersen
87b0bb6e5d distro: mass cleanup
Delete unused methods and make types and fields private where
possible. Some code is moved around, but apart from that there
is no change in behavior.

The naming of the distros were moved back into the distro
packages as the common types now only had one user, and this
allowed us to drop some redundant error checking.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 14:13:03 +01:00
Tom Gundersen
cf2ad51243 compose/ImageBuild: drop the distro field
This likely needs to be reintroduced in some fashion, but it was
unused, and when we reintroduced it it should be as a real Distro
object.

For now, drop it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 14:13:03 +01:00
Jiri Kortus
f5cf649511 Fix typo in RootFilesystemUUID
RootFilesystemUUDI -> RootFilesystemUUID
2020-03-24 11:01:20 +01:00
Brian C. Lane
3af34fba3f test: Move temporary repo setup into test/helpers.go
This allows it to be shared between the dnf-json tests and weldrcheck.
2020-03-23 21:08:01 +01:00
Brian C. Lane
222d09499c weldr: Improve the error message from sourceNewHandler 2020-03-23 21:08:01 +01:00
Brian C. Lane
6e40729cd3 weldr: Update the sourceNewHandler to use the correct struct
The store supports different fields than the API, this switches to using
an API specific struct with support for proxy and gpgkey_files.
2020-03-23 21:08:01 +01:00
Brian C. Lane
01aca4ecf7 weldrcheck: Adding integration tests for projects/source 2020-03-23 21:08:01 +01:00
Brian C. Lane
52febbdfa6 weldrcheck: Setup a temporary repository for testing 2020-03-23 21:08:01 +01:00
Brian C. Lane
3005486cb4 client: Add projects/source API support 2020-03-23 21:08:01 +01:00
Brian C. Lane
971bafbc09 Move the API struct definitions into internal/weldr
This will prevent problems with import loops. client already imports
weldr, so weldr cannot import client.
2020-03-23 21:08:01 +01:00
Brian C. Lane
0f8e40bdf1 weldrcheck: Fix typo in socket failure 2020-03-23 21:08:01 +01:00
Tom Gundersen
d642fd2c69 distro: drop redundant parts of the interfaces
Usage of these have now been entirely replaced with the newly
introduced interfaces. The individual distros should be cleaned up
and dead code removed, buth that is left for a future patch.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
7fe3421afb distro/test: use new interfaces
Test in terms of the newly introduced interfaces. This should not
have any functional effect.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
5de98458e5 ditro/registry: index by name
This is purely internal, and there is no benefit to translating
to a tag, a string identifier will do just fine.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
d7aad58897 store/PushCompose: take ImageType and Arch as argumnet rather than strings
Resolve eagerly into real objects, and avoid having to resolve and
error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
7d4ad6b649 rcm/depsolve: take ImageType as argumnet rather than strings
Use the already resolved real object, and avoid having to resolve
and error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
1597ae2ed6 rcm/submit: resolve into real Arch and ImageType objects
Rather than using the `common` package, parse the JSON as strings,
then resolve into real Arch and ImageType objects.

This should not be a behavioural change, but will simplify the code
in subsequent commits.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
96b4850554 rcm/submit: fix error handling
We were not correctly catching the case where more than one arch
or more than one image type was specified.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
8e5b79df96 weldr/uploadRequestToTarget: take ImageType as argumnet rather than a string
Resolve image type into a real object eagerly, and avoid having to
resolve and error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
bd86eaf6a5 weldr/composeTypesHandler: list image types per-arch
Currently all image types are supported on all arches, but in the
future we may want to restrict this. In that case, return the
image types that are valid for the arch in qusetion, rather than
all the possible ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
95203e0fff weldr/depsolveBlueprint: take ImageType as argumnet rather than strings
Resolve image type into a real object eagerly, and avoid having to
resolve and error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
090d01602b weldr/composeHandler: invert error handling
Check for errors and return early if they are found, rather than
check for the absence of errors.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
f201fc84b7 weldr: pin a real Arch object, rather than a string
weldr needs to know the host architecture. Rather than pinning
a string, pin a real Arch object, and query its name when we
need it.

This verifies the validitiy of the architecture for the given
distro before it is passed to weldr, rather than lazily on
demand.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
bbd8dc338d distro: introduce Arch and ImageType interfaces
Objects implementing these interfaces will represent the
architecture support for a given distro and the image type
support for a given architecture distro combination, respectively.

The idea is to always resolve to these objects early, and drop
the equilavent methods from the distro interface. This means that
we convert our input strings to real objects once, and then never
have to verify their correctness again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00