Commit graph

389 commits

Author SHA1 Message Date
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
1b8277c078 README.md: include sample builder configuration
To highlight how the builder plugin is configured and where to put
the configuration files.
2020-09-26 11:37:02 +01:00
Christian Kellner
3ee5966b79 HACKING.md: add Patches, Coding Style sections
Small hint where to file patches and what the coding style is.
2020-09-26 11:37:02 +01:00
Christian Kellner
01de94bc44 HACKING.md: small formatting adjustmensts
Declare code blocks to be shell, add a newline here and there.
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
b2a62d4dcf HACKING.md: troubleshooting and cleanup sections
Some more help if stuff goes wrong and some cleanup instructions.
2020-09-25 22:33:31 +01:00
Christian Kellner
add4f77e68 container/hub: disable notification
We don't ever want to send out email notifications for anything
during testing.
2020-09-25 15:26:36 +01:00
Christian Kellner
ec16d4fb14 HACKING.md: move useful links from README.md
There are not of general interest, but are specific to plugin
development. Move it to HACKING.md.
2020-09-25 15:26:36 +01:00
Christian Kellner
66aebcd0d4 README.md: refer to HACKING.md for development
HACKING.md replaced the development section of the README.md.
Refer to that new document.
2020-09-25 15:26:36 +01:00
Christian Kellner
3be53c1849 HACKING.md: added with testing instructions
Add instructions how to run the unit tests as well as the full
local test environment.
2020-09-25 15:26:36 +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
20abf9a142 builder: tag the build on success
When a compose / build was successful, tag it with the destination
tag. This will create a sub-task and wait for it. The individual
parameter are the same used for standard "image" koji tasks.
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
65bc71c9d1 make-tags.sh: add packages to tag
Add the "Fedora-Cloud" and "RHEL-Cloud" package to the f32-candidate
tag, so that builds can be tagged properly.
2020-09-25 15:26:36 +01:00
Christian Kellner
8274b0250e compose.py: remove, unused
Replaced by the builder plugin, in standalone use.
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
d300c96f1f builder: save the compose request
After creating the compose request object, save it as meta-data of
the task. This should come in especially handy when a compose gets
rejected by osbuild-composer.
2020-09-21 13:01:04 +02:00
Christian Kellner
d0499f4ef4 builder: create_compose takes a ComposeRequest obj
Instead of having the individual components for a compose request as
argument, make create_compose just take a ComposeRequest object.
This will pave the way to save the compose request as meta-data for
the task, which can be useful if something goes wrong, e.g. creating
the 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
3342f88f3b builder: properly decode the http response body
What is returned by content.decode() is a binary string and needs
to be properly decoded before we use it, especially in the error
messages.
2020-09-19 22:41:26 +02:00
Christian Kellner
807a4937ee builder: remove status member from result dict
Now that an error is thrown for failing builds, the status will
always be "success" and thus is redundant.
2020-09-19 22:41:26 +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
f2f34a3b76 builder: raise an exception on compose failures
Instead of a normal task return with a result dictionary, raise an
exception when the compose 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
2dbeab79a5 plugin/builder: more logging
Add more debug logging and always print the compose result status.
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
e2d0f49610 plugin/builder: remove unused to_json method
Since the switch to requests, with its support for dictionary to
json conversion, this method is no longer necessary.
2020-09-19 22:41:26 +02:00
Christian Kellner
f930691d86 run-tests: remove the container after use
Pass `--rm` to automatically remove the container after it exited.
2020-09-17 19:53:06 +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
f4c850d7d0 ci: enable ShellCheck warnings
Enable ShellCheck at the warning level.
2020-09-17 19:53:06 +02:00
Christian Kellner
b8f991e386 ci: fix typo in job name
It is linting not "liniting". So many iiiis.
2020-09-17 19:53:06 +02:00
Christian Kellner
2b7741519b run-tests: double quote $(pwd)
This could indeed also be anything.
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
24850d3303 plugin/hub: specify type of architectures array
In the json schema used to validate the input, specify the type of
the architectures array as a string.
2020-09-17 16:33:14 +01: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
c6f1fa0a6f ci: configure coverage thresholds
Taken from osbuild-composer. What is good for them is good for us.
2020-09-17 16:33:14 +01:00
Christian Kellner
78d9bea92d container: use latest brew staging repos
This is what is deployed in the brew staging area. Be as close as
possible to that.
2020-09-17 15:40:33 +02: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
2aae1242f8 container: add RHEL container variants
Add a RHEL version of container/*/Dockerfile. Uses the internal
repos.
2020-09-17 10:48:37 +02:00
Christian Kellner
0df038c8c5 container: add internal repos
One for the latest koji and the other one for RHEL. They are only
accessible from within the internal network.
2020-09-17 10:48:37 +02:00
Christian Kellner
14003137fc run-builder: supply --rm only for "fg"
When run in the background, remove the container in "builder_stop",
this should make it easier to print logs between starting and
stopping the container.
2020-09-17 10:48:37 +02:00
Christian Kellner
5b237ffe84 run-builder: set sensible bash flags
Do the usual "set -euo pipefail".
2020-09-17 10:48:37 +02:00