Commit graph

88 commits

Author SHA1 Message Date
Tomáš Hozza
43e87632fb Drop common.CurrentArch() in favor of osbuild/images
Drop `common.CurrentArch()` implementation and use
`arch.Current().String()` from the osbuild/images instead.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-26 11:32:34 +01:00
Tomáš Hozza
1afe7d20c8 Adjust code to new version of osbuild/images
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-12-06 17:32:18 +01:00
Tomáš Hozza
b41705adfb Delete unused internal/platform package
This is a leftover from the `osbuild/images` split`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-20 18:59:00 +02:00
Achilleas Koutsou
8f69088af1 distro: remove architecture names and use platform enum
Removing the dependence of the manifest package on the distro package to
import manifest into distro.
Wherever arch names are needed, we use the enums from the platform
package instead.
2023-05-31 16:40:07 +02:00
Brian C. Lane
b1c2dbdfc6 Remove old build tag comments
Go is transitioning from the old '// +build' form to '//go:build', this
removes all uses of the old form, adding the new one where needed.

See https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md
2023-03-07 09:22:23 -08:00
Brian C. Lane
7a4bb863dd Update deprecated io/ioutil functions
ioutil has been deprecated since go 1.16, this fixes all of the
deprecated functions we are using:

ioutil.ReadFile -> os.ReadFile
ioutil.ReadAll -> io.ReadAll
ioutil.WriteFile -> os.WriteFile
ioutil.TempFile -> os.CreateTemp
ioutil.TempDir -> os.MkdirTemp

All of the above are a simple name change, the function arguments and
results are exactly the same as before.

ioutil.ReadDir -> os.ReadDir

now returns a os.DirEntry but the IsDir and Name functions work the
same. The difference is that the FileInfo must be retrieved with the
Info() function which can also return an error.

These were identified by running:
golangci-lint run --build-tags=integration ./...
2023-03-07 09:22:23 -08:00
Achilleas Koutsou
2eb9833370 osbuild-image-tests: ignore LVM UUID
Unconditionally ignore the UUID of the LVM container.  We don't control
this value so it isn't stable and makes our image tests fail.
2022-07-12 13:28:36 +02:00
Tomas Hozza
95e2e75851 worker/osbuild: stop handling VMDK stream-optimized conversion
A backward compatibility code handling the conversion of VMDK image to
stream-optimized sub-format has been kept in the implementation since
PR#2529 [1] merged on May 4th 2022. Since this change, no API
implementation is submitting jobs, which would hit this conversion code,
because VMDK images are already being produced in the desired
sub-format.

On-premise deployments are expected to use the same composer and worker
versions. There are no composer / worker instances in production, which
are not running the modified code.

Delete the backward compatibility code.

[1] https://github.com/osbuild/osbuild-composer/pull/2529
2022-07-01 18:55:01 +01:00
Jordi Gil
616258ee25 distro: housekeeping with cpu arch and arch.Name() 2022-05-10 19:53:41 +02:00
Jakub Rusz
a0569c784e osbuild-image-tests: skip Openstack boot testing on aarch64
We don't have access to aarch64 machines in Openstack or with kvm
support so skip the boot test part to be able to run the image tests on
aarch64.
2021-11-18 16:24:36 +01:00
Tomas Hozza
9497ef8ca9 Image tests: skip rpm-ostree-1-autovar.conf tmpfiles.d config on Fedora
The content of `/usr/lib/tmpfiles.d/rpm-ostree-1-autovar.conf` is
dynamically created and its lines are not ordered deterministically.
This causes the rpm-ostree based image test cases to fail often on
Fedora, because the diff of the expected and actual image-info report
always produces some different lines.

Add a new option `-skip-tmpfilesd-path` to `osbuild-image-tests`
accepting a tmpfiles.d configuration path, which should be ignored when
comparing the expected and actual image-info report. The option can be
specified multiple times and all paths will be ignored.

Modify the `image_tests.sh` test case to use the new option and ignore the
`/usr/lib/tmpfiles.d/rpm-ostree-1-autovar.conf` file when testing Fedora
images.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-10-08 16:21:25 +01:00
Ondřej Budai
1516c1987e test/image: fix pipeline exports for v2 manifests
Previously, we just assumed that all test manifests are of version 1, or we
should export the pipeline named assembler. However, this is no longer true
in RHEL 8.5 and 9 - they are only manifest v2 and they don't have a pipeline
named assembler.

This commit introduces a new way to guess the export name - if the manifest
is of version 1, we just export the assembler. In the case v2 manifest, the
last pipeline is exported.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-08-17 15:53:08 +02:00
Tomas Hozza
e6c3d78ec4 image tests: ignore 'selinux/context-mismatch' in image-info report on RHEL-8
Add a new CLI option to `osbuild-image-tests` called
`-skip-selinux-ctx-check` to workaround the limitation of `setfiles` on
RHEL-8 [1]. If the option is passed to the binary, then the
'selinux/context-mismatch' part is removed from the "expected" and
"actual" image-info report, before these two reports are compared.

Modify `image_tests.sh` to run `osbuild-image-tests` with
`-skip-selinux-ctx-check` when run on RHEL-8.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1973754

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-22 13:25:59 +03:00
Achilleas Koutsou
7b02d43139 osbuild-image-tests: call osbuild with export option
Call osbuild with the export option.  For now the only valid export
value is "assembler".

Run all exported images through testImage.
2021-03-17 18:12:17 +00:00
Tom Gundersen
b0805377ea image-tests: checkpoint build root
Most images share a build root, checkpoint the build root to speed up tests
at the potential cost of some disk space (in the cases the build roots are not the same).
2021-03-15 16:40:48 +00:00
Ondřej Budai
b28f32312d test/image: improve logging of failed osbuild execution
Previously, the test merged stderr and stderr and treated it as json. This was
obviously wrong. osbuild's stderr only returns python exception that are
of course not json.

The behaviour is now different:

1) stderr and stdout are treated separately
2) json from stdout is indented to prevent long lines. If it fails the test
   just prints the stdout as returned from osbuild.
3) stderr is printed as returned from osbuild

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-04 12:29:16 +02:00
Tomas Hozza
fc6fbec32f test/image: Fix test cases directory path in doc and code
The directory with image-tests test cases has been renamed from `cases`
to `manifests`. This has not been previously reflected in the test/README.md
and osbuild-image-tests code. osbuild-image-tests hardcodes the test
cases directory path and uses it in case no test case are passed
to it on the command line. Since the image_tests.sh CI test case looks
for image-tests test cases in the correct directory and passes the
relevant ones to osbuild-image-tests, the CI didn't detect this issue.

Running osbuild-images-tests without any argument and let it run all
test cases from the default test cases directory as part of CI probably
does not make sense. Due to this reason, I'm not adding any new test.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-01-12 15:36:52 +01:00
Ondřej Budai
18258238d9 test: extract GenerateCIArtifactName to test helpers
A bit of deduplication can never hurt.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
9f80c2ac8e test/image: print saner error messages
%#v was my bad understanding of Go's error formatting. Let's use the standard
%v that gives saner and human-readable error messages.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
35d7f0b9a6 test/image: remove the kvm check for aarch64
Test cases shouldn't be smart - if kvm is not available and the boot test
is still run, the test should indeed fail. It's up the test runner to decide
whether the test should be run. (It's currently not, so this is not
a functional change).

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
7256a92d15 test/image: use t4g.micro instance type for aarch64
The instance type is arch-dependant, therefore it's needed to pick the right
one for a given arch.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Tom Gundersen
3c7f61c322 test: restructure dir layout
Attempt to clarify the structure of our tests. Each test case is now
encapsulated in a script in `test/cases`. Each of these scripts should
be runnable on a pristine machine and be independent of each other. It
is up to the test-orchestractor to decide if they should be run
consequtively instance, or in parallel on separate instances. Each
script can execute several tests and call whatever helper binaries
is desired. However, each case should be assumed to always run as one.
2020-10-21 09:04:13 +02:00
Martin Sehnoutka
174e3f2037 ci: fix artifact name generation in cloud cleaner
The issue comes from the fact that the PR introducing it was very old
and meanwhile the variable used for image name creation has changed.
This patch makes sure both functions are the same.
2020-10-14 13:00:48 +02:00
Tom Gundersen
b86b18c4fb test/integration: move azure configuration into azure
This is not an integration test, but configuration.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Alexander Todorov
2370de7a4b tests: print SSH error for more info. Refs #987 2020-09-22 16:03:30 +02:00
Alexander Todorov
456bf242c4 tests: Add option to fail qemu boot. Fix #888
as @teg suggests in
https://github.com/osbuild/osbuild-composer/issues/888#issuecomment-662942314
this is ON by default so we can be alerted for missing cloud
credentials in CI!

If you want to disable it then -fail-local-boot=off

Note: special case the qemu image types which always need to be
booted locally.
2020-09-22 16:02:43 +02:00
Martin Sehnoutka
d819b26e3f run_image_tests: replace CHANGE_ID with BRANCH_NAME
CHANGE_ID is set for PRs, which is why it worked during the review
process, but in the master branch it is not set. BRANCH_NAME is set for
both PRs and master branch. In case of PRs it is in form `PR-<pull
request number>`.
2020-09-16 23:08:31 +02:00
Martin Sehnoutka
509964bede image-tests: don't use random names for CI artifacts
When using random names for artifacts like AWS snapshots, or Azure
images, it becomes hard to clean them up in case of CI failure. See this
issue for more details:
https://github.com/osbuild/osbuild-composer/issues/942

This PR introduces predictable names so that we can easily determine
which artifact belongs to which PR and therefore we can decide to wipe
all resources that are not needed any more.
2020-09-15 14:30:51 +02:00
Martin Sehnoutka
125fce92db internal/boot: Make some function public
More specifically only those that are needed in
/cmd/osbuild-image/tests.

This patch can be merged with the previous one if we want to make sure
every commit can be built, but I'm going to keep it like this for now so
that we can easily see the changes.
2020-09-03 15:12:59 +01:00
Martin Sehnoutka
ec6ce8387d internal/boot: introduce package for booting images
The package takes the existing code from /cmd/osbuild-image-tests and
makes it available for other executables.
2020-09-03 15:12:59 +01:00
Alexander Todorov
25c3deda83 tests: Use -pool when importing vmdk & booting a VM. Fixes #953
explicitly specify the cluster and the default resource pool
when importing b/c the import process creates a temporary VM,
which requires a ResourcePool to provision. Same thing when
provisioning a VM.
2020-09-01 11:55:45 +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
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
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
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
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
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
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