Commit graph

109 commits

Author SHA1 Message Date
Ondřej Budai
039fc6b618 test/builder: drop misleading quotes from config
configparser treats quotes literally:

client_id = "koji"

translates to the following python string:

'"koji"'

This doesn't matter in the test because the oauth mock from osbuild-composer
actually ignores the credentials and return the token in every case.

But if you want to take this config as an example, you will probably put the
credentials automatically inside the quotes which will not work because a real
oauth server will refuse the client ID surrounded by quotes.

Note that .conf works different than .toml:

TOML requires to have strings in quotes. Yeah, consistency. 🤷
2022-03-23 17:53:30 +01:00
Christian Kellner
9562deb983 builder: use correct secret when fetching token
Use the `self.secret` and not `self.id` for the secret. Doh. Mea culpa.
Fix the corresponding test as well, which also checked for the wrong
thing.

Reported-By: Ondřej Budai <ondrej@budai.cz>
2022-03-23 15:21:48 +01:00
Christian Kellner
f559c18079 plugins: support for repo package sets
This adds support for specifing the package sets for repositories;
on the command line this can be done via `--repo-package-set` with
and argument of `;` separated package set names. This will result
in repo information being transported via dict instead of plain
strings. Thus the hub plugin's schema was modified accordingly.
Last but not least, the builder plugin now can decode these dicts
and setup the repos accordingly.
Test were added for plugins as well as the integration test changed
to use this new feature.
The first upstream commit that supports this feature is pinned.
2022-02-15 17:35:29 +01:00
Christian Kellner
5d2f6c6daa test/integration: properly match distro to host
When we are on an RHEL 8.x host we need to supply `rhel-8x` as
target distro. The previous code just used the major version so
we always built `rhel-8`, i.e. RHEL 8.3.
2022-02-15 17:35:29 +01:00
Christian Kellner
78ed04dbd6 plugins: support for ostree specific options
OStree compose requests need special options, like the `ref` the
`parent` and the `url`. Add support for those options to all three
plugins:
  The command line plugin now takes `--ostree-{parent,ref,url}`
  and passes it to koji via the existing options dictionary.

  The JSON schemata in the hub plugin was adjusted to allow these
  new options.

  Finally the builder plugin will look for the new `ostree` dict
  inside the options, create an `OSTreeOptions` object from it,
  and attach it to each image request.

NB: since the ostree options are per image request and are thus
architecture dependent we support a "$arch" substition in the
`parent` and `ref` options that will be resolved by the plugin;
this allows to builds arch specific commits for with a single
compose request.

Add the respective unit tests.
2022-02-14 13:14:19 +01:00
Christian Kellner
47af69254c builder: map koji api image types to cloud ones
Map the image types used by the koji API to the image types used
by the cloud api. This should allow for a smooth transition when
the plugin is upgraded, i.e. the pungi configuration can be used
unmodified. After all the plugins are upgraded the pungi config
should be changed to use the native image types and then this
mapping could be removed again.
2022-02-11 16:36:07 +01:00
Christian Kellner
4edca7a82a test/builder: validate image type in request
Take the current list of valid image types currently supported by
the cloud api and validdate it during the compose request. Also
allow a test "image_type" image type which is used all over the
place in the testing code.
2022-02-11 16:36:07 +01:00
Christian Kellner
54c59cc41c builder: use cloud api
Composer now[1] has integrated the koji API into the "cloud API"
and thus we can use this more general purpose and powerful API
instead of using the specialized koji API endpoint.
Adapt the request and response structures as well as the unit
tests to use that.

[1] PR #2214, commit 11e2ae45284bfb0d89ef1c1e0d2aa4ae230ea573
2022-02-11 16:36:07 +01:00
Christian Kellner
c1a887a9a9 test: switch to using oauth/sso
Switch the authentication method that the koji builder plugin
uses from mTLS to SSO. Since we are using the mock openid
server from the `osbuild-composer-tests` package. Make this
package a dependency of `koji-osbuild-tests`.
2022-02-02 13:33:21 +01:00
Christian Kellner
4e1039bed7 test: add helper script to run openid server
Add a new helper script to run the mock open id server that is
shipped inside the osbuild-composer-tests package.
2022-02-02 13:33:21 +01:00
Christian Kellner
940e122ae9 builder: support for sso via oauth2
Implement support for authentication via OAuth2 using the client
credentials "Client Credentials Grant" flow (4.4 of RFC 6749).
For this a new configuration section is added to the config file,
where the client_id, client_secret and token_url have to be
specified.
The impelmention does currently not support "refresh tokens", but
does support refreshing the token if an `expires_in` is present
in the token itself.
Corresponding unit tests have been added.

[1] https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
2022-02-02 13:33:21 +01:00
Christian Kellner
b80fd4d7f6 test: integration tests adapt to the host
Change the integration test so that it adapts to the host, i.e. it
will take the name, version and architecture for the tags and urls
for the repos from the host it is running on. This should make it
more future proof since we now have a central place where this is
configured: the ci configuration, i.e. `.gitlab-ci.yml`.
2022-01-31 15:55:26 +01:00
Christian Kellner
1a5977bad2 builder: move ssl arguments to global options
When the builder is used as a command line argument: move the
ssl related options to the global parser so they can be used
with status and wait too.
2022-01-26 18:02:33 +01:00
Christian Kellner
2ca0f3b370 builder: make repo a proper optional argument
When the builder is used as an command line binary: have `repo`
be a proper command line argument. It was currently specified
before arch which can be passed multiple times, but so does
repo; hence one of them needs to be optional.
2022-01-26 18:02:33 +01:00
Christian Kellner
a6cb711e1c test: use importlib instead of imp
Replace the usage of `imp` with `importlib` because the former
is deprecated and newer pylint will complain and break CI.
2021-10-05 12:18:46 +02:00
Alexander Todorov
e778771f2b Remove rhel.repo to avoid dnf being confused
when building the containers the initial `dnf upgrade` will download
content from the latest nightly trees which turns the container into a
Beta system and subsequent `dnf isntall` gets confused!
2021-07-29 11:19:33 +02:00
Ondřej Budai
3ceeb47333 tests: change all mentions of Fedora 32 to Fedora 33
Fedora 32 is EOL, let's use Fedora 33. (Fedora 34 is not yet
100% supported in composer).
2021-07-23 15:24:05 +02:00
Christian Kellner
345265e9d2 test/builder: check manifest fetching
Add a test that checks that manifests are indeed uploaded and
another test that simulates a failure while fetching manifests.
2021-02-25 16:01:51 +01:00
Ondřej Budai
0bcac397a3 test: remove the podman-plugins workaround
Fix for https://bugzilla.redhat.com/show_bug.cgi?id=1877865 is now shipped in
8.3.
2021-02-25 14:46:34 +01:00
Ondřej Budai
4fdc457745 test/integration: define podman network gateway manually
Podman 2.2.0 doesn't create a gateway by default. See:
https://github.com/containers/podman/issues/8748

This commits introduces a workaround: specifying the gateway manually.

Note that the gateway is used in test/run-builder.sh
2020-12-16 15:32:28 +01:00
Ondřej Budai
4603578b62 test/integration.sh: install podman-plugins from RPMRepo
The nightly disappeared again. We now have an 8.4.0 snapshot that contains
the package. Let's use it.
2020-12-16 15:32:28 +01:00
Lars Karlitski
d9cb6217ef test/integration.sh: bump nightly
The current one is not available anymore. We cannot use rpmrepo for this
yet, because the podman-plugins package is too new.
2020-12-01 10:48:08 +01:00
Christian Kellner
c282b9b1f0 test: replace docker.io with fedora's registry
In order to avoid running into docker.io's new download limit,
use the container directly from registry.fedoraproject.org.
2020-11-22 23:53:38 +01:00
Christian Kellner
d0216a7ef0 test: copy the plugin in the run scripts
If called from within the source directory, i.e. the local plugin
exists, copy those to the share directory so they can be picked
up by the entry point scripts, in case the rpms are not found.
2020-11-19 11:22:54 +00:00
Christian Kellner
b74e440028 test/make-tags: add Fedora-IoT to f32-candidate
This is just for local testing of Fedora IoT commits, which should
be named properly.
2020-11-19 11:22:54 +00:00
Christian Kellner
8705c0aa68 test/container: ensure koji plugin paths exist
When using the local plugin, ensure the destination plugin path
exists before copying, otherwise it will fail.
2020-11-19 11:22:54 +00:00
Christian Kellner
ba25e0f3d7 test: use absolute path in run-builder.sh
In case `TEST_PATH` was not specified as command line argument,
it was falling back to `test`. Make the latter an absolute path,
by pre-pending `PWD`, otherwise podman complains about the name
of the volume.
2020-11-19 11:22:54 +00:00
Christian Kellner
c826db38e7 test: match container version to host
Instead of just using the "latest" container everywhere, which will
change every time a new release is made, add a build argument to
specify the version and then match that version to the host in all
the build scripts. This will make it possible to use the tests for
gating, and ensure that we test the plugins on the OS version that
is targeted.
2020-11-19 11:22:54 +00:00
Christian Kellner
d60dd9f362 test: make hub container self contained
Instead of building on the existing quay.io/osbuild/koji:v1, and
then replacing a lot of it (entry point), move the packages and
the dnf.conf change over from the former base and then directly
depend on Fedora. This gives us more control, especially over
what Fedora version is being used.
2020-11-19 11:22:54 +00:00
Lars Karlitski
16f762c2ed test: move to koji-osbuild-tests package
This is similar to how other osbuild packages are testing: everything
that's needed for testing is included in the tests package or a
dependency of it. The test runner then runs every executable in
/usr/libexec/tests/<packagename>. This gives a simple test API to
projects depending on this package (notably osbuild-composer).

The local development workflow described in HACKING.md is meant to
continue to work. To ensure this, all relevant scripts gained a
TEST_DATA variable, which defaults to `./test`, but is set from $1 to
the installed path from integration.sh.
2020-11-19 09:28:28 +01:00
Lars Karlitski
ade02b0c9a test: pull podman-plugins from internal RHEL repo
Instead of taking podman-plugins from the source directory, use the one
that will be released into RHEL 8.3.1.

This will simplify moving tests into an rpm.
2020-11-19 09:28:28 +01:00
Christian Kellner
c2b5bd7060 builder: attach koji init/import logs
De-serialize the koji init and import logs, required fields in the
ComposeLogs, and if non-empty, attach them to the task.
Update the tests to check for the presence of these logs.
2020-11-17 16:05:39 +01:00
Christian Kellner
68309e4b5a builder: use koji_build_id from ComposeStatus
Instead of getting the `koji_build_id` from the direct reply of
the compose request call, use the one returned in the compose
status.
The reason behind this is that composer was changed so that the
CGInitBuild call to koji is now being done by a worker and not
composer itself. This means that once the compose request call
returns, the build id is not yet known. In composer release 24,
the compose request call internally waits for the worker that
does the CGInitBuild API call, but that will be changed, and
the koji_build_id will then not be returned from the compose
request API call anymore. This prepares for that. The tests are
also adapted to simulate the new behavior.

NB: this makes composer 24 a dependency, since the build id is
taken from the ComposeStatus, which was only added there.
2020-11-17 13:35:52 +00:00
Christian Kellner
d7bfaee189 plugins: ability to skip the tagging
Add a new command line option `--skip-tag` that will skip tagging
after a successful build. The help text is copied from the same
option of other sub-commands in the koji client. The hub plugin's
jsonschema was updated accordingly, and the builder plugin will
skip the tag if the option was requested.
Tests were added or augmented for all three plugins to test the
new option.
2020-11-16 17:00:40 +01:00
Christian Kellner
4290a3123c test/builder: check compose-status.json uploads
Check that the compose-status.json is indeed uploaded.
2020-11-13 11:06:10 +01:00
Christian Kellner
7cc225716c test/builder: check log fetching
For each compose, mock also the "compose/<id>/logs" API endpoint
and just return some string. Add a feature to be able to control
the http status of the route though, so we can simulate failures
during log fetching.
2020-11-13 11:06:10 +01:00
Christian Kellner
bb992ab688 test/builder: fix image status route response
The correct response is one status object for each image request.
2020-11-13 11:06:10 +01:00
Christian Kellner
3f51470d9c test/builder: use multiple arches in build check
In the builder unit test that checks a successful compose, use
more than one architecture, and check that an image request was
created for all of those. This should expose bugs multi-arch
specific bugs.
2020-11-13 11:06:10 +01:00
Christian Kellner
630d09f6c4 ci: generate koji certs with SAN in make-certs.sh
Generate the certificate to be used for koji in make-certs.sh by
the same CA that also generates the composer and client certs.
Create a single certificate that uses the SubjectAltName (SAN)
extension to cover two domains: localhost, org.osbuild.koji.koji,
which previously was done via two separate certificates; this is
the legacy usage which stopped working with go 1.15 (see previous
commit). As a consequence the apache config is modified to use
only one virtual host with a ServerAlias directive.
2020-11-12 13:13:55 +01:00
Christian Kellner
6f439dc34f ci: rework ssl cert generation (SAN usage)
Rework the generation of certificates, in order to make use of
the SubjectAltName (SAN) extension, that is required for modern
usage of TLS (see RFC 2818, or [1]) and now enforced by default
for go version 1.15[2] (Fedora 33). For this a different config
file is used, originally written by Lars, and assign SANs to
the server and client certificates. Additionally, the correct
extensions are used for each of those, so that their usage is
limited to the server or client use case. The client certificate
is renamed from "worker" to "client".
The lifetime of the certificates is increased, as a side effect of
the new config file.

[1] https://github.com/urllib3/urllib3/issues/497
[2] https://golang.org/doc/go1.15#commonname

Co-authored-by: Lars Karlitski <lars@karlitski.net>
2020-11-12 13:13:55 +01:00
Christian Kellner
f529ffe394 test: use quay mirror for the postgres container
The official postgres container image is fetched from docker.io,
which recently introduced rate limiting, which makes introduces
possible CI error if we run into this limit.
Instead use a custom mirror[1] of the official image, hosted on
quay.io[2]. As a side effect this updates the posgres version
from 12 to 13.

[1] osbuild/containers@7db3c68
[2] quay.io/osbuild/postgres:v1
2020-11-10 13:26:06 +01:00
Christian Kellner
180cdefbad test/cli: check for release command line arg
Check that specifying `--release` results in the corresponding
entry (`release`) in the options dictionary (`opts`).
2020-11-03 20:40:36 +01:00
Christian Kellner
58f6a60e15 test/cli: check for repo command line argument
Check that specifying `--repo` multiple times results in the
corresponding options dictionary (`opts`) entry, called `repo`.
2020-11-03 20:40:36 +01:00
Christian Kellner
f69ce030db test/cli: specify expected argument values
In the basic invocation test, specify the expected argument values
not only their type. With the exception of the default image type
they correspond to the various command line arguments given.
2020-11-03 20:40:36 +01:00
Christian Kellner
a37fe00b05 container: fix spelling in hub/kojiweb.conf
Found by codespell.
2020-11-03 11:31:29 +01:00
Christian Kellner
0b4a13e8c7 test/builder: more architectures in build tag
Add more supported build architectures to the standard build tag.
This will check the logic for (un-)supported build architectures
in the builder plugin. If we only have one arch, which is the
requested arch, it will not catch logic errors, that invert the
supported vs requested architectures.
2020-11-03 10:54:04 +01:00
Christian Kellner
8d40baedf8 test/builder: avoid using list in keyword argument
Although in that specific use case it was fine, since the list
was copied before usage, pylint in newer versions was unhappy.
2020-10-29 17:12:03 +01:00
Christian Kellner
f5564c5f1f ci: explicitly install the dnsname podman plugin
On RHEL a pre-compiled version is currently installed from the
vendor directory (see the README.md there). On Fedora it is
packaged in podman-plugins and that used to be installed
without explicitly asking for it, but that seems to have changed.
Explicitly install it on Fedora to ensure it is present.

Symptom of the dns plugin missing is that the koji hub container
will not start because it will block waiting for the postgres
container forever.
2020-10-28 21:48:44 +01:00
Christian Kellner
e6f9721276 test/run-builder: use command -v instead of which
The latter is non-standard according to ShellCheck. Let's use the
standard one.
2020-09-29 21:40:25 +01:00
Christian Kellner
b1b7425ca6 test/make-tags.sh: KOJI_SERVER env variable
Introduce KOJI_SERVER that can be set outside, defaulting to
http://localhost:8080/kojihub for local testing.
2020-09-29 21:40:25 +01:00