Commit graph

602 commits

Author SHA1 Message Date
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
Brian C. Lane
b618829d45 repositories: Fedora 32 is still under development 2020-03-18 20:46:00 +01:00
Brian C. Lane
8f8187061f dnf-json: Return an error when repo setup fails 2020-03-18 20:42:09 +01:00
Ondřej Budai
8d71773f7d 8
Release osbuild-composer version 8
2020-03-18 17:39:15 +01:00
Jakub Rusz
31a3cc6455 tests: rewrite rcm-tests to use go test framework
Fixes #311
2020-03-18 16:23:43 +01:00
Ondřej Budai
8d46da027e spec: remove the changelog
The changelog is distribution-specific, therefore it doesn't make sense
to have it upstream.
2020-03-18 15:23:26 +01:00
Lars Karlitski
1b7cb6c11b store/jobqueue: remove distro field from jobs
A job's purpose is to build an osbuild manifest and upload the results
somewhere. It should not know about which distro was used to generate
the pipeline.

Workers depended on the distro package in two ways:

1. To set an osbuild `--build-env`. This is not necessary anymore in new
   versions of osbuild. More importantly, it was wrong: it passed the
   runner from the distro that is being built, instead of one that
   matches the host.

   This patch simply removes that logic.

2. To fetch the output filename with `Distro.FilenameFromType()`. While
   that is useful, I don't think it warrants the dependency.

   This patch uses the fact that all current pipelines output exactly
   one file and uploads that. This should probably be extended in the
   future to upload all output files, or to name them explicitly in the
   upload target.

The worker should now compile to a smaller binary and do less
unnecessary work on startup (like reading repository files).
2020-03-18 12:24:20 +01:00
Martin Sehnoutka
76b236796c spec: add systemd scriptlets for the rcm subpackage
Fedora packaging guidelines require that we use scriptlets when shipping
unit files:
https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd
the rcm subpackage needs to use these as well as the main package.
2020-03-18 09:59:58 +01:00
Lars Karlitski
e70e6a72a0 weldr: remove azure-specific size check
This is already done by the distros.
2020-03-18 08:33:42 +01:00
Lars Karlitski
baa055d6ee rcm: use same function as weldr for pushing composes
Now that `Store.PushCompose()` takes a `Distro` as argument, the rcm API
can use that function as well. This moves them both through the same
code path, reducing duplication.

Remove `PushComposeRequest()` and the corresponding struct. It was
supposed to allow composes with multiple output types and architectures,
but that was not yet implemented. Merging the two now simplifies moving
the compose queue out of the store in a future commit, which will then
tackle multi-image-type composes as well.
2020-03-18 08:33:42 +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
15033faa81 rcm: pass packages when pushing a compose
In the post-dnf-stage world, `Distro.Manifest` expects the full list of
depsolved packages.  This is similar to what weldr does, but much
simpler, because the rcm API only cares about base packages.
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
Lars Karlitski
f68679c09f weldr: remove unused argument
819430e removed all `clean` arguments from rpmmd. This was a leftover.
2020-03-18 08:33:42 +01:00
Martin Sehnoutka
f5ea81e8ec add CONTRIBUTING.md file
The file contains recommendations for external contributors as well as
definition of how the code changes should look like for all of us.
2020-03-17 21:12:05 +01:00
Brian C. Lane
644a14d5f5 Update go.mod and vendor for require package 2020-03-17 21:10:00 +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
8d0984ef5d ci/lint: add integration tag
In the current PRs we have an issue with the linter failing on a dead code
in integration tests. The linter isn't failing on main_test.go file
because it somehow ignores the integration tag. However, it fails on
other files which main_test.go depends on and which have the integration
tag.

This commit tells golangci-lint to always use the integration tag while doing
the inspection.
2020-03-17 20:36:58 +01:00
Ondřej Budai
54e27e607c stage: make the unmarshalling error more verbose
Prior this commit there was no information in the log about the unrecognized
stage. This commit adds the stage name to the unmarshalling error.
2020-03-17 12:21:01 +01:00
Lars Karlitski
7a3c82a405 spec: build and install osbuild-rcm-tests 2020-03-17 08:38:15 +01:00
Ondřej Budai
5311b3a45c tests: remove test/run script
The script is not needed anymore, because Travis now uses the Go
implementation of image tests. Hurray!
2020-03-16 21:10:57 +01:00
Ondřej Budai
d83908f0cf ci/travis: switch to the Go implementation of image tests
There's now nothing preventing us from using the newer and better Go
implementation of image tests.

Also, the travis config was simplified to be more readable.
2020-03-16 21:10:57 +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
6cd1bf11c2 ci/travis: remove fedora 32 tests
We don't have any tests for fedora 32 now, let's just drop it.
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
7ea74cd131 dnf-json: pass back the repo_id and the relativepath of each package
This will eventually replace the remote_location property. The latter
pins a specific location (a specific mirror), but the two former
can together be used to re-resolve to a more suitable mirror at the
time/place the package will actually be downloaded.

Rather than pinning mirrors in the osbuild manifests, we want to be
able to include the metalink and relative locations so each worker
can use mirrors closer to them.

This would be particularly important when pipelines are rebuilt in
the future, and the best mirrors may have changed.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 23:48:42 +01:00
Tom Gundersen
6309611fea distro: avoid nil-pointer dereference on error
When a key is not fonud, there is no `err` variable set, so we should
not attempt to print it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +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
Tom Gundersen
8b940d09e2 travis: drop s390x
s390x uses LXC, we need to be run in a real VM for the osbuild tests
to work.

We did not yet have s390x support anyway, so these were noops.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
cd9dff84f1 travis: simplify the test runs
It is no longer necesary to install yum, nor use a build environment
even though we are running this in ubuntu VMs. The rpm stage needed
by the build pipeline works just fine on stock ubuntu.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
8d3be9e2c0 osbuild/stages: drop the dnf stage
This is no longer used, and will be deprecated in osbuild eventually.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
4c40faebe6 distro: move from dnf-based to rpm-based pipelines for all distros
Conceptually, we used to insert the high-level packages and package
groups into the pipeline together with the expected repository
metadata checksum.

osbuild, using the dnf stage, would then fetch the metadata, verify
that its checksum is correct, compute the dependencies, and install
the packages.

Among the problems this has is that it made it impossible to cache
and share the resolved metadata as well as the rpms. Moreover,
as the checksum was at the repository-level, rather than at the
package level, it meant that we would refuse to build a pipeline
as soon as there were any changes at all to the repository, as we
could no longer guarantee the installed packages would be the same.

As of this patch, all repository and metadata handling is done by
composer, rather than osbuild. This means that the resolved metadata
can be cached between runs, which and it means that we can now
pin individual packages, rather than the entire repository. Meaning,
that as long as the rpms are still available, we are able to build
a pipeline.

The downloading of rpms is now done by a source helper in osbuild,
which means that they can be cached and shared between runs too.

One consequence of this change is that we resolve the location of
each rpm in composer, and pass that to the worker. As the worker
may not be in the same location, we do not want to use metalinks
in composer for this, as it would pin the repository closest to
composer, rather than the runner. Instead, we now manually select
a baseurl for each repository, which should be generally the
most useful one. Fedora helpfully provides such baseurls, so
this should work ok.

The most important thing to verify when checking this commit, is
that the image info in our test-cases remains unchanged.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
4dda272d8b test/cases: include the full rpmmd structs
This includes the packgase and build-packages used by each pipeline.
For now, this information is not used anywhere, but when we move
from dnf to rpm-based pipelines, this is what will be used instead
of the repo metadata checksum.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
fe2c111ec5 submodule: update to current master
This pulls in the curl timeout fixes.
2020-03-15 19:38:59 +01:00
Tom Gundersen
2c8eec63dc test/cases: add fedora-31 tests
These tests are generated by regenerating each of the fedora-30 tests
with only the distro field changed to fedora-30.

```

for case in f30-*.json; do
	cat $case | jq '.["compose-request"]' | jq '.distro = "fedora-31"' | sudo ./tools/generate-test-cases .osbuild | jq . | sponge f31-$case
done
``

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
be03947fe5 test/cases/tar: fix up the f30-x86_64-tar-boot test case
This had not been regenrated like the other ones, insert the right
blueprint and regenerate it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
2220a76acf generate-test-cases: don't build images unless we intend to run image-info
For tarballs, this is currently not supported, so no point in generating
the images in the first place. This will still be done during testing to
boot-test them.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
2486f329e4 test/cases: rename to <distro>-<arch>-<type>-<purpose>.json
So far we only have f30, x86_64 images to be boot tested. In follow-ups
we expect to test all distros, all architectures and all image types
as boot tests.

And we also expect to do some sanity testing for all the blueprint
features we support without booting.

The AMI images can boot with an empty blueprint, the other image types
need an ssh key embedded in order to be able to connect and verify
that they booted successfully.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
cf0c3ea031 travis: streamline test definitions
No longer distinguish between the tests appart from their distro and
architecture from travis' point of view.

We must distinguish based on architecture, as we do not yet support
cross-architecture builds. We also split by distro as there is no
benefit to running tests for different distros on the same VM, as
they will not be able to share any chaches, so we might as well
parallellize them.

Tests that apply to the same distro/architecture combo are now
always run on the same VM as to utilize any caching we are able
to do.

Now that local_boot and empty_blueprint tests have been merged,
this will not increase the number of tests currently run on a
given VM, so should not affect the total running time of the
tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
841c307bf7 test/cases: merge remaining empty_blueprint and local_boot
As in 616b6250c7, add the needed
ssh key to the formerly empty blueprint, and use this test-case
for booting as well as pipeline generation verification.

For the ext4-partition image type, we also needed to add the
openssh-server package, as @core is not included by default.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
0f2b8e597e distro/test: use cmp.Diff rather than reflect.DeepEqual
This gives us more readable output. Both because it gives just a
diff, rather than the whole object as a string, but also as it
captures differences between the objects that thir string
representation does not.

In particular, if a field is an interface I, and T implements I,
then an object of type T and a pointer to the same object can both
be assigned to a variable of type I. Either way, the JSON
representation is the same, but the objects (correctly) do not
compare equal.

This is a pain to debug.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 19:38:59 +01:00
Tom Gundersen
538a16bf27 vendor: add missing directory
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