Commit graph

76 commits

Author SHA1 Message Date
Lars Karlitski
ad11ceecf4 worker: use openapi spec and generated code
Write an openapi spec for the worker API and use `deepmap/oapi-codegen`
to generate scaffolding for the server-side using the `labstack/echo`
server.

Incidentally, echo by default returns the errors in the same format that
worker API always has:

    { "message": "..." }

The API itself is unchanged to make this change easier to understand. It
will be changed to better suit our needs in future commits.
2020-09-06 18:42:23 +01:00
Tom Gundersen
b7fb52dc7d 20
Release osbuild-composer version 20.
2020-08-23 16:44:07 +02:00
Tom Gundersen
b0cd29f78b worker: support returning returning images as StreamOptimized
vCenter requires images to be uploaded as vmdk StreamOptimized. Lorax
always produced images on this format, so we should make sure to do the
same for our VMWare images.

Allow LocalTarget to request the images produced by osbuild be converted
to be streamOptimized before saving in composer, and hook the weldr API
up to enable this option for vmdk images.

Ideally this should simply be an option in osbuild, but that would
require some more work, which we will not manage in time for RHEL8.3.
Therefore do this minimal fix.

Note that that means the images produced by our manifests (including in
our image-test test cases) are not on the format that the weldr API
returns, so the tests we run on them would also, for now, need to
convert before uploading to vCenter.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-23 14:45:27 +02:00
Tom Gundersen
06c8461684 19
Release osbuild-composer 19.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-10 21:46:25 +02:00
Ondřej Budai
5ab8b59803 18
Release osbuild-composer version 18.
2020-07-22 17:04:23 +02:00
Tom Gundersen
fbfa191c81 rcm: drop sub-package
The osbuild-composer-rcm package was never finished, not in use and will be replaced by osbulid-composer-koji.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-07-17 19:13:15 +01:00
Ondřej Budai
add2ad98e0 17
Release osbuild-composer version 17
2020-07-08 17:35:27 +02:00
Ondřej Budai
534c508c41 16
Release osbuild-composer version 16
2020-06-29 19:48:46 +02:00
Ondřej Budai
ee782c6860 spec: sync
f7c4dca5 and 6d7181e8 changed the new spec file but omitted the changes from
the old one. This commit syncs them for consistency sake.
2020-06-29 19:48:46 +02:00
Ondřej Budai
5991666b8a spec: make the subpackages require a matching version of composer
The subpackages are not really meant to be used with a different version of
the osbuild-composer package. This commit enforces.the usage of a matching
version in the spec file.
2020-06-15 07:18:31 -05:00
Ondřej Budai
6bc200df14 15
Release osbuild-composer version 15
2020-06-12 14:15:49 +02:00
Tom Gundersen
cffb527a39 spec: bump osbuild deps
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-11 19:17:03 +02:00
Ondřej Budai
a8f6281da2 14
Release osbuild-composer version 14
2020-06-03 23:35:09 +02:00
Ondřej Budai
5f9215cbcb sync the specfiles
20c40b59 added a dependency to osbuild-ostree. However, it wasn't added to the
old specfile. This commit fixes it.

The old specfile is used only on Fedora 31. which might never get the support
for building ostree images, but I prefer the two specfiles to be as close to
each other as possible.
2020-06-03 23:35:09 +02:00
Ondřej Budai
76c18566fc spec: exclude i686 architecture
RHEL 8 doesn't have golang in the i686 buildroot anymore. Fedora doesn't have
i686 images and kernel anymore. Also, osbuild-composer doesn't have support
for building i686.

Let's exclude i686 for these reasons, it's dead.
2020-05-28 19:44:13 +02:00
Ondřej Budai
5f0dffefe4 13
Release osbuild-composer version 13
2020-05-28 09:44:36 +02:00
Ondřej Budai
fcd3394a82 spec: bump the osbuild dependency to version 15
The new Fedora IoT image type uses org.osbuild.ostree.commit assembler with
tar option that was introduced in osbuild 15, therefore the dependency version
must be bumped.

This also bumps the submodule to 9cbedc04. That's basically version 15 of
osbuild with one fix related to secrets.
2020-05-28 00:31:30 +02:00
Ondřej Budai
e2c9b9d881 12
Release osbuild-composer version 12
2020-05-14 07:30:56 +02:00
Ondřej Budai
169f54ed34 11
Release osbuild-composer version 11
2020-04-29 20:42:37 +02:00
Ondřej Budai
c6b9bf4545 spec: fix warnings during the package removal
Currently, removing osbuild-composer produces these warnings:

Failed to stop osbuild-worker@.service: Unit name
osbuild-worker@.service is missing the instance name.
See system logs and 'systemctl status osbuild-worker@.service' for details.
Failed to stop osbuild-remote-worker@.service: Unit name
osbuild-remote-worker@.service is missing the instance name.
See system logs and 'systemctl status osbuild-remote-worker@.service' for
details.

%systemd_preun calls on a package upgrade this:
systemctl --no-reload disable --now [ARGS...]

I tried using a wildcard:

systemctl --no-reload disable --now "osbuild-worker@*.service"

But this gives:

Invalid unit name "osbuild-worker@*.service" was escaped as
"osbuild-worker@\x2a.service" (maybe you should use systemd-escape?)
Failed to disable unit: Unit file osbuild-worker@\x2a.service does not exist.

In the end I decided to use two commands - disable and stop. Disable works
without a wildcard, stop requires one. This solution should mimic systemctl
disable --now pretty well.
2020-04-29 10:50:58 +02:00
Ondřej Budai
e3acf45588 spec: fix warnings during the package upgrade
Currently, upgrading osbuild-composer produces these warnings:

Failed to try-restart osbuild-worker@.service: Unit name
osbuild-worker@.service is missing the instance name.
See system logs and 'systemctl status osbuild-worker@.service' for details.
Failed to try-restart osbuild-remote-worker@.service: Unit name
osbuild-remote-worker@.service is missing the instance name.
See system logs and 'systemctl status osbuild-remote-worker@.service'
for details.

%systemd_postun_with_restart calls on a package upgrade this:
systemctl try-restart [ARGS...]

However, try-restart requires using a wildcard when restarting all
the services created from a template unit. This commit therefore adds the
wildcards.
2020-04-29 10:50:58 +02:00
Ondřej Budai
e235fdedb3 tests/image: boot the vhd images on Azure
Previously, vhd images were tested using QEMU. This commit changes that to
boot them in the actual Azure infrastructure.

Azure VMs have quite a lot of dependencies - a network interface, a virtual
network, a network security group, a public ip address and a disk. Azure CLI
and Azure Portal handle the creation of all these resources internally.
However, when using the API, the caller is responsible to create all these
resources before creating an actual VM.

To handle the creation of all the resources in the right order, a deployment
is used. A deployment is a set of resources defined in a JSON document.
It can optionally take parameters to customize each deployment. After the
deployment is finished, the VM is up and ready to be tested using SSH.

Sadly, the deployments are a bit hard to clean-up. One would expect that
deleting a deployment removes all the deployed resources. However, it doesn't
work this way and therefore it's needed to clean up all resources "manually".
For this reason, our deployment sets a unique tag on all the resources created
by the deployment. After this test is finished, the API is queried for all
the resources with the tag and then, they're deleted in the right order.
2020-04-27 20:34:20 +02:00
Ondřej Budai
5d77188de0 bump osbuild to version 12
We will soon need the support for vhdx format, which is supported since
osbuild 12.

This commit bumps the dependency in the spec file and also updates the
submodule.
2020-04-24 15:27:39 +02:00
Ondřej Budai
dbfc2a0929 10
Release osbuild-composer version 10
2020-04-15 16:59:42 +02:00
Martin Sehnoutka
2b83a16c37 osbuild requirement: bump to version 11
The newest osbuild is needed for support for aarch64. The aarch64 images
are using GPT which requires stable partuuid which was included in the
latest osbuild release (11). This will be used to produce stable
image-info tests.
2020-04-07 21:14:05 +02:00
Ondřej Budai
09109b4f8e 9
Release osbuild-composer version 9
2020-04-01 15:56:57 +02:00
Lars Karlitski
c5823d92b4 spec: build test binaries against installed libraries
On Fedora, the `%gobuild` macro turns off go modules and sets gopath to
installed libraries (in `/usr/share/gocode`).

When building the test binaries, we used `go test -c` directly, which
downloaded the libraries into GOPATH. That's wasteful and doesn't work
in mock (without internet). Replicate what `%gobuild` does by setting
`GO111MODULE=off` and `GOPATH` to the correct value.

RHEL uses modules as intended. No change is necessary.
2020-03-31 09:48:23 +02: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
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
Ondřej Budai
cdc4248909 spec: use the standard way to represent a go dependency
This isn't a functional change.
2020-03-25 11:43:39 +01:00
Jakub Rusz
6603ae8d74 spec: add testify to BuildRequires 2020-03-24 10:59:15 +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
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
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
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
Lars Karlitski
7a3c82a405 spec: build and install osbuild-rcm-tests 2020-03-17 08:38:15 +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
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
Ondřej Budai
d3d16b6afa 7
Release osbuild-composer version 7
2020-03-05 17:30:50 +01:00
Ondřej Budai
a504fc8801 spec: add weldr provide
Since the recent commit (04db4fa) we are no longer provider
of lorax-composer. This was needed because when installing cockpit-composer,
which depends on lorax-composer, dnf chose us as the lorax-composer provider
instead of the original lorax-composer package. As we are not yet ready to
fully replace lorax-composer, this broke the cockpit-composer tests.

This commit is the first part of long term fix. Osbuild-composer is now
a provider of weldr. Soon, lorax-composer will also be a provider of
weldr. After that, cockpit-composer will be switched to be depending
on weldr. Also, it will suggest lorax-composer, which will force dnf
to use lorax-composer as the default weldr backend. If someone wants
to experiment with osbuild-composer, it will be possible, because
it will also be a provider of weldr and there will be no need to
install lorax-composer to satisfy cockpit-composer dependencies.
2020-03-05 15:39:08 +01:00
Lars Karlitski
04db4fa3f5 spec: remove lorax-composer provide
We're not fully compatible with lorax-composer's API yet, and we don't
provide lorax-composer's systemd unit files.

As a result, cockpit-composer's integration tests fail, because `dnf
install lorax-composer` on Fedora can result in installing
osbuild-composer in some cases.
2020-03-05 11:04:30 +01:00
Brian C. Lane
2d4e4d14d0 Add osbuild-weldr-tests to run the weldr integration tests
This runs tests against a running API server, either lorax-composer or
osbuild-composer, and reports the results to stdout. It uses the
/run/weldr/api.socket to communicate with the server.
2020-03-03 12:21:40 +01:00
Ondřej Budai
6a37883c1e spec: move worker-related service units to worker sub-package
Prior this commit installing the worker sub-packages shows the following
warning:

Failed to preset unit: Unit file osbuild-worker@.service does not exist.

Moving the unit file to the sub-package fixes it.
2020-03-02 14:29:38 +01:00
Ondřej Budai
0dcd16aa36 tests: begin rewriting of ./test/run test suite to Go
./test/run test suite has served us well over the last months. However,
there is currently a major effort to run the better defined integration
test suite on a CI. Nonetheless, two very important parts are still missing
from the integration test suite: inspecting the image with image-info
and booting the image. This commit begins the work on this matter by porting
a part of ./test/run suite to Go. Currently, only image-info tests work, the
rest will come in the following commits.
2020-02-26 16:58:39 +01:00
Brian C. Lane
58839cf927 Use semver to enforce blueprint version numbers
This changes osbuild-composer's behavior to match lorax-composer when
encountering invalid versions. Instead of leaving them as-is it will
return a BlueprintError explaining the problem. eg.

"errors": [
    {
        "id": "BlueprintsError",
        "msg": "Invalid 'version', must use Semantic Versioning:  is not in dotted-tri format"
    }
]

This is enforced on new blueprints (including the workspace). If a
previously stored blueprint has an invalid version and a new one is
pushed it will use the new version number instead of trying to bump the
invalid one.

This also moves the version bump logic into blueprint instead of store,
and adds an Initialize function that will make sure that the blueprint
has sane default values for any missing fields.

This includes tests for the Initialize and BumpVersion functions.
2020-02-25 09:00:35 +01:00
Tom Gundersen
ca599a8f6f 6
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-24 16:25:13 +01:00
Martin Sehnoutka
28a1230105 spec: create rcm subpackage
We don't want to ship the RCM API socket unit in the main
osbuild-composer package. This way it will be only available in the -rcm
subpackage.
2020-02-24 12:03:25 +01:00