Commit graph

727 commits

Author SHA1 Message Date
Tom Gundersen
b6ebe6ec1e repositories/RHEL: use repositories for the latest releases
Also include the GPG keys. When we first started testing we were
testing against nightlies, whose packages were not signed. But
when using released content (which is signed) the GPG keys are
required.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-30 16:09:41 +02:00
Martin Sehnoutka
92145822d9 distro: rename ListArchs to ListArches
In PR#395 we discussed the spelling of archs vs. arches and we agreed to
use arches. This patch only renames the public method `ListArchs`in the
`Distro` interface.
2020-03-30 10:41:02 +02:00
Lars Karlitski
57134548a1 .github: run unit tests only once, with coverage
We've been running the unit tests twice, once with and once without
coverage. Run them only once, with coverage.
2020-03-29 16:10:46 +02:00
Tom Gundersen
2575b611e4 repositories: add all the standard repositories
Now that these are no longer used for image testsing, they do not need
to be static. Add the standard updates and modular repositories.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +02:00
Tom Gundersen
b108d9d12c repositories: go back to using metalink
Now that the shipped repositories are no longer used for the tests,
we are no longer dependent on being reproducible, so using metalink
is ok.

This stil suffers from the fact that the mirror best for composer
is chosen, which may not be the same as the mirror best for the
worker. However, this sholud still be better than the round-robin
mirror, se we use this until proper metalink implementation is
in place.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:36 +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
Tom Gundersen
fa015a70f6 rcm: rework the API for submitting composes
The API allowed composes to have multiple architectures, image
types and repositories. Turns out that's not exactly what we want
it is not clear how to combine the lits of each. Each architecture
might not combine with each image type, and it is not clear which
repositories are need for each image build. Lastly, while allowing
different image builds to have different distros in the same
compose does not appear immediately useful, there is no particular
reason to disallow that. This patch reworks the way composes are
specified.

The intention remains the same, to be able to submit several image
builds as one compose. But rather than taking arrays of image types
and architectures, take one array of image builds instead, each of
which consists of one distro, one architecture, one image build and
an array of repositories.

In a follow-up patch they will also each contain an array of upload
targets.

This means that each image build will have the same sort of structure
as a compose request in the weldr API. The reason we want to submit
an array of them rather than have them as individual composes, is that
in a follow-up patch we will introduce the concept of a "finalizer",
or "call-back" or something to that effect, which will be triggered
when all the images have been built successfully. The use-case is,
as always, koji, which requires this.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:04 +02:00
Tom Gundersen
1c0d951f54 rcm: make repository struct private
This is only used internally to the `submit()` function.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:04 +02:00
Martin Sehnoutka
db4b6e71ed distro_test: add test that covers BuildPackages
The main reason here is not to make sure we have the right set of build
packages, but rather to make sure the pointer hierarchy (distro->arch->
image type) works as expected.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
91f572e961 fedora30,32: merge fedora3XImageType into imageType struct
This patch uses the same approach as fedora31 few commits ago. It moves
the arch pointer to the imageType struct and sets it while creating the
distro->arch->image type hierarchy in the setImageType function. The
rest of the patch is just renaming.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
ff065cc7d0 fedora30,32: merge fedora3XArch structure into arch
It uses the same approach as fedora31 few commits ago. The pointer to
distro is moved to "arch" and "arch" now contains a map of allowed
image types for each arch.

Also include setArches and setImageTypes helper functions to ease the
creation of pointers from the structures to a parent structure while
creating the distro->arches->image types hierarchy.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
507194772b fedora31: create setImageTypes and setArches helpers
Previously we had to type the name of the architecture and image type
multiple times (in the definition, when inserting it into each parent
structure etc.) and it would get even worse because we would have to do
the same for all distros. These helper functions make it less error
prone by copying the name in the function automatically.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
adae7110af fedora31: merge fedora31ImageType with imageType
The former one was just a wrapper to the second one. In this patch I
removed the fedora31ImageType struct and instead moved the pointer to
the imageType struct. The previous solution always created a new wrapper
and returned it to the called. This new solution creates a shallow copy
of imageType, assignes arch field, and then returns the result to the
caller. It should achieve the same without the additional wrapper.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
473fa3b341 fedora31: merge fedora31Arch struct into arch
It was unnecessary to have these separate any more.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
6d2d259e57 distro: remove unused FilenameFromType() function
This information is now provided only when an architecture is specified,
so it is necessary to first obtain object implementing the Arch interface
then object implementing the ImageType interface and then you can get
the filename and mime type.

Tests are changed accordingly to the new API.
2020-03-28 00:21:31 +01:00
Martin Sehnoutka
2f576e0964 weldr: stop using Distro.FilenameFromType
The method is available in the Distro interface, but the distro does not
have the information needed to provide this kind of information any
more. The logic is now split into Arch and ImageType interfaces. This
patch will allow us to get rid of some old code and move forward.
2020-03-28 00:21:31 +01:00
Jiri Kortus
5fc1f10ecb Add unit test for GRUB2 stage
Refs: #405
2020-03-27 19:18:14 +01:00
Jiri Kortus
3306a3b20e Add unit test for groups stage
Refs: #405
2020-03-27 19:11:13 +01:00
Jiri Kortus
bc52b93ece Add unit tests for fstab stage
Refs: #405
2020-03-27 19:10:42 +01:00
Jiri Kortus
ea3fccd643 Add unit tests for chrony stage
Refs: #405
2020-03-27 19:09:30 +01:00
Brian C. Lane
fc205786fc weldr: Return a JSON API error response for all unknown requests
This matches the lorax-composer behavior.
2020-03-27 19:07:33 +01:00
Brian C. Lane
e3934108f7 client: Handle the differences between unit tests and integration tests
The mock server used by unit tests is slightly different than the
running server, mostly related to package names that are hard-coded.

This adds a bool to testState that can be used in the tests to alter the
expected behavior. It should be used as little as possible.
2020-03-27 19:07:33 +01:00
Brian C. Lane
856eb59edf client: Move the weldrcheck integration tests to client
With this change the integration tests can now also be run as unit tests
against the mocked server. The way it works is this:

internal/client/unit_test.go sets up the mock server and is built
when the `integration` build tag is *not* included.

internal/client/integration_test.go sets up the connection to an
existing server and is built when the `integration` build tag *is*
included.

The test code is built and run for both cases.

Currently they all pass for the integration test run. The unit test
cases need some work because the mocked server isn't a real server with
real depsolving and package lists. A future commit will fix this.
2020-03-27 19:07:33 +01:00
Brian C. Lane
816a09fd9d client: Add integration test setup code 2020-03-27 19:07:33 +01:00
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
Lars Karlitski
32d7c68cf1 image-types: start describing image types
This is the start to document the image types that osbuild-composer
produces on a higher level than the code in the `distro` package.

The idea is to document the purpose for each of the image types as well
as the reasons why deviating from a standard install is necessary.
2020-03-26 19:16:30 +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
Alexander Todorov
7967ecbbf8 tests: Make TestSources distro independent. Refs #315
by calling `composer-cli sources info` on a user defined repository
2020-03-25 16:30:52 +01:00
Ondřej Budai
f6b3c4a994 test/images: regenerate the test cases
Previous commit changed the output of image-info, therefore the cases must be
regenerated.
2020-03-25 16:14:43 +01: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
Lars Karlitski
3b5d5a73d3 worker: drop default port
We require passing the address from the unit file. Do the same for the
socket, using host:port syntax.

Overriding the port was broken before, because we unconditionally
appended ":8700" to every address.
2020-03-25 14:05:44 +01:00
Lars Karlitski
f8982f4a1a worker: don't hard code path to unix domain socket
Introduce a mandatory argument `address`, which is interpreted as a path
to a unix socket when `-unix` is given or a network address otherwise.

Move the default path to the service file.

Add a more useful usage message when passing `-help` or no arguments.
2020-03-25 14:05:44 +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
cb4421b69f worker: remoteAddress → address 2020-03-25 14:05:44 +01:00
Lars Karlitski
94183d14a8 worker: split NewClient()
Use the default dialing functions for tcp connections and set the tls
config on the transport directly. This makes the code easier to follow,
because the only special case is overriding the DialContext() for unix
connections.
2020-03-25 14:05:44 +01:00
Lars Karlitski
845ba6e8e5 worker: don't hard code upload URL
This doesn't work with remote workers.
2020-03-25 14:05:44 +01:00
Lars Karlitski
9e71df234a worker: load tls certificates once on startup 2020-03-25 14:05:44 +01:00
Lars Karlitski
16cd243300 worker: set remoteAddress once on startup 2020-03-25 14:05:44 +01:00
Ondřej Budai
ef7e8e0772 drop packit configuration file
Packit is not used currently, therefore let's drop its configuration from the
repository. The change can be always reverted if we change our minds.
2020-03-25 11:43:39 +01:00
Ondřej Budai
0d5c2d141c spec: add notes to remove the lines related to renaming in F34
The packaging guidelines requires that these provides and obsoletes stays
in the spec file for 2 fedora versions. The name change was introduced in
Fedora 32, there the lines should be removed in F34.
2020-03-25 11:43:39 +01:00
Ondřej Budai
247e8cb205 update readmes to use the new osbuild-composer package 2020-03-25 11:43:39 +01:00
Ondřej Budai
b45119c471 spec: sync the line order and whitespace changes
In the new spec file, the tests-related code is always at the bottom of the
containing block to make the conditional code easier to read. Do the same
in the old spec file.

Also, in the new spec file, some whitespaces are different (rpmlint reported
mix used of tabs and spaces), let's do the same changes in the old spec file.
2020-03-25 11:43:39 +01:00