Commit graph

978 commits

Author SHA1 Message Date
Tom Gundersen
2fe4450620 store/compose/ImageType: use distro.ImageType objects
This reduces the amount of resolving and error checking we have to do.
This exposed a bug in weldr's ComposeEntry type, which will be fixed in
a follow-up commit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
5ba7e21a72 store/compose: rename 'Id' to 'ID' to make linter happy
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
df7a0fec22 store: merge the compose package into the store
The types exposed by the compose package are only used in the store API,
so move them there where they belong.

Making the ownership of the types clear, rather than having them live in
a package for themselves, will make it clearer how the types can be
modified in follow-up commits.

Also remove the JSON annotations, as these types are no longer used for
serialization.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
571a21c3ac store: drop pendingJobs
This is no longer used. Drop the field and the type definition.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
27e52a9755 store: use dedicated types for (un)marshaling
Distinguish between the types used at runtimes and the types used for
(un)marshaling. Also make the types private to the store package.

This should allow us to reduce the interdependencies between the
packages and more easily change things without accidentally breaking
backwards compatibility.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
8eb71ac9df mock/fixture/store: move to the store package
This way we can make more of the store fields and types private in
follow up commits.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
4c4bad5444 weldr/api_test: don't access what should be private Store fields
In a follow-up these will be made private.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
e5b3e737b6 test/helper: add comparison for ImageType objects
Two image types compare equal if they are named the same, and so are
their respective architectures and distros.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
bcf0bae2a7 distro/test: make TestArch and TestImageType public
No need to statically query these values from tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
eb658f5495 distro: add Distro() and Arch() accessors
These return the parent object of the Arch and ImageType, respectively.

Not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
c22797ffdb distro/test: rename to test_distro
Make the package easier to use from elsewhere, `test` is too generic.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
dc794a6d31 blueprint: DeepCopy() cannot fail
Don't return an error value, as it is always nil.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
3f2e7be9cf common/types: drop dead code
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Lars Karlitski
0ad7843dad codevoc: fix threshold
d49f0fef4 added a 5% threshold to codecov.yml, so that small fixes don't
turn the CI red.

However, it contained a typo and put the setting in the wrong place in
the file. codecov.io ignores unknown keys instead of throwing an error.

Fix this and validate with:

    cat codecov.yml | curl --data-binary @- https://codecov.io/validate
2020-05-17 10:12:06 +02:00
Ondřej Budai
3e26a1e632 travis: extend the timeout from 10 to 30 minutes
Travis kills the build if the command doesn't produce any output for
10 minutes. The previous commit dropped most of the test cases and left only
those with potentially long delays. This could make more build fail.
This commit introduces the travis_wait command so Travis waits for 30 minutes
without any output before it kills our job.
2020-05-15 18:47:54 +02:00
Ondřej Budai
2520c5c60a travis: limit the tests to ami and vhd
ami and vhd tests support uploading to the cloud. However, this not yet
implemented by Schutzbot. This commit drops all the tests from Travis
except for these two.
2020-05-15 18:47:54 +02:00
Ondřej Budai
32c7a90464 schutzbot: add missing image tests
openstack and ami images weren't built by Schutzbot. This commit fixes it.
2020-05-15 18:47:54 +02:00
Alexander Todorov
b9c5942976 tests: swap the places of expected-actual results in asserts
This results in better output. Output before this swap can be
seen at https://github.com/osbuild/osbuild-composer/issues/611.
It looks like we wanted a compose to FAIL and it FINISHED instead
which is making the error log confusing.
2020-05-15 17:01:02 +03:00
Major Hayden
efed778006 Add RHEL 8.2 testing
Run the base and image tests on RHEL 8.2. 🚂

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-15 08:57:17 -05:00
Ondřej Budai
11e3724ab5 test/image: move qemu code around
I think it's more readable this way, this is not a functional change.
2020-05-15 08:01:53 -05:00
Ondřej Budai
c0ad652db5 test/images: fix running the tests on rhel
RHEL 8 doesn't have qemu-system-x86_64 in PATH. Instead, it is in
/usr/libexec/qemu-kvm. This commit fixes that by detecting the host
distro and choosing the right binary.
2020-05-15 08:01:53 -05:00
David Rheinsberg
c886e1bea9 news: reformat as proper markdown
We use 8ch indents right now, which causes everything to be interpreted
as `<pre>` (or whatever your favourite equivalent is). Lets use proper
markdown.

While at it, this fixes a set of minor issues:

  * Surround markdown syntax with `` to suppress interpretation (like in
    the regexp, etc).

  * Replace hyphens before dates with proper em-dash.

  * Fix indentation in some news-entries, which did not align correctly.

This will also synchronize the file with osbuild/NEWS.md, which soothes
my heart.
2020-05-15 13:10:38 +02:00
Alexander Todorov
ef392a5b93 Build -tests RPM on RHEL unconditionally 2020-05-15 09:35:24 +02:00
Major Hayden
e8429fc3ed CI: Gather log artifacts
Ensure that logs are artifacted after a test run. Also, ensure that
these logs are in unique directories so that they are not overwritten by
Jenkins as it builds the final artifact archive.

For example, if two jobs have a `test.log`, Jenkis will only keep one of
those logs. Each log must be named differently or placed in a unique
directory.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-14 11:54:14 -05:00
Major Hayden
f36a5bbb0b CI: Use Jenkins' merged repo for testing
When Jenkins clones a repository for testing, it does the base clone
first and then merges the code from the PR afterwards. This ensures that
the code merges properly and is tested properly, but it also makes a SHA
that only exists inside Jenkins. 😢

Tell ansible-osbuild to use the repository that Jenkins made so that the
SHA is valid.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-14 09:10:20 -05:00
Ondřej Budai
02b70be9c6 test/dnf-json: fix cleaning-up the cache after the test is finished
t.Parallel() makes defer weird. This commit moves the temporary dir setup
and teardown to the parallel subtest, so the teardown gets called after
the tests are finished.

More detailed explanation:

Consider this code:

```go
t.Run("group", func(t *testing.T) {
    setUp()
    t.Run("parallel test1", parallelTest1)
    t.Run("parallel test2", parallelTest1)
    t.Run("sequential test", sequentialTest)
    cleanUp()
})
```

When the group subtest is started, firstly parallelTest1 is run. When
t.Parallel() in the parallelTest1 is hit, its execution is suspended and
parallelTest2 is started. Once again, t.Parallel() is hit and the
parallelTest2 is suspended. Now, sequentialTest is started. It doesn't
contain t.Parallel() so it's run without any interruptions. The group subtest
continues its execution and calls the cleanUp method. After the cleanup is
done, the group subtest returns and it's time for the important part:
The parallelTest1 and 2 are resumed and run in parallel. In other words,
the code after t.Parallel is run when the PARENT subtest returns.

The important (and weird) part is that the parent subtest of the parallel
subtests returns before its parallel children finish. However, just the inner
anonymous function returns. The containing t.Run("group", func(){...})
function does not return until all the parallel subtests are finished.

How to solve this? One solution is to move the cleanup out of the group
subtest:

```go
t.Run("group", func(t *testing.T) {
    setUp()
    t.Run("parallel test1", parallelTest1)
    t.Run("parallel test2", parallelTest1)
    t.Run("sequential test", sequentialTest)

})
cleanUp()
```

How does this work? The group subtest is not marked as parallel, so it just
runs from its beginning to its end (including the parallel subtests). After
it finishes, then the cleanUp is called.

In this commit I chose a different method: I just moved the clean up into each
parallel subtest. I think this is clearer than all that parallel magic I
tried explaining in previous paragraphs.

See the section "Run a group of tests in parallel":
https://blog.golang.org/subtests

and this paragraph:
https://golang.org/pkg/testing/#hdr-Subtests_and_Sub_benchmarks
2020-05-14 09:49:04 +02:00
Ondřej Budai
e2c9b9d881 12
Release osbuild-composer version 12
2020-05-14 07:30:56 +02:00
Ondřej Budai
7a4542fc2a news: remove a spurious newline 2020-05-14 07:30:56 +02:00
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