Commit graph

950 commits

Author SHA1 Message Date
Jiri Kortus
cdcd09dd67 [tests] use assert.ElementsMatch instead of reflect.DeepEqual in distro_test
The asserts should do the same job and also make sure that the two
compared lists are the same at the same time.

Refs: #442
2020-05-14 00:34:30 +02:00
Major Hayden
4aeb6f2b28 CI: Split image tests into separate tasks
Make it easier to see progress in Jenkins for image tests and keep their
logs separated for easier diagnosis of problems.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-14 00:32:34 +02:00
Major Hayden
6fcd994807 CI: Build RPMs using mock
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-13 15:57:04 -05:00
Major Hayden
e1715d8473 CI: Remove jenkins.osbuild.org configuration
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-13 15:57:04 -05:00
Jiri Kortus
b24957134b Improve coverage for distro packages - RHEL-8.3
Refs: #442
2020-05-13 20:32:05 +02:00
Jiri Kortus
04a0862c9a Improve coverage for distro packages - RHEL-8.2
Refs: #442
2020-05-13 20:32:05 +02:00
Brian C. Lane
369312989f blueprints: Fix handling of invalid blueprint names in the API code
Empty names are not allowed, and blueprint names should only contain
characters matching: ^[a-zA-Z0-9._-]+$

This also adds tests for the various places where the blueprint name
could potentially be wrong.
2020-05-13 20:00:52 +02:00
Brian C. Lane
56ae3d33c8 client: urlencode compose status filter parameters 2020-05-13 20:00:52 +02:00
Lars Karlitski
27e8e4b5d5 jobqueue: allow canceling jobs
This is not exposed to a worker yet. It will continue the job and get an
error when it tries to update the job's status to finished.
2020-05-13 16:45:09 +02:00
Lars Karlitski
b795ca25a2 fsjobqueue: remove unnecessary variable declaration 2020-05-13 16:45:09 +02:00
Lars Karlitski
8df143fabe fsjobqueue: pass accepted job types to New()
This makes the queue more type safe and allows to get rid of the
`pendingChannel` and `pendingChannels` helpers, which only existed to
create not-yet-existing pending channels.
2020-05-13 16:45:09 +02:00
Lars Karlitski
3240f11647 fsjobqueue: factor common functionality into maybeEnqueue() 2020-05-13 16:45:09 +02:00
Lars Karlitski
7592e38d3d jsondb: Allow passing nil as document to Read()
This makes Read() usable in situations where only the existence of a
value has to be checked.
2020-05-13 16:45:09 +02:00
Lars Karlitski
e599a95067 fsjobqueue: use a single mutex to protect all fields
In addition, it protects that all public functions operate on `db`
in transactions.
2020-05-13 16:45:09 +02:00
Lars Karlitski
e03c1fff65 fsjobqueue: factor reflect.Select out of Dequeue()
Hopefully this make it easier to read.
2020-05-13 16:45:09 +02:00
Lars Karlitski
6773c01722 jobqueue: drop JobStatus type
The enum is redundant information that can be deduced from the job's
times: queuedAt, startedAt, and finishedAt. Not having it reduces the
potential for inconsistent state.
2020-05-13 16:45:09 +02:00
Lars Karlitski
e1805d5f62 fsjobqueue: only update dependants when necessary
This is the same as the code in Enqueue(). There is no need to add a job
to q.dependants if all of its dependencies have finished.
2020-05-13 16:45:09 +02:00
Lars Karlitski
459181a650 fsjobqueue: fix spelling errors and json field names 2020-05-13 16:45:09 +02:00
Lars Karlitski
894a80081f store: simplify TestCompose
After the queue rework, TestCompose() was the only user of
UpdateImageBuildInCompose() and Compose.UpdateState(). Set all required
fields in TestCompose() directly instead of going through those.
2020-05-13 13:33:11 +02:00
David Rheinsberg
8dd4554491 test-case-generator: use --output-directory of osbuild
Use the --output-directory switch of osbuild to avoid poking into the
osbuild-cache.
2020-05-13 13:31:23 +02:00
David Rheinsberg
edd7b37ea2 osbuild-image-test: use --output-directory of osbuild
Switch over to the --output-directory argument of osbuild and stop
poking into the osbuild-cache.
2020-05-13 13:31:23 +02:00
David Rheinsberg
fdd7536152 worker: switch to --output-directory=DIR
Since 2 releases `osbuild` accepts an `--output-directory=DIR` argument
which lets us decide where to place generated artifacts. Switch over to
it, rather than digging into the store, to make sure we will not access
the osbuild store when parallel cleanups are ongoing (which are not yet
a thing, though).
2020-05-13 13:31:23 +02:00
Lars Karlitski
ccdc4b62f4 jenkins: use -test.timeout argument
This is the same as 6c611b487, but for the jenkins directory
(configuration for Jenkins inside Red Hat's VPN).

Use golang's `test.timeout` to set the timeout instead of using
ansible's `async` property. The latter doesn't respect `register` when
running into a timeout, which means there are no logs in that case.
2020-05-13 01:10:53 +02:00
Lars Karlitski
6c611b4875 schutzbot: use -test.timeout argument
Use golang's `test.timeout` to set the timeout instead of using
ansible's `async` property. The latter doesn't respect `register` when
running into a timeout, which means there are no logs in that case.
2020-05-12 15:40:42 -05:00
Lars Karlitski
2ecdee6814 client: drop client timeout in tests
A timeout doesn't make sense on this level, because it is very difficult
to estimate how long downloading rpm metadata takes. Drop it completely
in favor of higher-level timeouts in the test runner.

Fixes #601
2020-05-12 22:38:10 +02:00
Lars Karlitski
d49f0fef44 codecov: add 5% threshold
We're only using code coverage as additional information. Put in a 5%
threshold so that small fixes that decrease coverage slightly don't
block pull requests.
2020-05-12 21:38:43 +02:00
Major Hayden
3a961da7a5 Mount /tmp as tmpfs each time
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-12 07:48:25 -05:00
Major Hayden
1bccedf480 Remove Fedora modular repos before testing
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-12 07:48:25 -05:00
Major Hayden
fcd351f085 ↔ Parallel testing on internal Jenkins
Attempt osbuild-composer testing on the internal Jenkins deployment with
nodes that are destroyed after each use. The internal Jenkins looks for
a Jenkinsfile inside the `schutzbot` directory.

Let's not remove the `jenkins` directory (used by jenkins.osbuild.org)
yet until we know the internal Jenkins is stable and performs well.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-12 07:48:25 -05:00
Lars Karlitski
b5769add2c store: move queue out of the store
The store is responsible for two things: user state and the compose queue. This
is problematic, because the rcm API has slightly different semantics from weldr
and only used the queue part of the store. Also, the store is simply too
complex.

This commit splits the queue part out, using the new jobqueue package in both
the weldr and the rcm package. The queue is saved to a new directory `queue/`.

The weldr package now also has access to a worker server to enqueue and list
jobs. Its store continues to track composes, but the `QueueStatus` for each
compose (and image build) is deprecated. The field in `ImageBuild` is kept for
backwards compatibility for composes which finished before this change, but a
lot of code dealing with it in package compose is dropped.

store.PushCompose() is degraded to storing a new compose. It should probably be
renamed in the future. store.PopJob() is removed.

Job ids are now independent of compose ids. Because of that, the local
target gains ComposeId and ImageBuildId fields, because a worker cannot
infer those from a job anymore. This also necessitates a change in the
worker API: the job routes are changed to expect that instead of a
(compose id, image build id) pair. The route that accepts built images
keeps that pair, because it reports the image back to weldr.

worker.Server() now interacts with a job queue instead of the store. It gains
public functions that allow enqueuing an osbuild job and getting its status,
because only it knows about the specific argument and result types in the job
queue (OSBuildJob and OSBuildJobResult). One oddity remains: it needs to report
an uploaded image to weldr. Do this with a function that's passed in for now,
so that the dependency to the store can be dropped completely.

The rcm API drops its dependencies to package blueprint and store, because it
too interacts only with the worker server now.

Fixes #342
2020-05-08 14:53:00 +02:00
Lars Karlitski
64011e3cba store: simplify DeleteCompose()
The check for all image builds being either finished or failed was done
twice. Remove the second one.
2020-05-08 14:53:00 +02:00
Lars Karlitski
dde3d459f5 Add jobqueue package
Now that the "old" `jobqueue` package was renamed to `worker`, add a new
package that contains an interface to an actual job queue. Also add two
implementations: fsjobqueue, a job queue backed by the file system, and
testjobqueue, which can be used as a mock implementation for testing.

These packages are not yet used.
2020-05-08 14:53:00 +02:00
Lars Karlitski
9968358c49 weldr: remove stale comment 2020-05-08 14:53:00 +02:00
Lars Karlitski
37b42d452b store: make PushCompose() take a manifest
Code that's calling PushCompose() had to depsolve packages and fetch the
right ImageType from a distro, but not create the osbuild manifest. That
was left for PushCompose to do. Move it out of there to the callers, so
that the store is mainly concerned with storing things.

This also simplifies the argument list of PushCompose().
2020-05-08 14:53:00 +02:00
Lars Karlitski
2b7adb3200 jsondb: add List method
And add some additional tests.
2020-05-08 14:53:00 +02:00
Lars Karlitski
d74a63f4f2 weldr: inline composesToComposeEntries
This function had two modes (`uuids == nil` and `uuids != nil`). Instead
of splitting it up into one function for each mode, inline it at call
sites. It was only used three times.
2020-05-08 14:53:00 +02:00
Lars Karlitski
cbf0ec05b4 weldr: simplify filtering in composeStatusHandler
Instead of iterating over all composes, iterate over the passed UUIDs
(which amount to all composes when `*` is passed). This is more
straight-forward to read and more efficient in the case of requesting
only one (or a few) statuses.
2020-05-08 14:53:00 +02:00
Lars Karlitski
8e9f725301 weldr: fix minor inefficiency in composeStatusHandler
`uuids` was initialized with a length, but only appended to. This lead
to a slice with lots of empty uuids, followed by the actual ones.

Fix this by initializing to an empty slice.

This happened to work because there's a non-fatal check for non-existing
composes further down, and the empty string fails that test.
2020-05-08 14:53:00 +02:00
Lars Karlitski
35173cae82 weldr: return fewer errors in composeDeleteHandler
Don't try deleting a compose when it's already known that the uuid is
invalid.
2020-05-08 14:53:00 +02:00
Lars Karlitski
cf53e6a9e2 test/helpers: include error return when route fails 2020-05-08 14:53:00 +02:00
Lars Karlitski
5c019cd092 test/helpers: mark TestRoute() as a helper function
This makes the calling function/location appear when a test fails.
2020-05-08 14:53:00 +02:00
Jiri Kortus
9315ccb88e Assert existing pipelines in TestDistro_Manifest
Without the assertion some tests can just pass without actually doing
anything if no matching pipeline jsons exist.

Refs: #442
2020-05-08 10:12:28 +03:00
Jiri Kortus
3cea1f27cf Fix paths in TestDistro_Manifest
It turned out the paths contained more ../s than appropriate.

Refs: #442
2020-05-08 10:12:28 +03:00
Major Hayden
2e34a94980
Disable Jenkins CI for RHEL temporarily 2020-05-06 17:04:47 +00:00
Major Hayden
08594bd66d 🚽 Use Jenkins pipeline for better flow
By using a small Jenkins pipeline in the repository, we can define
almost all of our testing parameters in the repo itself and not inside
Jenkins.

This also allows us to use the GitHub Branch Source plugin and
auto-discover new repositories without `ok to test` bombs in
pull requests.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-05 18:33:04 -05:00
Ondřej Budai
3ba8c79e5e test/image: don't fallback to hvf/tcg if kvm is not available
-cpu host cannot be used with anything else than kvm. This commit removes
hvf and tcg because it doesn't make any sense with -cpu host.

If this causes some issues for anyone, we can revert back and remove -cpu
host.
2020-05-04 10:12:56 +02:00
Ondřej Budai
0c354e34e4 test/image: fix qemu args on qemu>=4.2
Running qemu with -accel accel= results in the following error:

qemu-system-x86_64: -accel accel=kvm:hvf:tcg: Don't use ':' with -accel,
use -M accel=... for now instead

Qemu 4.2 deprecated the -accel accel= argument. When the arg is passed in,
qemu exists status code of 1.

This commit changes the qemu command to use the recommended way of specifying
the acceleration options.

See:
3d5e90a50b
2020-05-04 10:12:56 +02:00
Major Hayden
b725ac24d2 Use sudo/become for tests
Jenkins now uses a non-root user for its agent, so we will need to use
sudo for some commands and `become` within the Ansible playbooks.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-01 11:03:50 -05:00
Ondřej Budai
7f7769cae0 test/cases: fix expected values for the image info sub-test
osbuild removed GRUB2_ROOT_FS_UUID from grubenv in 22d131a5. This broke
the Jenkins CI because it runs against osbuild master.

This commit fixes all the testcases and bumps the osbuild submodule
to version 13 that changed the GRUB2_ROOT_FS_UUID behaviour.
2020-04-30 15:55:34 +02:00
Jiri Kortus
50df564caf Improve coverage for distro packages - F32
Refs: #442
2020-04-30 11:26:27 +02:00