Commit graph

548 commits

Author SHA1 Message Date
Tom Gundersen
314793cf6d test/cases: drop groups_blueprint.json
This will be covered by new test cases, but this is not currently
hooked up to our CI, so drop it for now.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Tom Gundersen
4c09d0d685 test/cases: sort the keys
This sorts the keys in the test case, but there is no behavioral
change.

This is in preparation for the cases being generated.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Tom Gundersen
3cff028c84 test/cases: drop rhel-8.2 test cases
These cases are pointing to internal repos that have since changed. Drop them
until we have a better long-term story.

Our CI currently does not verify these cases, so this is not a behavioural
change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Tom Gundersen
f97ab01b4c image-info: cleanup
Follow standard python coding style.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Jacob Kozol
b7dad71420 tools: add script to generate test cases
The test case json files will increase in complexity with the move from
dnf to json. They quantity of them will also continue to grow as new
distros, architectures, boot methods, image types, and blueprint
customizations become available. The generate-test-cases script
simplifies the process of creating new test cases. It accepts a compose
request and boot method as input and then uses osbuild-pipeline,
osbuild, and image-info to generate the test case.

[tomegun: some clean-ups and allow store to be reused]
2020-03-13 15:00:24 +01:00
Tom Gundersen
333a1f3500 osbuild-pipeline: read the blueprint from stdin
Make the bluprint parameter a bool, and if set, then read a
blueprint from stdin, otherwise an empty blueprint is used.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Tom Gundersen
40040f2cc8 osbuild-pipeline: make blueprint optional
If no blueprint is provided, consider that the same as the empty
blueprint.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-13 15:00:24 +01:00
Alexander Todorov
972b7c1181 Add documentation around assert/require. Refs #309 2020-03-13 14:01:18 +01:00
Alexander Todorov
b81580081b Use asserts in tests. Refs #309 2020-03-13 14:01:18 +01:00
Lars Karlitski
72f8b07e8b store: move ComposeRequest to the store package
A ComposeRequest is data used to submit a compose to the store, so it
should live in that package.

Remove the json marshalling test, because ComposeRequest is never
marshalled to JSON.

This will allow to use types from `distro` in the ComposeRequest struct.
2020-03-12 20:01:24 +01:00
Brian C. Lane
e3d1a34ab6 weldr: Fix blueprints/depsolve response
The response always returns a 200 with a JSON response. Any errors will
be in the errors list.
2020-03-12 01:55:45 +01:00
Brian C. Lane
e13ebd46ee weldr: Fix blueprints/info response for unknown blueprints
The response is different for JSON and TOML requests. If it is JSON it
will always return a 200, but any blueprints with errors will be in the
errors list.

If TOML has an error it will return an error 400 with the error in a
standard API error response with status set to false.
2020-03-12 01:55:45 +01:00
Brian C. Lane
7bd020ca11 weldr: Return an error when an empty blueprint is received
The JSON and TOML parsers differ in how they handle an empty body so
check for a ContentLength of zero first and return a "Missing
blueprint" error to the client.

Includes updated tests for the JSON path, and new tests for empty TOML
blueprints.
2020-03-12 01:55:45 +01:00
Brian C. Lane
77fd2a0d8b store: Return an error from GetBlueprintChange
If the blueprint doesn't exist, or the commit for the selected blueprint
doesn't exist it will return an error.

This also fixes the blueprints/undo/ route to return the correct error
to the caller.
2020-03-12 01:55:45 +01:00
Brian C. Lane
b4710b52f1 store: Return an error from DeleteBlueprint and DeleteBlueprintFromWorkspace
If an unknown blueprint or workspace is deleted it will now return an
error.

Also fixes the blueprints DELETE handlers to return the correct error to
the client. Includes a new test.
2020-03-12 01:55:45 +01:00
Brian C. Lane
2675eff4eb weldr: Add tests for empty and invalid blueprints 2020-03-12 01:55:45 +01:00
Brian C. Lane
36c19d756a weldrcheck: Add tests for blueprint errors
Add tests for things like posting invalid or empty blueprints,
non-existent blueprints, and commits.
2020-03-12 01:55:45 +01:00
Tom Gundersen
6acc205a68 travis: drop unit and source tests
These are done through github actions, which are much quicker. Leave
the image tests until they will be moved over to proper integration
tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-10 23:38:03 +01:00
Tom Gundersen
e8e5a11389 github-action: run unit tests
There should be no need to run unit tests on specific architectures,
move it over to github-actions and rename "Lint" to "Checks" as it
is a bit more generic now.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-10 23:38:03 +01:00
Tom Gundersen
c50aa9e135 github-action: add prepare-source test to linting
This is inspired by PR #307, but uses github actions rather than
Travis.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-10 23:38:03 +01:00
Lars Karlitski
efb2975e36 tree-wide: run go fmt 2020-03-10 23:38:03 +01:00
Alexander Todorov
bd46389059 tests: use go's test framework in osbuild-dnf-json-tests
This allows us to take advantage of the `testing` package. It also gives
the resulting test binary common command line arguments (same as `go
test`).

Tests need to be compiled with `go test -c`, which injects a `Main()`
that calls the Test* functions.

This is not supported by the golang rpm macros. Thus, build this binary
by calling `go test -c` directly, but taking care to pass the same
linker flags as the `%gobuild` macro.

Mark the test binary with the `integration` build constraint, so that
`go test ./...` doesn't pick them up. That's only for unit tests.

The idea is to move all other test binaries to this scheme as well.

Spec file changes by Lars Karlitski <lars@karlitski.net>
2020-03-10 20:29:19 +01:00
Alexander Todorov
4a0fea8b6d Ignore osbuild-weldr-tests binary 2020-03-10 20:29:19 +01:00
Jacob Kozol
2ce40e179a osbuild-pipeline: add rpmmd flag and output
A developer may want to use the output of rpmmd (build package specs,
package specs, and checksums) instead of the pipeline manifest. In this
case they may pass the -rpmmd flag to osbuild-pipeline. With this flag,
instead of returning the pipeline, it will return the output of rpmmd.
2020-03-10 17:26:37 +01:00
Ondřej Budai
714f64bf22 tests: fail the tests if no manifest is given
All the tests have a manifest, therefore there's no need for skipping a test.
2020-03-10 14:40:52 +01:00
Ondřej Budai
e5d501c9a3 tests: fix test/run script
Commit fc47ae8 changed the test case format but did not change the test
runner. This commit fixes that.
2020-03-10 14:40:52 +01:00
Brian C. Lane
aed28ccf72 store: Add blueprint change order tracking
Previously the order that changes were made to blueprints was not being
saved. I worked around this by sorting by timestamp, but it only has 1s
resolution so it is very likely to end up with changes having the same
timestamp, especially when running tests.

This adds a new variable to the Store, it is a list of the commit hashes
for each blueprint, in the order they were made.

Since this is a change to the Store schema the first time the new code
is run with the old store state it needs to populate the commit list, as
best it can, with the existing data. To do that it sorts the changes for
each blueprint by timestamp and version and saves this ordering into the
new BlueprintsCommits list.
2020-03-10 12:41:19 +01:00
Brian C. Lane
eeef1e289c weldr: Add support for /blueprints/tag route
A POST to this route will tag the latest commit of a blueprint as a new
revision. The revision numbers start at 1 and increment on each call.
If the latest commit has already been tagged it ignores the request.
2020-03-10 12:41:19 +01:00
Brian C. Lane
cc7bab14af store: Add TagBlueprint function
This function will find the latest commit to a blueprint and increment
the revision, or set it to 1 if this is the first tag for the blueprint.
2020-03-10 12:41:19 +01:00
Martin Sehnoutka
245e6ad6e7 rcm tests: document the test cases
The purpose of this documentation is to describe how the user is
expected to work with the RCM API. It can also serve as an example for
creating automation scripts if the RCM teams wants to create some.
2020-03-09 18:08:43 +01:00
Martin Sehnoutka
3b3d22d91e rcm tests: add get status test
This is a very basic test to get the status of a single compose. It will
evolve as the API gains support for Koji builds.
2020-03-09 18:08:43 +01:00
Martin Sehnoutka
0f48220225 rcm tests: read the response to a variable
This will be needed for following tests.
2020-03-09 18:08:43 +01:00
Martin Sehnoutka
178b283ca2 gitignore: add tests binaries 2020-03-09 18:08:43 +01:00
Brian C. Lane
c5341211e9 Add coveralls.io code coverage github-action
This uses the goveralls package to convert the coverage report to lcov
and send it to coveralls.io
2020-03-09 18:06:08 +01:00
Brian C. Lane
46c3bed153 client: Use http.Client instead of a string for the socket
This converts the client and weldrcheck functions to use http.Client for
connections instead of passing around the socket path and opening it for
each test.
2020-03-09 18:02:54 +01:00
Alexander Todorov
2778efed6f Download AMI image inside integration tests
only build and download AMI image type here b/c building the rest
of the output types is tested separately elsewhere
2020-03-09 13:25:09 +01:00
Alexander Todorov
8117344307 Fix typo in log message 2020-03-09 13:25:09 +01:00
Martin Sehnoutka
885704db05 tests: introduce RCM API testing executable
It is an equivalent to what we already have for Weldr API but this one
is for the RCM API. It should test the expected use cases:
 * submit a compose
 * get a status
2020-03-09 09:37:11 +01:00
Tom Gundersen
16e01f01d6 distro: drop Pipeline and Sources from interface
These are no longer used directly, but superseeded by Manifest().

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Tom Gundersen
fc47ae8c39 test/cases: test manifests rather than pipelines
A manifest is struct made up of a pipeline and a sources object. So
far all our sources objects are empty, but we have moved from
using pipelines to manifests everywhere, in preparation for
generating pipelines that require sources.

Make the same change in the test cases.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Tom Gundersen
2facde159b distro/test: fix typos in log messages
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Tom Gundersen
caca553a8f test/cases: rename compose -> compose-request
This is to avoid any confusion with the Compose struct in the store,
which contains the pinned rpmmd data and the pipeline, among other
things.

The struct in the test cases represent the user input to the compose
route, so rename it 'compose-request', to make that clearer.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Tom Gundersen
d7297e569d test/cases: support package specs in the rpmmd struct
This is unused for now, but we support passing the actual package specs
return from rpmmd.Depsolve() to distro.Pipeline(), so we should support
doing that also in the tests.

So far all our distros ignore the passed in packages, so no test-cases
make use of this yet.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Tom Gundersen
fbf137a1b7 test/cases: move checksum out of the compose struct
The intention is that the compose struct fully specifies the test
case, and pipeline and image-info specifies the expected outputs.
Lastly, the boot struct specifies how to boot-test the image.

The checksum does not fit into this scheme, as it is computed from
the compose by querying rpmmd, and it is then passed as an input to
distro.Pipeline in order to compute the pipeline.

Introduce a new struct, rpmmd, which will eventually contain all
the data returned from rpmmd.Depsolve and later passed to
distro.Pipeline. For now it only contains the checksum.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-08 21:05:01 +01:00
Lars Karlitski
3cff0a2578 osbuild-tests: test saving a blueprint
This is safe now that it is running each test in a temporary working
directory.
2020-03-08 17:04:47 +01:00
Lars Karlitski
22dee28885 osbuild-tests: run compose tests in a temporary directory
Some `composer-cli` commands operate on the current directory, for
example saving blueprints or images. Add the `TemporaryWorkDir` type,
which helps changing to a temporary working directory and cleaning
everything up after.

The alternative would have been to pass a working directory to all calls
of `runComposerCLI`, but that seemed like it would require a lot of
change, which I didn't deem worth for testing code.
2020-03-08 17:04:47 +01:00
Lars Karlitski
23fe851d4d Makefile: use spec file from HEAD to make rpm
The spec file in the current working directory might have changes. When
building rpms with the commit hash in the version, they ought to be
built with the spec file from that hash as well.
2020-03-05 20:37:02 +01:00
Major Hayden
75dd1db6e3 🐣 Use new 'make rpm' in GitHub Actions
Signed-off-by: Major Hayden <major@redhat.com>
2020-03-05 10:59:53 -06:00
Ondřej Budai
d3d16b6afa 7
Release osbuild-composer version 7
2020-03-05 17:30:50 +01:00
Lars Karlitski
5e4d6359fe Makefile: document rpm targets 2020-03-05 15:57:46 +01:00