Commit graph

265 commits

Author SHA1 Message Date
Ondřej Budai
bc02da786d upload/koji: ensure that Koji type instance is always logged-in
Previously, Koji instance could be both logged-in and not logged-in.
This change disallows it: Now, the Koji instance is created by calling
koji.Login, so it must be always logged-in. This change should lead to more
robust code.
2020-08-27 17:29:57 +01:00
Alexander Todorov
e41dc46748 tests: remove vmwaretest.ConvertToStreamOptimizedVmdk()
in favor of OpenAsStreamOptimizedVmdk() which is also used by
the worker.
2020-08-26 14:45:31 +02:00
Alexander Todorov
e7aa9c10c2 Move openAsStreamOptimizedVmdk() into importable package
so it can be used later within tests
2020-08-26 14:45:31 +02:00
Tom Gundersen
ac5f69e757 osbuild: move result serialization from common
In the same way `osbuild.Manifest` is the input to the osbuild API,
`osbuild.Result` is the output. Move it to the `osbuild` package where
it belongs.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-26 12:12:37 +02:00
Ondřej Budai
c711b9149e remove travis mentions in codebase
Travis is no longer used, let's ditch these.
2020-08-25 10:41:10 +02:00
Ondřej Budai
e399c05cb4 tests/image: remove travis constants
The tests are no longer run on Travis, therefore we don't need the special
setup to run them there.

This change should also fix #929 that is probably caused due to osbuild
executed in a weird way.

Fixes #929
2020-08-25 10:41:10 +02:00
Tom Gundersen
b0cd29f78b worker: support returning returning images as StreamOptimized
vCenter requires images to be uploaded as vmdk StreamOptimized. Lorax
always produced images on this format, so we should make sure to do the
same for our VMWare images.

Allow LocalTarget to request the images produced by osbuild be converted
to be streamOptimized before saving in composer, and hook the weldr API
up to enable this option for vmdk images.

Ideally this should simply be an option in osbuild, but that would
require some more work, which we will not manage in time for RHEL8.3.
Therefore do this minimal fix.

Note that that means the images produced by our manifests (including in
our image-test test cases) are not on the format that the weldr API
returns, so the tests we run on them would also, for now, need to
convert before uploading to vCenter.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-23 14:45:27 +02:00
Alexander Todorov
bdea79613c Return a string from runWithStdout() instead of []byte
and trim invisble newlines b/c they were messing up with ssh
2020-08-20 21:59:54 +02:00
Tom Gundersen
f3cba8ecfc vmwaretest: avoid using the cli
This is not shipped in RHEL, so use the library directly to query the IP
address. This is a massive hack, but let us revisit this after the next
release.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-20 21:59:54 +02:00
Alexander Todorov
5a395cda38 tests: manually convert to streamOptimized vmdk 2020-08-20 21:59:54 +02:00
Alexander Todorov
9cce43d384 tests: upload & test in vCenter. Closes #338 2020-08-20 21:59:54 +02:00
Tom Gundersen
cc677dea3c repositories: distinguish between RHEL8 beta and GA
We need the same RPMs to work equally well on a host running a beta
release (pulling beta content) as on a machine running GA (pulling GA
content). Detect this at run-time and point at the right repository.

Testing this is a bit hairy as we are building 8.3 images, but obviously
there is currently no 8.3 content at the GA URLs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-19 15:06:21 +02:00
Tom Gundersen
fbfa191c81 rcm: drop sub-package
The osbuild-composer-rcm package was never finished, not in use and will be replaced by osbulid-composer-koji.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-07-17 19:13:15 +01:00
Tom Gundersen
79d27ded25 image-tests: avoid /var/tmp
`systemd-tmpfiles` will helpfully delete "old"  files in /var/tmp at regular
intervals. The files installed from rpm has the timestamps from when they
were packaged, which causes some to be cleaned up when the timer triggers.

The first timer triggers 15 minutes after boot, so we were sometimes hit
by this when our CI was under load.

Fixes #839 and #862.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-07-17 19:13:15 +01:00
Christian Kellner
44f0ba368f test: set PYTHONPATH for image-info on travis
Create a GetImageInfoCommand analogous to GetOsbuildCommand that
will adjust the PYTHONPATH for image-info on travis so that the
osbuild python module is accessible.
2020-07-13 11:31:06 +02:00
Ondřej Budai
d02e77de06 Revert "tests/image: run the tests in parallel (somewhat)"
Running tests in parallel is not stable under all conditions, this commit
removes it to make the tests more reliable.

This reverts commit e890e03d
2020-07-09 22:32:03 +02:00
Ondřej Budai
843f7701cf test/azure: don't tag the resources
The tag is not used anymore, see the previous commits.
2020-07-09 12:50:06 +02:00
Ondřej Budai
3475c54505 test/azure: fix the disk cleanup
Previously, all resouces were created with a certain tag. When the cleanup
phase came, the Resources - List route[1] was used to get all resources with
the tag. Then, they were deleted in the right order.

Sadly, the Resources - List API has issues with listing disks. Sometimes,
it returns the virtual disks 15 minutes after they were created. As the
result, the disks have been left behind quite often and our bill was higher
than necessary.

This commit uses a different method - the Go code now knows all resource names
(see the previous commit), so it can delete all resources without listing them
using the "broken" API route.

[1]: https://docs.microsoft.com/en-us/rest/api/resources/resources/list
2020-07-09 12:50:06 +02:00
Ondřej Budai
57b1788c9d test/azure: specify resource names as parameters
Prior this commit the resource names were generated in the deployment
template, so the Go code actually didn't know them. This commit generates
all names in the Go code, so they can be used in the future commits.
2020-07-09 12:50:06 +02:00
Tom Gundersen
50d469fe45 distro: replace BasePackages() with Packages()
Rather than getting a set of base packages from the ImageType, and then
appending the requested packages from the blueprint, pass the blueprint
into the new Packages() function, and return the full set of packages to
be depsolved.

This allows us to also append packages based on other customizations
too, and use that to append chrony when the timezone is set. This
matches the behavior anaconda had, and there was a TODO item to do this,
which had been overlooked.

Fixes #787.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-29 16:04:38 +02:00
Ondřej Budai
fc2788340f worker: set the osbuild success to false even on non-osbuild errors
composer uses the success field to decide whether a build succeeded or failed.
This is bad.

Unfortunately, fixing this requires kinda big code changes. This commit
changes the worker's behaviour to set the osbuild success flag to false
even on errors which weren't caused by osbuild (e.g. an upload error).
This is certainly hacky but I think it's still essential to tell the user
that an error occurred.

Fixes #789
2020-06-29 10:21:24 +02:00
Ondřej Budai
297dbe2fc7 worker: move nil result check to more appropriate place
Result can be nil only when there's an error. Move the code to a place where
it makes more sense.
2020-06-29 10:21:24 +02:00
Alexander Todorov
66b80e0dac tests: Add reproducer for #524
see this comment:
https://github.com/osbuild/osbuild-composer/issues/524#issuecomment-632017769

depending on the answer we should probably add more tests for
dnf-json too.
2020-06-26 22:02:46 +02:00
Major Hayden
067726e91d Print success log line after job is done
We print messages to the log when the build fails, but we don't print
one when the build is successful.

I really want to celebrate our successes more often, so let's print a
success message when osbuild completes successfully. Since success
doesn't feel like success without an emoji, let's add one of those, too. 🎉

Signed-off-by: Major Hayden <major@redhat.com>
2020-06-26 20:30:01 +02:00
Alexander Todorov
f7c4dca5d5 tests: upload & boot image in OpenStack. Closes #339 2020-06-23 16:17:30 +02:00
Major Hayden
4da9c3389b Pretty print osbuild JSON on failure
When osbuild fails, osbuild-composer's image tests print the output as
ugly JSON and that makes it difficult to determine why osbuild failed.

Instead, print the json in pretty format. 🦋

Fixes #782.

Signed-off-by: Major Hayden <major@redhat.com>
2020-06-18 08:46:19 -05:00
Ondřej Budai
ab0a8057bf worker: ensure that the reported result is always non-nil
When osbuild crashes (e.g. when cp fails because of the machine running
out of disk space), it doesn't produce a machine-readable result. Due to
our suboptimal handling of the result struct (this is my fault), this can
lead to result == nil. However, composer expects that result != nil in all
cases because it uses the Success flag to assess the compose state. If
result == nil, it just crashes terribly.
2020-06-12 12:47:31 +02:00
Ondřej Budai
4958d15413 tests: build qcow2 instead of tar
Tar is only available on RHEL, switch to qcow2, that's everywhere.
2020-06-12 10:00:50 +02:00
Lars Karlitski
40b65144d1 osbuild-tests: add compose cancel test 2020-06-12 10:00:50 +02:00
Lars Karlitski
aa0c037bb2 osbuild-worker: support canceling jobs
Exit the whole worker process when a job was canceled, because osbuild
does not clean up all child processes when receiving SIGKILL.

Change the service to restart osbuild-worker also on success, and
decrease the restart timeout.
2020-06-12 10:00:50 +02:00
Alexander Todorov
6d904f062c tests: composer-cli blueprints undo. Closes #615
the remaining test for composer-cli compose cancel is part of #757
2020-06-12 06:30:54 +02:00
Ondřej Budai
37bc80b31d image-tests: allow disabling of local booting
On some environments (like RHEL gating) there's no virtualization available.
This commit adds -disable-local-boot argument to osbuild-image-tests. When
this argument is present, the local booting is skipped. This doesn't affect
the cloud booting, the test binary still tries to do that. If no credentials
are available, the fall back to local booting will be skipped if
-disable-local-boot is given.
2020-06-12 06:29:32 +02:00
Lars Karlitski
33a4c55a6f osbuild-worker: don't use /var/cache for temporary directories
When osbuild-composer crashed, it left temporary directories in
`/var/cache`. Use `/var/tmp` for these output directories, because
systemd will clean these up (we set PrivateTmp=true).

Also, put the store into `/var/cache/osbuild-store`. The worker does not
checkpoint anything. The store is only used as a cache for rpms. That
can be shared between multiple workers and successive runs of a single
worker.
2020-06-12 00:13:37 +02:00
Tom Gundersen
4e75acc44a osbuild-pipeline: support check_gpg
Allow this to be set on the input repos, and passed on to dnf-json.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-10 19:25:54 +02:00
Lars Karlitski
cd674ea39f test/image: use basename of test case
This makes it easier to use the test binary with the `-run` argument.
Instead of the full path:

    -test.run TestImages//usr/share/tests/osbuild-composer/cases/rhel_8.2-x86_64-openstack-boot.json

this only requires the actual name:

    -test.run TestImages/rhel_8.2-x86_64-openstack-boot.json
2020-06-10 17:00:18 +02:00
Lars Karlitski
b3e14a4e68 test/image: pass a temporary store to osbuild
When edd7b37ea added `--output-directory` to the invocation of osbuild,
it also removed `--store`.

This was a mistake: osbuild's default store is `.osbuild`, which is not
what we want. Restore the old behavior of passing a temporary directory,
but use the same for each test run.
2020-06-10 17:00:18 +02:00
Lars Karlitski
f173714fe2 test/image: also capture osbuild's standard error
Treating stdout and stderr separately makes it hard to match what
happened when. It's also easy to miss when `-v` is passed to the test
binary.

Print the output to stdout when osbuild fails, because the test
framework we're using does not print errors if they're too large.

Also, don't special-case exec.ExitError. Output might be useful in any
case.
2020-06-10 17:00:18 +02:00
Ondřej Budai
c00cf1ac11 tree-wide: use an absolute path to dnf-json
Previously, all the osbuild-composer tools must be run from a directory with
dnf-json. This was often confusing, especially with the dnf-json-tests. This
commit changes the path to be absolute, so this is no longer an issue.
2020-06-10 16:56:28 +02:00
Ondřej Budai
b93df4b524 rpmmd: require the path to dnf-json to be passed in
RPMMD had hardcoded path to dnf-json helper. This required all executables
using RPMMD to be run in the directory where dnf-json was located. This commit
makes RPMMD take the path to dnf-json as an argument. This allows its
consumers to specify whichever path they want.

Not a functional change
2020-06-10 16:56:28 +02:00
Tom Gundersen
52273756d4 tests/compose: use qcow2 rather than ami for tests
qcow2, unlike ami, is guaranteed to exist on all the architectures we
support.

Also, now that we preserve the cache, make two composes, rather than
just one. This verifies that nothing breaks horribly just because the
cache not being cold. The fact that we have a cache at all should make
this tolerably fast.

This should fix #693.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-08 18:06:43 +02:00
Tom Gundersen
31f7bd9e74 image-tests: skip tests if the test case cannot be opened
Schutzbot currently runs all the same tests an all arches/distro
combinations. This will not work as we introduce image types only on
some distro/arches.

In the future we should make the image-test binary more clever, so
Schutzbot won't have to tell it which cases to run at all. For now,
simply don't fail if the specified test-case does not exist.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-08 13:32:59 +02:00
Tom Gundersen
b8f4b9eae9 tests: split up TestEverything
This is not a functional change, just helps to make the output more
readable to indicate which sub-command is being tested.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 19:25:33 +02:00
Alexander Todorov
099f0abeb3 tests: composer-cli sanity tests for compose metadata|results
Refs #643, #644
2020-06-07 19:25:33 +02:00
Alexander Todorov
a70b47ebb6 Enable composer-cli tests for blueprints commands. Refs #356, #615 2020-06-07 19:25:33 +02:00
Alexander Todorov
9d1d4e44ce tests: Don't pass --json to composer-cli unless needed. Refs #356
most invocations of composer-cli do not need to parse JSON so use
the canonical invocation instead. I've left existing functions
which assert on the returned results intact.

'quiet' parameter has been removed b/c it was never used
2020-06-07 19:25:33 +02:00
Alexander Todorov
b51b80f35c tests: rename functions 2020-06-07 19:25:33 +02:00
Tom Gundersen
6002a128b8 osbuild-worker: don't flush cache between jobs
Until osbuild-14, the images were unconditionally kept in the cache,
meaning the cache could grow very large. Now only the downloaded RPMs
are saved, which greatly limits how big it can grow.

Having the RPMs cached should speed up all but the first image build a
lot, so we should take advantage of that by not flushing the cache
between each build.

The cache is still flushed when the worker is stopped / restarted.

This moves the cache from /var/tmp/osbulid-worker* to
/var/cache/osbulid-worker/osbulid-worker-*. This means that each worker
gets a dedicated cache, in case there are several on one machine. In the
future we may want to combine them and only ever have one cache, but for
that we need improvements in parallel access and cache-cleanup.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 19:22:52 +02:00
Brian C. Lane
ddd2010815 weldr: Add support for the v1 API to /projects/source/new
This commit changes the store.PushSource function to take the key as
well as the SourceConfig so that it can be used for v0 or v1.

It adds helper functions for decoding the toml/json into a new
SourceConfig interface type which lets the core source/new code be
shared between the versions.

It also adds tests for the new API behavior.
2020-06-03 21:24:47 +02:00
Tom Gundersen
a48565e06e store: verify that old versions of the store can still be unmarshalled
The new tool osbuild-store-dump saves store.json to the current working
directory, with more or less arbitrary data in it.

This has been executed on osubild-composer-{12,13} (mutatis mutandis),
and the results are saved in `internal/store/test`. A new test is added
which loads these stores and does very basic verification on them having
been loaded correctly.

This is mostly meant to catch regressions that means old stores are able
to make composer crash, or lose all its data. It would not catch minor
errors that leave the stores syntactically correct.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-03 00:30:01 +02:00
Tom Gundersen
0417c6d8bb distro: make the osbuild package internal to the distros
Rather than Manifest() returning an osbuild.Manifest object, introduce a
new distro.Manifest object which represents it as an opaque, JSON
serializable object. This new type has the following properties:

1) its serialization is compatible with the input to osbuild,
2) any valid osbuild input can be deserialized into it, and
3) marshalling and unmarshaling to and from JSON is lossless.

This means that even as we change the subset of valid osbulid manifests
that we support, we can still load any previous state from disk, and it
will continue to work just as before, even though we can no longer
deserialize it into our internal notion of osbuild.Manifest.

This fixes the underlying problem of which #685 was a symptom.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-03 00:30:01 +02:00