Commit graph

36 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
9a21c00f81 test/builder: use composer url from the plugin
Use the new DEFAULT_COMPOSER_URL constant from the plugin. This
will follow changes to e.g. SSL automatically now.
2020-09-17 10:48:37 +02:00
Christian Kellner
e1edb12d11 test/builder: check a successful compose
Use the standard session and options mock object together with the
new composer mock object to simulate a successful compose:
the mock composer will accept the request and also status calls
for it, which will immediately return with success. The plugin
should then return and indicate a successful compose.
2020-09-15 18:59:03 +02:00
Christian Kellner
31885efab8 test/builder: mock composer, check a bad request
Use httpretty to mock composer responses. Create a helper method
to configure a session object that should result in a valid
compose request. Simulate a bad request by asking for an arch
that the mock composer will refuse and check the correct exception
is thrown in the builder plugin.
2020-09-15 18:59:03 +02:00
Christian Kellner
9e98f10afc test/unit: extract common code
Create a new plugintest.PluginTest class that shares the plugin
loading code that is common to all plugin testing. Adapt the
existing (hub, builder) tests.
Also correct the name for test_builder.TestHubPlugin to
TestBuilderPlugin.
2020-09-14 13:06:52 +01:00
Christian Kellner
d8107f2347 test/builder: add unit test skeleton
Add the skeleton to run builder plugin unit tests and check that
exceptions are throw for unknown build target and unsupported
architectures.
2020-09-14 10:00:56 +02:00