|
0 |
From: Dan Nicholson <dbn@endlessos.org>
|
|
1 |
Date: Mon, 19 Apr 2021 11:00:20 -0600
|
|
2 |
Subject: tests: Test without a cache directory by default
|
|
3 |
|
|
4 |
Several tests generate summaries and then expect to use the generated
|
|
5 |
summary immediately. However, this can cause intermittent test failures
|
|
6 |
when they inadvertantly get a cached summary file. This typically
|
|
7 |
happens when the test is run on a filesystem that doesn't support user
|
|
8 |
extended attributes. In that case, the caching code can only use the
|
|
9 |
last modified time, which only has 1 second granularity. If tests don't
|
|
10 |
carefully manage the summary modification times or the repo cache then
|
|
11 |
they are likely subject to races in some test environments.
|
|
12 |
|
|
13 |
This introduces an environment variable `OSTREE_SKIP_CACHE` that
|
|
14 |
prevents the repo from using a cache directory. This is enabled by
|
|
15 |
default in tests and disabled for tests that are a explicitly trying to
|
|
16 |
test the caching behavior.
|
|
17 |
|
|
18 |
Bug: https://github.com/ostreedev/ostree/issues/2313
|
|
19 |
Bug: https://github.com/ostreedev/ostree/issues/2351
|
|
20 |
Forwarded: https://github.com/ostreedev/ostree/pull/2352
|
|
21 |
Applied-upstream: 2021.3, commit:e660855796a40ad417d13cbe081bd62e56a1c6f5
|
|
22 |
---
|
|
23 |
src/libostree/ostree-repo.c | 2 +-
|
|
24 |
tests/libtest.sh | 5 +++++
|
|
25 |
tests/test-pull-summary-caching.sh | 3 +++
|
|
26 |
tests/test-pull-summary-sigs.sh | 3 +++
|
|
27 |
tests/test-signed-pull-summary.sh | 3 +++
|
|
28 |
5 files changed, 15 insertions(+), 1 deletion(-)
|
|
29 |
|
|
30 |
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
|
|
31 |
index b2347b4..76b0248 100644
|
|
32 |
--- a/src/libostree/ostree-repo.c
|
|
33 |
+++ b/src/libostree/ostree-repo.c
|
|
34 |
@@ -3291,7 +3291,7 @@ ostree_repo_open (OstreeRepo *self,
|
|
35 |
if (!glnx_opendirat (self->repo_dir_fd, "tmp", TRUE, &self->tmp_dir_fd, error))
|
|
36 |
return FALSE;
|
|
37 |
|
|
38 |
- if (self->writable)
|
|
39 |
+ if (self->writable && getenv ("OSTREE_SKIP_CACHE") == NULL)
|
|
40 |
{
|
|
41 |
if (!glnx_shutil_mkdir_p_at (self->tmp_dir_fd, _OSTREE_CACHE_DIR, DEFAULT_DIRECTORY_MODE, cancellable, error))
|
|
42 |
return FALSE;
|
|
43 |
diff --git a/tests/libtest.sh b/tests/libtest.sh
|
|
44 |
index 2e9a99d..40f362b 100755
|
|
45 |
--- a/tests/libtest.sh
|
|
46 |
+++ b/tests/libtest.sh
|
|
47 |
@@ -86,6 +86,11 @@ unset TAR_OPTIONS
|
|
48 |
# easily clean up.
|
|
49 |
export OSTREE_SYSROOT_DEBUG=mutable-deployments
|
|
50 |
|
|
51 |
+# By default, don't use a cache directory since it makes the tests racy.
|
|
52 |
+# Tests that are explicitly testing the cache operation should unset
|
|
53 |
+# this.
|
|
54 |
+export OSTREE_SKIP_CACHE=1
|
|
55 |
+
|
|
56 |
export TEST_GPG_KEYID_1="7FCA23D8472CDAFA"
|
|
57 |
export TEST_GPG_KEYFPR_1="5E65DE75AB1C501862D476347FCA23D8472CDAFA"
|
|
58 |
export TEST_GPG_KEYID_2="D8228CFECA950D41"
|
|
59 |
diff --git a/tests/test-pull-summary-caching.sh b/tests/test-pull-summary-caching.sh
|
|
60 |
index 9671199..37c2aed 100755
|
|
61 |
--- a/tests/test-pull-summary-caching.sh
|
|
62 |
+++ b/tests/test-pull-summary-caching.sh
|
|
63 |
@@ -31,6 +31,9 @@ if ! has_gpgme; then
|
|
64 |
exit 0
|
|
65 |
fi
|
|
66 |
|
|
67 |
+# Ensure repo caching is in use.
|
|
68 |
+unset OSTREE_SKIP_CACHE
|
|
69 |
+
|
|
70 |
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
|
|
71 |
|
|
72 |
echo "1..1"
|
|
73 |
diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh
|
|
74 |
index 3819cbf..04a8e48 100755
|
|
75 |
--- a/tests/test-pull-summary-sigs.sh
|
|
76 |
+++ b/tests/test-pull-summary-sigs.sh
|
|
77 |
@@ -23,6 +23,9 @@ set -euo pipefail
|
|
78 |
|
|
79 |
. $(dirname $0)/libtest.sh
|
|
80 |
|
|
81 |
+# Ensure repo caching is in use.
|
|
82 |
+unset OSTREE_SKIP_CACHE
|
|
83 |
+
|
|
84 |
COMMIT_SIGN=""
|
|
85 |
if has_gpgme; then
|
|
86 |
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
|
|
87 |
diff --git a/tests/test-signed-pull-summary.sh b/tests/test-signed-pull-summary.sh
|
|
88 |
index e953f2e..3d46869 100755
|
|
89 |
--- a/tests/test-signed-pull-summary.sh
|
|
90 |
+++ b/tests/test-signed-pull-summary.sh
|
|
91 |
@@ -27,6 +27,9 @@ set -euo pipefail
|
|
92 |
|
|
93 |
echo "1..14"
|
|
94 |
|
|
95 |
+# Ensure repo caching is in use.
|
|
96 |
+unset OSTREE_SKIP_CACHE
|
|
97 |
+
|
|
98 |
# This is explicitly opt in for testing
|
|
99 |
export OSTREE_DUMMY_SIGN_ENABLED=1
|
|
100 |
|