Commit graph

150 commits

Author SHA1 Message Date
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
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
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
Martin Sehnoutka
e43a30e4cf osbuild-dnf-json-tests: Introduce depsolving test
This test makes sure we can run depsolve for all build packages sets and
base packages sets for all image types for all architectures for all
defined Fedora versions. In could run the same for RHEL, but I haven't
yet implemented it, because such tests cannot run in public Internet.
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
Tom Gundersen
a385d91565 osbuild-pipeline: print more helpful info in case invalid input is given
Use the List*() functions to print the valid options in case an invalid
one is given.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 15:46:57 +01:00
Alexander Todorov
5a0ccd55db tests: Add sanity tests for sources. Refs #315, #356 2020-03-23 21:10:46 +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
Tom Gundersen
1ceb504738 osbuild-pipeline: resolve argumnets to Arch and ImageType objects
This gives us verification at the point of use for free and simplifies
the code a bit.

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
ff0ec01eb6 distro: drop NewDefaultRegistry()
Require the caller to pass in the required distros explicitly. This
would allow us to easily add distros in osbuild-pipeline and tests
before exposing them in composer itself, for instance.

This means there is no longer a dependency from the distro package
to each of the individual distros, so the distros are now able
to depend on the distro packag for types and interfaces.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
1345ca77fd store: drop the distro registry
This was now unused.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-22 22:26:09 +01:00
Lars Karlitski
1bb8f7eee0 osbuild-image-tests: add missing build constraints
Build constraints must be added to every file. We only want to build
this package when the `integration` tag is set.

Without this, every build prints this warning:

    # github.com/osbuild/osbuild-composer/cmd/osbuild-image-tests
    runtime.main_main·f: function main is undeclared in the main package
2020-03-22 13:50:28 +01:00
Ondřej Budai
7c1de17300 tests/image: use %#v when printing errors
When using %#v instead of %v, printing an error gives a slightly more
informative error message, therefore this commit switches to %#v in all
error prints.
2020-03-19 14:25:08 +01:00
Ondřej Budai
1b49755a7e tests/image: remove all distro restrictions
The distro argument and restrictions to run only tests for the same distro
as the host's one were confusing. This commit removes them. Now the behaviour
is following:

By default all the test cases in test case directory are run.
If test cases are given by arguments, they are all run, and test case
directory is ignored.
2020-03-19 14:25:08 +01:00
Ondřej Budai
832fb44eb8 tests/image: give the test VM only 1 GB of memory
The VM doesn't need 2 GBs to start Fedora and ssh server. This fix enables
us to run the tests in more constrained environment.
2020-03-19 14:25:08 +01:00
Ondřej Budai
3cb2a5f930 tests/image: remove the hack for fedora-30
Previously we had only tests for Fedora 30, therefore I added a hack to treat
every Fedora as Fedora 30, so the tests would run. Now, we have tests for
multiple Fedora versions, therefore the hack is no longer needed.
2020-03-19 14:25:08 +01:00
Ondřej Budai
acfb461aa5 tests/image: switch the implementation to go testing framework
We're currently rewriting all the integration tests to use the Go
testing framework. This commit does the switch for the image tests.

I decided not to use the testing framework in functions which are
not directly tight to testing (booting images, running osbuild). I think
it's reasonable to use classic error handling there and propagate the errors
to places directly tight to testing and use the testing library.
This enables us to reuse the code in different part of projects if needed.
2020-03-19 14:25:08 +01:00
Jiri Kortus
48027293cb Use testing module syntax and asserts in osbuild-tests
Fixes #312
2020-03-19 13:22:14 +02:00
Lars Karlitski
77556973cc distro: don't expose repositories in distro objects
Mixing the way to build a distribution with where to get the source
packages from is wrong: it breaks pre-release repos, local mirrors, and
other use cases. To accommodate those, we introduced
`/etc/osbuild-composer/repositories`.

However, that doesn't work for the RCM API, which receives repository
URLs to use from outside requests. This API has been wrongly using the
`additionalRepos` parameter to inject those repos. That's broken,
because the resulting manifests contained both the installed repos and
the repos from the request.

To fix this, stop exposing repositories from the distros, but require
passing them on every call to `Manifest()`. This makes `additionalRepos`
redundant.

Fixes #341
2020-03-18 20:46:28 +01:00
Jakub Rusz
31a3cc6455 tests: rewrite rcm-tests to use go test framework
Fixes #311
2020-03-18 16:23:43 +01:00
Lars Karlitski
0f1a014aca store: don't keep a "default" distro
Only the weldr API has the concept of a default distro. Pass that distro
explicitly to `PushCompose()` and fetch the distro from the compose in
all other functions that accessed Store.Distro.
2020-03-18 08:33:42 +01:00
Lars Karlitski
c2c8fae093 store: give ComposeRequest a real distro
`ComposeRequest` included a `common.Distribution`, which had to be
resolved in PushComposeRequest. Use a real `distro.Distro` object here,
and push resolving it to the rcm package.

Change the `Distribution` on the (lower-case) `composeRequest` to a
string. This struct represents the incoming request. Since we're now
resolving the real distro object from the registry in the same function,
it seems redundant to validate the incoming distro twice.
2020-03-18 08:33:42 +01:00
Brian C. Lane
548c58ddda weldrcheck: Convert to go testing framework + testify/require
Convert weldrcheck to use the standard go testing framework along with
the github.com/stretchr/testify/require assert package.

This also removes the cmd/osbuild-weldr-tests and builds the test binary
directly from the weldrcheck package. This makes it easier to organize
the code instead of putting it all into a single main_test.go file.
2020-03-17 21:10:00 +01:00
Ondřej Budai
15e905b4d2 tests/image: add option to filter test cases by distro
By default, image test executable runs only test cases for the same distro
as the host's one. On Travis there's Ubuntu, so we need to adjust the
behaviour and run the cases for a distro specified by command line
arguments.
2020-03-16 21:10:57 +01:00
Ondřej Budai
dc9c82fd96 tests/image: add path constants for Travis CI
The new set of constants allows to run the tests on Travis. The tests must
be build by:

go build -tags travis ./cmd/osbuild-image-tests
2020-03-16 21:10:57 +01:00
Ondřej Budai
03ae0007af tests/image: extract constants containing paths
We need to use different values for path constants when running the tests
on the Travis CI. This is the first step to achieve this.

Note that this commit may be reverted when Travis CI is dropped.
2020-03-16 21:10:57 +01:00
Ondřej Budai
d4ecebd38a tests/image: rename the main source file
To be consistent with other binaries.
2020-03-16 21:10:57 +01:00
Martin Sehnoutka
9f4042af6c osbuild-composer: don't use hardcoded state directory
Use $STATE_DIRECTORY environment variable which is set by systemd
because we use: StateDirectory=osbuild-composer in the service unit.

also change systemd unit to include STATE_DIRECTORY, because
RHEL comes with older systemd version, so we need to set this variable explicitly.
2020-03-16 21:05:39 +01:00
Tom Gundersen
7957feff48 distro.Manifest: take Customizations rather than Blueprint as argument
This makes two changes simultaneously, to avoid too much churn:
 - move accessors from being on the blueprint struct to the
   customizations struct, and
 - pass the customizations struct rather than the whole blueprint
   as argumnet to distro.Manifest().

@larskarlitski pointed out in a previous review that it feels
redundant to pass the whole blueprint as well as the list of
packages to the Manifest funciton. Indeed it is, so this
simplifies things a bit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 23:48:42 +01:00
Tom Gundersen
5d179428be rpmmd: drop the Name attribute from RepoConfig
This was never actually used anywhere, as passing it to dnf-json
was a noop.

We may want to reconsider the concept of a source/repo name and
how it differs from an ID, but for now drop the name.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 23:48:42 +01:00
Tom Gundersen
8400b39577 distro.Manifest: drop checksums parameter
This is no longer used to generate pipelines, but has been replaced
by the package specs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
819430e659 rpmmd: no longer flush the caches on every call
When we used the dnf-based pipelines, we were relying on the fact
that the metadata was unlikely to have changed between we generated
the pipeline and called osbuild. We achieved this by always updating
to the most recent metadata on every call to rpmmd.Depsolve that
would end up in a pipelin.

Refreshing the metadata is time-consuming, and something we want
to avoid if at all possible. Now that our pipelines no longer
rely on this property, we can drop the flushing.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Ondřej Budai
b4a7bc6467 tests/image: add booting tests
This commit makes the osbuild-image-tests binary doing the same set of tests
like the old test/run script.

Changes from test/run:
- qemu/nspawn are now killed gracefully. Firstly, SIGTERM is sent.
  If the process doesn't exit till the timeout, SIGKILL is sent.
  I changed this because nspawn leaves some artifacts behind when killed
  by SIGKILL.
- the unsharing of network namespace now works differently because of
  systemd issue #15079
2020-03-13 18:06:56 +01:00
Ondřej Budai
f060c8d795 tests/image: fix testcase struct
The field compose was renamed in caca553, therefore also the image tests got
broken. This commit fixes it.
2020-03-13 18:06:56 +01:00
Tom Gundersen
333a1f3500 osbuild-pipeline: read the blueprint from stdin
Make the bluprint parameter a bool, and if set, then read a
blueprint from stdin, otherwise an empty blueprint is used.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Tom Gundersen
40040f2cc8 osbuild-pipeline: make blueprint optional
If no blueprint is provided, consider that the same as the empty
blueprint.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Alexander Todorov
b81580081b Use asserts in tests. Refs #309 2020-03-13 14:01:18 +01:00
Lars Karlitski
efb2975e36 tree-wide: run go fmt 2020-03-10 23:38:03 +01:00
Alexander Todorov
bd46389059 tests: use go's test framework in osbuild-dnf-json-tests
This allows us to take advantage of the `testing` package. It also gives
the resulting test binary common command line arguments (same as `go
test`).

Tests need to be compiled with `go test -c`, which injects a `Main()`
that calls the Test* functions.

This is not supported by the golang rpm macros. Thus, build this binary
by calling `go test -c` directly, but taking care to pass the same
linker flags as the `%gobuild` macro.

Mark the test binary with the `integration` build constraint, so that
`go test ./...` doesn't pick them up. That's only for unit tests.

The idea is to move all other test binaries to this scheme as well.

Spec file changes by Lars Karlitski <lars@karlitski.net>
2020-03-10 20:29:19 +01:00
Jacob Kozol
2ce40e179a osbuild-pipeline: add rpmmd flag and output
A developer may want to use the output of rpmmd (build package specs,
package specs, and checksums) instead of the pipeline manifest. In this
case they may pass the -rpmmd flag to osbuild-pipeline. With this flag,
instead of returning the pipeline, it will return the output of rpmmd.
2020-03-10 17:26:37 +01:00
Martin Sehnoutka
245e6ad6e7 rcm tests: document the test cases
The purpose of this documentation is to describe how the user is
expected to work with the RCM API. It can also serve as an example for
creating automation scripts if the RCM teams wants to create some.
2020-03-09 18:08:43 +01:00
Martin Sehnoutka
3b3d22d91e rcm tests: add get status test
This is a very basic test to get the status of a single compose. It will
evolve as the API gains support for Koji builds.
2020-03-09 18:08:43 +01:00