Commit graph

73 commits

Author SHA1 Message Date
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
Christian Kellner
30aa71563c test: DATA_DIR can be externally defined
Change the use of DATA_DIR across all scripts so that it will
only be set if it does not yet exist. This makes it possible
to change the location of it across all scripts at once.
2020-09-29 21:40:25 +01:00
Christian Kellner
4dd2e6d814 test: SHARE_DIR can be externally defined
Change the use of SHARE_DIR across all scripts so that it will
only be set if it does not yet exist. This makes it possible
to change the location of it across all scripts at once.
2020-09-29 21:40:25 +01:00
Christian Kellner
aa8513c20d test: move container/ into test/
Move the container directory, containing the container definitions
for all the test containers, to test/, where all the other test-
related files are located (with the exception of `Schutzbot`).
Use `test/build-container.sh` to build the container, instead of
replicating that in `test-integration.sh`.
2020-09-29 21:40:25 +01:00
Christian Kellner
b625f96c2b test: move run-builder into test/
Move the run-builder.sh helper into the `test/` sub-directory. It
is mainly needed for testing together with the other test scripts.
2020-09-29 21:40:25 +01:00
Christian Kellner
660f0f2700 test: move run-koji-container.sh to test/
Move the run-koji-container.sh helper into the `test/` sub-directory.
It is mainly needed for testing together with the other test scripts.
2020-09-29 21:40:25 +01:00
Christian Kellner
05f1ecac8e test: move make-tags.sh into test/
Move the make-tags.sh helper into the `test/` sub-directory. It is
mainly needed for testing together with the other test scripts.
2020-09-29 21:40:25 +01:00
Christian Kellner
00c2313226 test/builder: use handler factory everywhere
Convert all tests so they use the new handler factory method.
2020-09-29 21:40:25 +01:00
Christian Kellner
4325ad00b6 test/builder: use handler factory in config checks
Use the new generic handler factory method in the configuration
data checks, eliminating a lot of duplicated code. No semantic
change intended.
2020-09-29 21:40:25 +01:00
Christian Kellner
d9c0f9e316 test/builder: add handler factory helper
Add a new helper method that can be used to create an instance of
OSBuildImage. Optionally, the session and options can be passed
in as well as a custom config data, otherwise the default session
and object are used. If custom configuration data was specified,
a temporary configuration file with the config data is created
and set plugin-wide so it is picked up by the object constructor.
2020-09-29 21:40:25 +01:00
Christian Kellner
7ecf7447e4 builder: use 'server' instead of 'url' for config
Mostly to be more in line with how things are called in all other
koji configuration files.
2020-09-26 11:37:02 +01:00
Christian Kellner
b9c3a3d2f9 all: sync with composer changes
Upstream composer has introduce a few changes that we need to
adapt for:

 - the koji composer API is now exposed on the standard https
   port (443). Thus koji hub and web need to move to a different
   pair: 8080 (http) and 4343 (https). Change the scripts and
   tests for that

 - the koji API gained a prefix 'api/composer-koji/v1/'. Change
   client and unit tests to use that prefix. Use urljoin to
   create new APIs

 - composer configuration format (osbuild-composer.toml) has
   changed and now also includes configuration for the CA
   and allowed domains

 - update the composer RPM repositories to the commit for the
   21 upstream release.
2020-09-25 22:33:31 +01:00
Christian Kellner
3b9980df50 test/build-container: simple helper script
Simple helper to build the two container for the hub and the builder.
2020-09-25 22:33:31 +01:00
Christian Kellner
e9e23b63e5 test/builder: ensure failed builds are not tagged
Since for a failed task, the build id is not returned, we check
that no tags exist at all (for any build).
2020-09-25 15:26:36 +01:00
Christian Kellner
fb9c6d9777 test/builder: ensure a successful build is tagged
Use the new MockHost class and its `tags` property to ensure that
a successful build is indeed tagged.
2020-09-25 15:26:36 +01:00
Christian Kellner
f39f7ef4b0 test/builder: mock session.host for tagging
Create a MockHost class that mocks a small subset of the HostExport
koji class, i.e. the builder specific XML RCP interface. All the
methods needed for tagging a build, including waiting for tasks,
are mocked. MockHost will keep a list of tagged builds, to check
in the unit test functions.
2020-09-25 15:26:36 +01:00
Christian Kellner
aa7df2efc5 test/builder: assert the compose request is saved
Assert, via the new UploadTracker, that the "compose-request.json"
is always saved, especially in the case where composer refuses the
compose (via bad request).
2020-09-21 13:01:04 +02:00
Christian Kellner
521bee4700 test/builder: mock koji file uploads
Replace the "fast_incremental_upload" of the plugin with a custom
one that will keeps track of all uploaded files through it. Can
be used to ensure that certain uploads happen.
NB: this assumes that "fast_incremental_upload" was or will be
directly imported into the plugin namespace.
2020-09-21 13:01:04 +02:00
Christian Kellner
825584966e test/builder: test failing composes
Check that an exception is thrown on compose failures, i.e. when
the compose status indicates that the compose has failed.
2020-09-19 22:41:26 +02:00
Christian Kellner
c70ec02fba test/builder: ability to set compose status
Can be used to mock a failing build, but setting the overall
status to "failure".
2020-09-19 22:41:26 +02:00
Christian Kellner
a1b03e2b80 builder: better and unified result value
When returning the result from the task handler function, return
a more complete and structured object in all cases. The name of
the sub-object is named after the service the item belongs to;
specifically composer is used for what belongs to (osbuild)-composer.
2020-09-19 22:41:26 +02:00
Christian Kellner
5c6605b974 test: shellcheck support for run-tests.sh
The severity is set to "warning" by default, but can be controlled
via the SHELLCHECK_SEVERITY env variable.
2020-09-17 19:53:06 +02:00
Christian Kellner
2e24a5506f test: use "bash" for entrypoint.sh
Also double quote GITHUB_WORKSPACE because that could indeed by
anything.
2020-09-17 19:53:06 +02:00
Christian Kellner
b44ceb19ef test/integration: remove unused variable
Don't need ARCH.
2020-09-17 19:53:06 +02:00
Christian Kellner
2bdfcfe0ae test/make-certs: remove unused variable
ALT_NAMES is now defined in test/data/composer.ssl.conf.
2020-09-17 19:53:06 +02:00
Christian Kellner
9ad7faf298 test/hub: check optional arguments
Include the release and repo arguments in the basic compose test,
so that if their type was to change, we were to catch it here.
2020-09-17 16:33:14 +01:00
Christian Kellner
1d9612ca05 plugin: pass repos as arrays
Currently we were passing the repo information as a comma
separated string, which is fragile, since urls can contain
commas. Just transfer them as arrays of strings.
2020-09-17 16:33:14 +01:00
Christian Kellner
5ab3acd7b1 container+test: match container base to host
On Fedora use containers based on Fedora, on RHEL use containers
based on RHEL, so we test the correct integration of the plugins
into the corresponding distribution.
2020-09-17 10:48:37 +02:00
Christian Kellner
955c531000 test/builder: check --cert command line option
Check that passing `--cert` as a command line option works, for
this we use real working certificates because this will actually
be parsed by requests.
2020-09-17 10:48:37 +02:00
Christian Kellner
15f645e6fa test/builder: more ssl_cert config check
Check we can handle a single cert properly, i.e. pass it as a
plain string to requests. Also check that if three components
are specified, an ValueError is thrown.
2020-09-17 10:48:37 +02:00
Christian Kellner
94f7b35967 test/builder: check ssl_verify can be a string
The ssl_verify config option can be a string, i.e. a path to the
certificate authority for the server side certificate. Check
that we handle that properly.
2020-09-17 10:48:37 +02:00
Christian Kellner
c2d73b431a test/builder: check config parsing
Check that options defined in the config file will be reflected
in the plugin. test all known options.
2020-09-17 10:48:37 +02:00
Christian Kellner
78cef84f67 test/builder: check repo configuration
In the test_compose_success check, after the build is "done",
check the repositories in compose request match with what
we expect.
2020-09-17 10:48:37 +02:00
Christian Kellner
41ee1f1708 test/integration: build image for current distro
Add a separate unit test to do a compose for a RHEL based image,
but then restrict the execution of test_compose_{disto} to the
distribution the test is running on, since currently cross-
distribution builds can be problematic.
2020-09-17 10:48:37 +02:00
Christian Kellner
565cecc07f test/integration: wait for compose result
In the "test_compose" integration test, explicitly wait for the
compose result, instead of being ok with having created the
request for it.
2020-09-17 10:48:37 +02:00
Christian Kellner
cf56696d90 test/builder: check stand-alone usage
Check the basic usage of the plugin as a stand-alone client for
the osbuild-composer API.
2020-09-17 10:48:37 +02:00
Christian Kellner
a660b39e00 test/integration: use copy-cred.sh
Instead of manually copying credentials around, use the new
copy-creds.sh script. Also don't manually initialize kerberos,
because that is now done automatically by the worker and the
builder.
2020-09-17 10:48:37 +02:00