273 Commits

Author SHA1 Message Date
Alexander Larsson
651785c974 tests: Don't dist the .wrap files (as they don't exist) 2018-10-04 11:22:50 +02:00
Alexander Larsson
43c7e7eeec tests: Don't generate the .wrap tests, launch them via test-wrapper.sh
There is no need for these files to be generated on disk

Closes: #2170
Approved by: alexlarsson
2018-10-03 13:19:35 +00:00
Alexander Larsson
5ab1b99d62 tests: Run in /tmp
These days we don't really need xattrs for the tests to run,
so move the test runs to /tmp, which brings down make check time
from 5 to 3.5 minutes on my machine.

Closes: #2170
Approved by: alexlarsson
2018-10-03 13:19:35 +00:00
Alexander Larsson
5fa3fbf19e tests: Autogenerate test matrix
Several tests have alternative wrappers that just set some feature
flags. For instance to switch between user and system and with or
without deltas. This change makes those wrappers automatically
generated from a simple description of the features.

For example the test-run.sh test goes from:
-       tests/test-run.sh \
-       tests/test-run-system.sh \
-       tests/test-run-deltas.sh \
-       tests/test-run-system-deltas.sh \
to
+       tests/test-run.sh{{user+system},{nodeltas+deltas}} \

There is some complexity here because the TESTS variable in automake
can't be runtime generated, so we rewrite it during "make
update-test-matrix" and commit the result to git.

The way it works is that make update-test-matrix takes the
TEST_MATRIX_SOURCE list, passes it to tests/expand-test-matrix.sh
which generates all the combinations in tests/Makefile-test-matrix.am.inc
where a test like tests/test-foo.sh{user+system} will get
converted to tests/test-foo.sh@user.wrap and tests/test-foo.sh@system.wrap.

We then have a pattern rule matchin tests/*.wrap which will generate
a wrapper that sets the right environment flags based on $0 and then
spawns the wrapper.

Closes: #2170
Approved by: alexlarsson
2018-10-03 13:19:35 +00:00
Matthias Clasen
823511b87a Update tests for changed errors
Great that we're actually testing these.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
3eed1f42a5 Add more tests
Test some more of the FlatpakRef api, including properties.

Closes: #2108
Approved by: alexlarsson
2018-09-24 08:18:10 +00:00
Simon McVittie
36e3644d18 test-webserver: Fix race condition
If we rely on the background subshell to create the httpd-output file,
and we are unlucky, then the "cp" invocation in the loop might execute
before the file has been created, and fail. This appears to have
happened on Debian's arm64 autobuilder, which failed with:

    Running web server: PYTHONUNBUFFERED=1 setsid python3 /<<PKGBUILDDIR>>/tests/http-utils-test-server.py 0
    Web server pid: 13319
    Waiting for web server (1/300)...
    cp: cannot stat '/var/tmp/tap-test.p1cxRN/httpd-output': No such file or directory

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2098
Approved by: alexlarsson
2018-09-24 08:06:51 +00:00
Matthew Leeds
48ceed70be Replace xa.collection-id with ostree.deploy-collection-id
Currently Flatpak reads a repo metadata key called "xa.collection-id" to
decide whether to configure a collection ID on a remote. This commit
drops support for xa.collection-id and replaces it with
ostree.deploy-collection-id, which is a key defined by OSTree but so far
only implemented here.

The reason for the change is so that collection IDs can only be deployed
to users running recent versions of Flatpak and OSTree. The current
situation is that Endless wants to deploy collection IDs (and therefore
support for doing USB updates) to users, but servers such as Flathub
can't safely set xa.collection-id in their metadata, because many users
are still using old versions of Flatpak and OSTree[1] which would hit
various bugs[2][3][4] on the P2P code paths that are enabled by
collection IDs. Defining a new key means that only users running
recent (as-yet-unreleased) versions of Flatpak and OSTree will pay
attention to it and deploy the collection ID, leaving the users on old
versions unaffected.

The reason this metadata key is being defined at the level of OSTree
instead of Flatpak, is that OSTree may want to implement it in the
future.

The functionality of deploying a collection ID by setting the
"deploy-collection-id" key in the config on the server side (which in
turn causes ostree.deploy-collection-id to be set) is already covered by
the unit tests in test-update-remote-configuration.sh; this commit just
tweaks them to use the new key.

Another solution I proposed to this problem was to have a key
"eos.collection-id" which would only be understood by the Endless fork
of Flatpak, and use that temporarily until enough people are running
recent versions of Flatpak, at which point "xa.collection-id" can be
used. But this solution (abandoning xa.collection-id upstream) allows us
to avoid that migration step and leave users on old versions of Flatpak
completely unaffected.

[1] https://ahayzen.com/direct/flathub.html#downloadsbyflatpakstacked
[2] https://github.com/ostreedev/ostree/commit/e4e6d85ea
[3] https://github.com/flatpak/flatpak/commit/5813639f
[4] https://github.com/flatpak/flatpak/commit/5b21a5b7
2018-09-19 17:23:08 -07:00
Simon McVittie
155d9116de test-webserver: Be more verbose about what we're doing
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1990
Approved by: alexlarsson
2018-08-27 10:36:28 +00:00
Simon McVittie
3224e26b0a Make test scripts bilingual Python 2/Python 3
Signed-off-by: Simon McVittie <smcv@debian.org>
Forwarded: https://github.com/flatpak/flatpak/pull/1990

Closes: #1990
Approved by: alexlarsson
2018-08-27 10:36:28 +00:00
Simon McVittie
bf31305618 tests: Remove vestigial support for putting Python 2 in a runtime
This is only used in the flatpak-builder tests now, not the main
flatpak tests.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1990
Approved by: alexlarsson
2018-08-27 10:36:28 +00:00
Simon McVittie
13fee9a9ee tests: Look for httpcache in ${test_builddir}, not PATH
For installed-tests, the installed test directory is not on the PATH.
To make this easier, put the uninstalled binary in tests/, so that
in both build-time and installed tests, it is in ${test_builddir}.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1989
Approved by: alexlarsson
2018-08-27 10:26:08 +00:00
Simon McVittie
ae0d7943a5 build: Install httpcache if installed-tests are enabled
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1989
Approved by: alexlarsson
2018-08-27 10:26:08 +00:00
Alexander Larsson
3f3625819b Dist tests/oci-registry-[server|client].py
These are needed for make distcheck to pass.
2018-08-20 10:50:57 +02:00
Alexander Larsson
6bb492cb6b test: Suppress weird thread-related stream leak in ostree
Closes: #1966
Approved by: alexlarsson
2018-08-17 08:13:15 +00:00
Alexander Larsson
45945c5d45 tests: Add --gen-suppressions=all to valgrind commandline
Closes: #1964
Approved by: mwleeds
2018-08-13 21:31:09 +00:00
Alexander Larsson
6a551c2ba7 Add suppression for ostree pthread_create issue
It seems like pthread_create allocates some tls that is not
immediately cleaned up. Suppress this for now.

Closes: #1964
Approved by: mwleeds
2018-08-13 21:31:09 +00:00
Owen W. Taylor
90be1f7515 test-oci-registry.sh: extend
Add:
 * Testing of flatpakrefs and bundles pointing to OCI remotes
 * Changing a remote from OCI to non-OCI, including during bundle
   installation.
 * Pruning origin remotes.
2018-08-13 11:23:28 +02:00
Owen W. Taylor
d7d05a8619 Use oci+http[s]:// as an URL to identify OCI registries
The old pattern of using a separate 'OCI' flag was very ugly
internally in the code once it was extended to flatpak bundles and
flatpakrefs - using a different URI scheme means that the nature
of the remote can't be accidentally lost in some part of the code.

Probing would be possible as well, but would make it difficult to
add a remote when offline, and also doesn't deal well with the
fact that our data layout is different for the two types of remotes -
the type of remote could change at any point!

As a side effect this change enables flatpakrefs and flatpak bundles for OCI
registries.
2018-08-13 11:23:28 +02:00
Alexander Larsson
3fa34ebd8a Work around libsoup recursive type hang in tests
Closes: #1952
Approved by: alexlarsson
2018-08-09 15:45:08 +00:00
Owen W. Taylor
8a32f0e718 Remove FLATPAK_ENABLE_EXPERIMENTAL_OCI envvar check
Now that appstream data and icons are retrievded from the index, the OCI
code is expected to be fully usable, and to work with registries as they
will actually be deployed.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:36 +00:00
Owen W. Taylor
c4c06b7be4 Allow using a compressed cache for HTTP downloads
Add a new flag for flatpak_cache_http_uri() that adds Accept-Encoding: gzip
to the request, and if the result is returned compressed, stores the data
compressed. If the data result is return uncompressed, it's compressed.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00
Owen W. Taylor
6838206e2a test-oci-registry.sh: Tests for talking to an OCI registry
Add a new test case to test the OCI remote functionality. The tests talk to
a server that implements good-enough index generation and bits of the
docker registry protocol. Adding and remove remotes, summary and appstream
generation, and image installation are all tested.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00
Owen W. Taylor
951aed561a Add flatpak_cache_http_uri: cache downloads based on HTTP headers
Add a new function, flatpak_cache_http_uri() that when passed an URL and
a local destination location, either a) downloads the content and stores
it at the destination location, storing HTTP cache header information
like Last-Modified, Etag into user xattrs (if available) or a separate
file or b) if the downloaded content is already present, checks the
header information to decide whether the downloaded content can be used
or needs to be revalidated witha conditional request.

Tests are added that use a special case test server that adds HTTP caching
headers and reacts to them based on query parameters. A small test binary
'httpcache' is added for the tests to use.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00
Owen W. Taylor
83506fa028 test-oci.sh: Remove confusing references to 'registry'
The directory where we export an OCI image to is not a "registry", even
if it's a FlatpakOciRegistry internally. So change export registry from
oci/registry to oci/image.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Alexander Larsson
c0f9d81fb0 tests: Fix up ioctl suppressions for tests
The FICLONE ioctl suppression was hit via a different
codepath too, so tweak the callstack for the
suppression.
2018-07-07 16:38:24 +02:00
Simon McVittie
3ed522c057 testlibrary: Capture stderr from more commands
This is the equivalent of commit 86fd56dce for the commands added
in commit 2465cf4 to test #1587.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1864
Approved by: alexlarsson
2018-07-07 08:35:50 +00:00
Simon McVittie
07a225b90e testlibrary: Remove unused argv_str
This was left over after commit 86fd56d.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1864
Approved by: alexlarsson
2018-07-07 08:35:50 +00:00
Alexander Larsson
fad723dbc4 tests: Run tests on /tmp (not /var/tmp)
Since we now are ok with no-xattrs this means we can run on tmpfs.

Closes: #1839
Approved by: alexlarsson
2018-06-29 09:59:50 +00:00
Alexander Larsson
aa55665ae1 tests: Don't skip if no user xattrs
We don't require these anymore

Closes: #1839
Approved by: alexlarsson
2018-06-29 09:59:50 +00:00
Owen W. Taylor
8f73dbd32d Include appstream and icons in OCI bundles as annotations
Include annotations:

 org.freedesktop.appstream.appdata
 org.freedesktop.appstream.icon-{64,128}

into OCI bundles. This not only makes the bundle self-describing, but also
if the bundle is imported into a registry, it becomes possible to browse
the registry and recreate an appstream by only retrieving the annotations
for relevant images, without having to download the actual images.

The icon annotations are formatted as data: URI's with base64 data. The idea
is that a server-side process to collect annotations could extract the icons
to separate storage and rewrite the URI's to remote URL's.

Closes: #1834
Approved by: alexlarsson
2018-06-29 08:43:31 +00:00
Matthew Leeds
85726180a1 tests: Run P2P tests unconditionally
Now that Flatpak always has P2P support enabled, the tests that are
dependent on it can always run.

Closes: #1804
Approved by: alexlarsson
2018-06-20 07:40:53 +00:00
Alexander Larsson
491d174879 Make p2p build non-optional
Closes: #1800
Approved by: alexlarsson
2018-06-19 18:10:56 +00:00
Alexander Larsson
ffaf2d5386 Cli transaction: Print the full uninstall/install/update lists in ready
This lets you see what operations will happen and you can confirm
it before starting the heavy operations.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Simon McVittie
69bc824813 test-webserver.sh: Wait longer for web server to start
When under load (for example running parallel tests) it can take a
while to get the web server ready.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #1760
Approved by: alexlarsson
2018-06-11 07:38:21 +00:00
Simon McVittie
acb33b4a0e test-webserver: Print http server output
Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #1760
Approved by: alexlarsson
2018-06-11 07:38:21 +00:00
Simon McVittie
ea73d96e02 testlibrary: Correct a wrong string in a debug message
This always printed "setting HOME=(null)" because we didn't set
datadir yet, but it should have been looking at homedir anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #1760
Approved by: alexlarsson
2018-06-11 07:38:21 +00:00
Simon McVittie
2471f0552c testlibrary: Let the test web server's stderr go to the test's stderr
Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #1760
Approved by: alexlarsson
2018-06-11 07:38:21 +00:00
Alexander Larsson
376a325eda tests: Test uninstall fail due to dependencies
Closes: #1750
Approved by: alexlarsson
2018-06-01 15:45:08 +00:00
Alexander Larsson
de5a713336 uninstall: Don't allow uninstalling a runtime with apps that need it
Closes: #1750
Approved by: alexlarsson
2018-06-01 15:45:08 +00:00
Alexander Larsson
bc4a2d8dbf uninstall: Add --all
Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
715cc173ef Transactions: Add uninstall operation and handle no-pull correctly
In the no-pull case and when uninstalling, we never want to do any network
i/o for e.g. detecting depenedencies.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
aff4c1f4fc tests: Fix some unused variable errors in non-p2p builds
Closes: #1745
Approved by: alexlarsson
2018-05-31 19:16:15 +00:00
Alexander Larsson
9757e4883e tests: Hacks to handle coreutils-single
In the Fedora 28 base container, `coreutils-single` is used and so
`/usr/bin/ls` is actually a "script":

```
$ file /usr/bin/ls
/usr/bin/ls: a /usr/bin/coreutils --coreutils-prog-shebang=ls script, ASCII text executable
```

We handle this by detecting shebangs in dependencies and recursively adding them.

Closes: #1741
Approved by: alexlarsson
2018-05-31 14:34:49 +00:00
Alexander Larsson
2642b55e91 libflatpak: Guard public headers for individual includes 2018-05-29 16:37:21 +02:00
Alexander Larsson
867d8f4007 tests: We need to update repo with flatpak build-update-repo, not just ostree summary -U
If not, there will not be the flatpak cache in the summary and we'll create a g_warning that
aborts the tests.
2018-05-29 16:37:21 +02:00
Alexander Larsson
45c9fb967a extensions: Respect versions (as well as version) when finding related refs
This allows one extension point to match multiple versions of an extension.
In particular, this is useful for OpenGL so that we can match the version matching the current
runtime, as well as the "magic" 1.4 version for nvidia.

Closes: #1722
Approved by: alexlarsson
2018-05-29 08:01:33 +00:00
Alexander Larsson
bad16e2158 test: Add some supressions to fix FLATPAK_TESTS_VALGRIND
Closes: #1720
Approved by: alexlarsson
2018-05-28 10:59:50 +00:00
Alexander Larsson
fb8122bae2 Tests: Ensure that all ostree commits produce valid bare-user-only repos
In particular the non-canonical checks were failing for me due to selinux
attributes being picked up.

Closes: #1698
Approved by: alexlarsson
2018-05-22 08:28:10 +00:00