Will Salmon pushed to branch willsalmon/CacheExpiryTest at BuildStream / buildstream
Commits:
-
b31f1ed6
by William Salmon at 2018-08-07T09:24:23Z
5 changed files:
- tests/artifactcache/expiry.py
- tests/frontend/push.py
- tests/frontend/workspace.py
- tests/testutils/__init__.py
- + tests/testutils/runner_integration.py
Changes:
... | ... | @@ -5,7 +5,7 @@ import pytest |
5 | 5 |
from buildstream import _yaml
|
6 | 6 |
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
7 | 7 |
|
8 |
-from tests.testutils import cli, create_element_size
|
|
8 |
+from tests.testutils import cli, create_element_size, wait_for_cache_granularity
|
|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
DATA_DIR = os.path.join(
|
... | ... | @@ -108,6 +108,8 @@ def test_expiry_order(cli, datafiles, tmpdir): |
108 | 108 |
res = cli.run(project=project, args=['build', 'target2.bst'])
|
109 | 109 |
res.assert_success()
|
110 | 110 |
|
111 |
+ wait_for_cache_granularity()
|
|
112 |
+ |
|
111 | 113 |
# Now extract dep.bst
|
112 | 114 |
res = cli.run(project=project, args=['checkout', 'dep.bst', checkout])
|
113 | 115 |
res.assert_success()
|
... | ... | @@ -3,7 +3,7 @@ import pytest |
3 | 3 |
|
4 | 4 |
from buildstream._exceptions import ErrorDomain
|
5 | 5 |
from tests.testutils import cli, create_artifact_share, create_element_size
|
6 |
-from tests.testutils import generate_junction
|
|
6 |
+from tests.testutils import generate_junction, wait_for_cache_granularity
|
|
7 | 7 |
from . import configure_project
|
8 | 8 |
|
9 | 9 |
|
... | ... | @@ -327,6 +327,8 @@ def test_recently_pulled_artifact_does_not_expire(cli, datafiles, tmpdir): |
327 | 327 |
# Ensure element1 is cached locally
|
328 | 328 |
assert cli.get_element_state(project, 'element1.bst') == 'cached'
|
329 | 329 |
|
330 |
+ wait_for_cache_granularity()
|
|
331 |
+ |
|
330 | 332 |
# Create and build the element3 (of 5 MB)
|
331 | 333 |
create_element_size('element3.bst', project, element_path, [], int(5e6))
|
332 | 334 |
result = cli.run(project=project, args=['build', 'element3.bst'])
|
... | ... | @@ -3,7 +3,7 @@ import pytest |
3 | 3 |
import shutil
|
4 | 4 |
import subprocess
|
5 | 5 |
from ruamel.yaml.comments import CommentedSet
|
6 |
-from tests.testutils import cli, create_repo, ALL_REPO_KINDS
|
|
6 |
+from tests.testutils import cli, create_repo, ALL_REPO_KINDS, wait_for_cache_granularity
|
|
7 | 7 |
|
8 | 8 |
from buildstream import _yaml
|
9 | 9 |
from buildstream._exceptions import ErrorDomain, LoadError, LoadErrorReason
|
... | ... | @@ -466,6 +466,8 @@ def test_detect_modifications(cli, tmpdir, datafiles, modification, strict): |
466 | 466 |
assert cli.get_element_state(project, element_name) == 'cached'
|
467 | 467 |
assert cli.get_element_key(project, element_name) != "{:?<64}".format('')
|
468 | 468 |
|
469 |
+ wait_for_cache_granularity()
|
|
470 |
+ |
|
469 | 471 |
# Modify the workspace in various different ways, ensuring we
|
470 | 472 |
# properly detect the changes.
|
471 | 473 |
#
|
... | ... | @@ -3,3 +3,4 @@ from .repo import create_repo, ALL_REPO_KINDS |
3 | 3 |
from .artifactshare import create_artifact_share
|
4 | 4 |
from .element_generators import create_element_size
|
5 | 5 |
from .junction import generate_junction
|
6 |
+from .runner_integration import wait_for_cache_granularity
|
1 |
+import time
|
|
2 |
+ |
|
3 |
+ |
|
4 |
+def wait_for_cache_granularity():
|
|
5 |
+ # This isn't called very often so has minimal impact on test runtime.
|
|
6 |
+ # If this changes it may be worth while adding a more sophisticated approach.
|
|
7 |
+ """
|
|
8 |
+ Mitigate the coarse granularity of the gitlab runners mtime
|
|
9 |
+ |
|
10 |
+ This function waits for the mtime to increment so that the cache can sort by mtime and
|
|
11 |
+ get the most recent results.
|
|
12 |
+ """
|
|
13 |
+ time.sleep(1.1)
|