Raoul Hidalgo Charman pushed to branch raoul/870-root-cache-dir at BuildStream / buildstream
Commits:
-
0098a900
by Tristan Van Berkom at 2019-01-23T13:57:53Z
-
9be31641
by Tristan Van Berkom at 2019-01-23T13:57:53Z
-
3a6e953f
by Tristan Van Berkom at 2019-01-24T01:59:13Z
-
68339b19
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
6ecc2b0a
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
1140aed5
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
b7ea8b74
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
c2c004f9
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
21b2958b
by Tristan Van Berkom at 2019-01-24T05:01:55Z
-
83fcaa9f
by Tristan Van Berkom at 2019-01-24T05:01:56Z
-
46eb3018
by Tristan Van Berkom at 2019-01-24T05:01:56Z
-
341b131b
by Tristan Van Berkom at 2019-01-24T06:13:57Z
-
ef2b4648
by Tristan Van Berkom at 2019-01-24T06:14:20Z
-
40c18174
by Tristan Van Berkom at 2019-01-24T07:00:50Z
-
111d7fc1
by Raoul Hidalgo Charman at 2019-01-24T09:58:47Z
24 changed files:
- buildstream/_artifactcache.py
- buildstream/_context.py
- buildstream/data/userconfig.yaml
- conftest.py
- doc/bst2html.py
- doc/sessions/running-commands.run
- tests/artifactcache/cache_size.py
- tests/artifactcache/expiry.py
- tests/artifactcache/junctions.py
- tests/artifactcache/pull.py
- tests/artifactcache/push.py
- tests/elements/filter.py
- tests/frontend/pull.py
- tests/frontend/push.py
- tests/frontend/track.py
- tests/frontend/workspace.py
- tests/integration/build-tree.py
- tests/integration/cachedfail.py
- tests/integration/messages.py
- tests/integration/pullbuildtrees.py
- tests/integration/source-determinism.py
- − tests/internals/utils.py
- tests/sources/remote.py
- tests/testutils/runcli.py
Changes:
... | ... | @@ -882,16 +882,16 @@ class ArtifactCache(): |
882 | 882 |
else:
|
883 | 883 |
available = utils._pretty_size(available_space)
|
884 | 884 |
|
885 |
- raise LoadError(LoadErrorReason.INVALID_DATA,
|
|
886 |
- ("Your system does not have enough available " +
|
|
887 |
- "space to support the cache quota specified.\n" +
|
|
888 |
- "\nYou have specified a quota of {quota} total disk space.\n" +
|
|
889 |
- "- The filesystem containing {local_cache_path} only " +
|
|
890 |
- "has: {available_size} available.")
|
|
891 |
- .format(
|
|
892 |
- quota=self.context.config_cache_quota,
|
|
893 |
- local_cache_path=self.context.artifactdir,
|
|
894 |
- available_size=available))
|
|
885 |
+ raise ArtifactError("Your system does not have enough available " +
|
|
886 |
+ "space to support the cache quota specified.",
|
|
887 |
+ detail=("You have specified a quota of {quota} total disk space.\n" +
|
|
888 |
+ "The filesystem containing {local_cache_path} only " +
|
|
889 |
+ "has {available_size} available.")
|
|
890 |
+ .format(
|
|
891 |
+ quota=self.context.config_cache_quota,
|
|
892 |
+ local_cache_path=self.context.artifactdir,
|
|
893 |
+ available_size=available),
|
|
894 |
+ reason='insufficient-storage-for-quota')
|
|
895 | 895 |
|
896 | 896 |
# Place a slight headroom (2e9 (2GB) on the cache_quota) into
|
897 | 897 |
# cache_quota to try and avoid exceptions.
|
... | ... | @@ -58,12 +58,21 @@ class Context(): |
58 | 58 |
# Filename indicating which configuration file was used, or None for the defaults
|
59 | 59 |
self.config_origin = None
|
60 | 60 |
|
61 |
+ # The directory under which other directories are based
|
|
62 |
+ self.rootcachedir = None
|
|
63 |
+ |
|
61 | 64 |
# The directory where various sources are stored
|
62 | 65 |
self.sourcedir = None
|
63 | 66 |
|
64 | 67 |
# The directory where build sandboxes will be created
|
65 | 68 |
self.builddir = None
|
66 | 69 |
|
70 |
+ # The directory for CAS
|
|
71 |
+ self.casdir = None
|
|
72 |
+ |
|
73 |
+ # The directory for temporary files
|
|
74 |
+ self.tmpdir = None
|
|
75 |
+ |
|
67 | 76 |
# Default root location for workspaces
|
68 | 77 |
self.workspacedir = None
|
69 | 78 |
|
... | ... | @@ -188,13 +197,30 @@ class Context(): |
188 | 197 |
user_config = _yaml.load(config)
|
189 | 198 |
_yaml.composite(defaults, user_config)
|
190 | 199 |
|
200 |
+ # Give deprecation warnings
|
|
201 |
+ if defaults.get('builddir'):
|
|
202 |
+ print("builddir is deprecated, use rootcachedir")
|
|
203 |
+ else:
|
|
204 |
+ defaults['builddir'] = os.path.join(defaults['rootcachedir'], 'build')
|
|
205 |
+ |
|
206 |
+ if defaults.get('artifactdir'):
|
|
207 |
+ print("artifactdir is deprecated, use rootcachedir")
|
|
208 |
+ else:
|
|
209 |
+ defaults['artifactdir'] = os.path.join(defaults['rootcachedir'], 'artifacts')
|
|
210 |
+ |
|
191 | 211 |
_yaml.node_validate(defaults, [
|
192 |
- 'sourcedir', 'builddir', 'artifactdir', 'logdir',
|
|
212 |
+ 'rootcachedir', 'sourcedir', 'builddir', 'artifactdir', 'logdir',
|
|
193 | 213 |
'scheduler', 'artifacts', 'logging', 'projects',
|
194 |
- 'cache', 'prompt', 'workspacedir', 'remote-execution'
|
|
214 |
+ 'cache', 'prompt', 'workspacedir', 'remote-execution',
|
|
195 | 215 |
])
|
196 | 216 |
|
197 |
- for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir', 'workspacedir']:
|
|
217 |
+ # add directories not set by users
|
|
218 |
+ defaults['tmpdir'] = os.path.join(defaults['rootcachedir'], 'tmp')
|
|
219 |
+ defaults['casdir'] = os.path.join(defaults['rootcachedir'], 'cas')
|
|
220 |
+ |
|
221 |
+ for directory in ['rootcachedir', 'sourcedir', 'builddir',
|
|
222 |
+ 'artifactdir', 'logdir', 'workspacedir', 'casdir',
|
|
223 |
+ 'tmpdir']:
|
|
198 | 224 |
# Allow the ~ tilde expansion and any environment variables in
|
199 | 225 |
# path specification in the config files.
|
200 | 226 |
#
|
... | ... | @@ -654,7 +680,7 @@ class Context(): |
654 | 680 |
|
655 | 681 |
def get_cascache(self):
|
656 | 682 |
if self._cascache is None:
|
657 |
- self._cascache = CASCache(self.artifactdir)
|
|
683 |
+ self._cascache = CASCache(self.rootcachedir)
|
|
658 | 684 |
return self._cascache
|
659 | 685 |
|
660 | 686 |
# guess_element()
|
... | ... | @@ -13,11 +13,8 @@ |
13 | 13 |
# Location to store sources
|
14 | 14 |
sourcedir: ${XDG_CACHE_HOME}/buildstream/sources
|
15 | 15 |
|
16 |
-# Location to perform builds
|
|
17 |
-builddir: ${XDG_CACHE_HOME}/buildstream/build
|
|
18 |
- |
|
19 |
-# Location to store local binary artifacts
|
|
20 |
-artifactdir: ${XDG_CACHE_HOME}/buildstream/artifacts
|
|
16 |
+# Root location for other directories in the cache
|
|
17 |
+rootcachedir: ${XDG_CACHE_HOME}/buildstream
|
|
21 | 18 |
|
22 | 19 |
# Location to store build logs
|
23 | 20 |
logdir: ${XDG_CACHE_HOME}/buildstream/logs
|
... | ... | @@ -53,15 +53,15 @@ def pytest_runtest_setup(item): |
53 | 53 |
class IntegrationCache():
|
54 | 54 |
|
55 | 55 |
def __init__(self, cache):
|
56 |
- cache = os.path.abspath(cache)
|
|
56 |
+ self.root = os.path.abspath(cache)
|
|
57 | 57 |
|
58 | 58 |
# Use the same sources every time
|
59 |
- self.sources = os.path.join(cache, 'sources')
|
|
59 |
+ self.sources = os.path.join(self.root, 'sources')
|
|
60 | 60 |
|
61 | 61 |
# Create a temp directory for the duration of the test for
|
62 | 62 |
# the artifacts directory
|
63 | 63 |
try:
|
64 |
- self.artifacts = tempfile.mkdtemp(dir=cache, prefix='artifacts-')
|
|
64 |
+ self.artifacts = tempfile.mkdtemp(dir=self.root, prefix='artifacts-')
|
|
65 | 65 |
except OSError as e:
|
66 | 66 |
raise AssertionError("Unable to create test directory !") from e
|
67 | 67 |
|
... | ... | @@ -86,6 +86,10 @@ def integration_cache(request): |
86 | 86 |
shutil.rmtree(cache.artifacts)
|
87 | 87 |
except FileNotFoundError:
|
88 | 88 |
pass
|
89 |
+ try:
|
|
90 |
+ shutil.rmtree(os.path.join(cache.root, 'cas'))
|
|
91 |
+ except FileNotFoundError:
|
|
92 |
+ pass
|
|
89 | 93 |
|
90 | 94 |
|
91 | 95 |
#################################################
|
... | ... | @@ -194,10 +194,9 @@ def workdir(source_cache=None): |
194 | 194 |
|
195 | 195 |
bst_config_file = os.path.join(tempdir, 'buildstream.conf')
|
196 | 196 |
config = {
|
197 |
+ 'rootcachedir': tempdir,
|
|
197 | 198 |
'sourcedir': source_cache,
|
198 |
- 'artifactdir': os.path.join(tempdir, 'artifacts'),
|
|
199 | 199 |
'logdir': os.path.join(tempdir, 'logs'),
|
200 |
- 'builddir': os.path.join(tempdir, 'build'),
|
|
201 | 200 |
}
|
202 | 201 |
_yaml.dump(config, bst_config_file)
|
203 | 202 |
|
... | ... | @@ -411,12 +410,10 @@ def run_session(description, tempdir, source_cache, palette, config_file, force) |
411 | 410 |
# Encode and save the output if that was asked for
|
412 | 411 |
output = _yaml.node_get(command, str, 'output', default_value=None)
|
413 | 412 |
if output is not None:
|
414 |
- |
|
415 | 413 |
# Convert / Generate a nice <div>
|
416 | 414 |
converted = generate_html(command_out, directory, config_file,
|
417 | 415 |
source_cache, tempdir, palette,
|
418 | 416 |
command_str, command_fake_output is not None)
|
419 |
- |
|
420 | 417 |
# Save it
|
421 | 418 |
filename = os.path.join(desc_dir, output)
|
422 | 419 |
filename = os.path.realpath(filename)
|
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 |
commands:
|
3 | 3 |
# Make it fetch first
|
4 | 4 |
- directory: ../examples/running-commands
|
5 |
- command: fetch hello.bst
|
|
5 |
+ command: source fetch hello.bst
|
|
6 | 6 |
|
7 | 7 |
# Capture a show output
|
8 | 8 |
- directory: ../examples/running-commands
|
1 | 1 |
import os
|
2 | 2 |
import pytest
|
3 |
+from unittest import mock
|
|
3 | 4 |
|
4 | 5 |
from buildstream import _yaml
|
5 | 6 |
from buildstream._artifactcache import CACHE_SIZE_FILE
|
7 |
+from buildstream._exceptions import ErrorDomain
|
|
6 | 8 |
|
7 | 9 |
from tests.testutils import cli, create_element_size
|
8 | 10 |
|
... | ... | @@ -60,3 +62,29 @@ def test_cache_size_write(cli, tmpdir): |
60 | 62 |
with open(sizefile, "r") as f:
|
61 | 63 |
size_data = f.read()
|
62 | 64 |
size = int(size_data)
|
65 |
+ |
|
66 |
+ |
|
67 |
+def test_quota_over_1024T(cli, tmpdir):
|
|
68 |
+ KiB = 1024
|
|
69 |
+ MiB = (KiB * 1024)
|
|
70 |
+ GiB = (MiB * 1024)
|
|
71 |
+ TiB = (GiB * 1024)
|
|
72 |
+ |
|
73 |
+ cli.configure({
|
|
74 |
+ 'cache': {
|
|
75 |
+ 'quota': 2048 * TiB
|
|
76 |
+ }
|
|
77 |
+ })
|
|
78 |
+ project = tmpdir.join("main")
|
|
79 |
+ os.makedirs(str(project))
|
|
80 |
+ _yaml.dump({'name': 'main'}, str(project.join("project.conf")))
|
|
81 |
+ |
|
82 |
+ volume_space_patch = mock.patch(
|
|
83 |
+ "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for",
|
|
84 |
+ autospec=True,
|
|
85 |
+ return_value=(1025 * TiB, 1025 * TiB)
|
|
86 |
+ )
|
|
87 |
+ |
|
88 |
+ with volume_space_patch:
|
|
89 |
+ result = cli.run(project, args=["build", "file.bst"])
|
|
90 |
+ result.assert_main_error(ErrorDomain.ARTIFACT, 'insufficient-storage-for-quota')
|
... | ... | @@ -66,8 +66,9 @@ def test_artifact_expires(cli, datafiles, tmpdir): |
66 | 66 |
res.assert_success()
|
67 | 67 |
|
68 | 68 |
# Check that the correct element remains in the cache
|
69 |
- assert cli.get_element_state(project, 'target.bst') != 'cached'
|
|
70 |
- assert cli.get_element_state(project, 'target2.bst') == 'cached'
|
|
69 |
+ states = cli.get_element_states(project, ['target.bst', 'target2.bst'])
|
|
70 |
+ assert states['target.bst'] != 'cached'
|
|
71 |
+ assert states['target2.bst'] == 'cached'
|
|
71 | 72 |
|
72 | 73 |
|
73 | 74 |
# Ensure that we don't end up deleting the whole cache (or worse) if
|
... | ... | @@ -144,9 +145,11 @@ def test_expiry_order(cli, datafiles, tmpdir): |
144 | 145 |
# have been removed.
|
145 | 146 |
# Note that buildstream will reduce the cache to 50% of the
|
146 | 147 |
# original size - we therefore remove multiple elements.
|
147 |
- |
|
148 |
- assert (tuple(cli.get_element_state(project, element) for element in
|
|
149 |
- ('unrelated.bst', 'target.bst', 'target2.bst', 'dep.bst', 'expire.bst')) ==
|
|
148 |
+ check_elements = [
|
|
149 |
+ 'unrelated.bst', 'target.bst', 'target2.bst', 'dep.bst', 'expire.bst'
|
|
150 |
+ ]
|
|
151 |
+ states = cli.get_element_states(project, check_elements)
|
|
152 |
+ assert (tuple(states[element] for element in check_elements) ==
|
|
150 | 153 |
('buildable', 'buildable', 'buildable', 'cached', 'cached', ))
|
151 | 154 |
|
152 | 155 |
|
... | ... | @@ -176,8 +179,9 @@ def test_keep_dependencies(cli, datafiles, tmpdir): |
176 | 179 |
res.assert_success()
|
177 | 180 |
|
178 | 181 |
# Check that the correct element remains in the cache
|
179 |
- assert cli.get_element_state(project, 'dependency.bst') == 'cached'
|
|
180 |
- assert cli.get_element_state(project, 'unrelated.bst') == 'cached'
|
|
182 |
+ states = cli.get_element_states(project, ['dependency.bst', 'unrelated.bst'])
|
|
183 |
+ assert states['dependency.bst'] == 'cached'
|
|
184 |
+ assert states['unrelated.bst'] == 'cached'
|
|
181 | 185 |
|
182 | 186 |
# We try to build an element which depends on the LRU artifact,
|
183 | 187 |
# and could therefore fail if we didn't make sure dependencies
|
... | ... | @@ -192,9 +196,10 @@ def test_keep_dependencies(cli, datafiles, tmpdir): |
192 | 196 |
res = cli.run(project=project, args=['build', 'target.bst'])
|
193 | 197 |
res.assert_success()
|
194 | 198 |
|
195 |
- assert cli.get_element_state(project, 'unrelated.bst') != 'cached'
|
|
196 |
- assert cli.get_element_state(project, 'dependency.bst') == 'cached'
|
|
197 |
- assert cli.get_element_state(project, 'target.bst') == 'cached'
|
|
199 |
+ states = cli.get_element_states(project, ['target.bst', 'unrelated.bst'])
|
|
200 |
+ assert states['target.bst'] == 'cached'
|
|
201 |
+ assert states['dependency.bst'] == 'cached'
|
|
202 |
+ assert states['unrelated.bst'] != 'cached'
|
|
198 | 203 |
|
199 | 204 |
|
200 | 205 |
# Assert that we never delete a dependency required for a build tree
|
... | ... | @@ -239,11 +244,11 @@ def test_never_delete_required(cli, datafiles, tmpdir): |
239 | 244 |
# life there may potentially be N-builders cached artifacts
|
240 | 245 |
# which exceed the quota
|
241 | 246 |
#
|
242 |
- assert cli.get_element_state(project, 'dep1.bst') == 'cached'
|
|
243 |
- assert cli.get_element_state(project, 'dep2.bst') == 'cached'
|
|
244 |
- |
|
245 |
- assert cli.get_element_state(project, 'dep3.bst') != 'cached'
|
|
246 |
- assert cli.get_element_state(project, 'target.bst') != 'cached'
|
|
247 |
+ states = cli.get_element_states(project, ['target.bst'])
|
|
248 |
+ assert states['dep1.bst'] == 'cached'
|
|
249 |
+ assert states['dep2.bst'] == 'cached'
|
|
250 |
+ assert states['dep3.bst'] != 'cached'
|
|
251 |
+ assert states['target.bst'] != 'cached'
|
|
247 | 252 |
|
248 | 253 |
|
249 | 254 |
# Assert that we never delete a dependency required for a build tree,
|
... | ... | @@ -275,10 +280,11 @@ def test_never_delete_required_track(cli, datafiles, tmpdir): |
275 | 280 |
res.assert_success()
|
276 | 281 |
|
277 | 282 |
# They should all be cached
|
278 |
- assert cli.get_element_state(project, 'dep1.bst') == 'cached'
|
|
279 |
- assert cli.get_element_state(project, 'dep2.bst') == 'cached'
|
|
280 |
- assert cli.get_element_state(project, 'dep3.bst') == 'cached'
|
|
281 |
- assert cli.get_element_state(project, 'target.bst') == 'cached'
|
|
283 |
+ states = cli.get_element_states(project, ['target.bst'])
|
|
284 |
+ assert states['dep1.bst'] == 'cached'
|
|
285 |
+ assert states['dep2.bst'] == 'cached'
|
|
286 |
+ assert states['dep3.bst'] == 'cached'
|
|
287 |
+ assert states['target.bst'] == 'cached'
|
|
282 | 288 |
|
283 | 289 |
# Now increase the size of all the elements
|
284 | 290 |
#
|
... | ... | @@ -296,28 +302,37 @@ def test_never_delete_required_track(cli, datafiles, tmpdir): |
296 | 302 |
|
297 | 303 |
# Expect the same result that we did in test_never_delete_required()
|
298 | 304 |
#
|
299 |
- assert cli.get_element_state(project, 'dep1.bst') == 'cached'
|
|
300 |
- assert cli.get_element_state(project, 'dep2.bst') == 'cached'
|
|
301 |
- assert cli.get_element_state(project, 'dep3.bst') != 'cached'
|
|
302 |
- assert cli.get_element_state(project, 'target.bst') != 'cached'
|
|
305 |
+ states = cli.get_element_states(project, ['target.bst'])
|
|
306 |
+ assert states['dep1.bst'] == 'cached'
|
|
307 |
+ assert states['dep2.bst'] == 'cached'
|
|
308 |
+ assert states['dep3.bst'] != 'cached'
|
|
309 |
+ assert states['target.bst'] != 'cached'
|
|
303 | 310 |
|
304 | 311 |
|
305 | 312 |
# Ensure that only valid cache quotas make it through the loading
|
306 | 313 |
# process.
|
307 |
-@pytest.mark.parametrize("quota,success", [
|
|
308 |
- ("1", True),
|
|
309 |
- ("1K", True),
|
|
310 |
- ("50%", True),
|
|
311 |
- ("infinity", True),
|
|
312 |
- ("0", True),
|
|
313 |
- ("-1", False),
|
|
314 |
- ("pony", False),
|
|
315 |
- ("7K", False),
|
|
316 |
- ("70%", False),
|
|
317 |
- ("200%", False)
|
|
314 |
+#
|
|
315 |
+# This test virtualizes the condition to assume a storage volume
|
|
316 |
+# has 10K total disk space, and 6K of it is already in use (not
|
|
317 |
+# including any space used by the artifact cache).
|
|
318 |
+#
|
|
319 |
+@pytest.mark.parametrize("quota,err_domain,err_reason", [
|
|
320 |
+ # Valid configurations
|
|
321 |
+ ("1", 'success', None),
|
|
322 |
+ ("1K", 'success', None),
|
|
323 |
+ ("50%", 'success', None),
|
|
324 |
+ ("infinity", 'success', None),
|
|
325 |
+ ("0", 'success', None),
|
|
326 |
+ # Invalid configurations
|
|
327 |
+ ("-1", ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA),
|
|
328 |
+ ("pony", ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA),
|
|
329 |
+ ("200%", ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA),
|
|
330 |
+ # Not enough space for these caches
|
|
331 |
+ ("7K", ErrorDomain.ARTIFACT, 'insufficient-storage-for-quota'),
|
|
332 |
+ ("70%", ErrorDomain.ARTIFACT, 'insufficient-storage-for-quota')
|
|
318 | 333 |
])
|
319 | 334 |
@pytest.mark.datafiles(DATA_DIR)
|
320 |
-def test_invalid_cache_quota(cli, datafiles, tmpdir, quota, success):
|
|
335 |
+def test_invalid_cache_quota(cli, datafiles, tmpdir, quota, err_domain, err_reason):
|
|
321 | 336 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
322 | 337 |
os.makedirs(os.path.join(project, 'elements'))
|
323 | 338 |
|
... | ... | @@ -356,10 +371,10 @@ def test_invalid_cache_quota(cli, datafiles, tmpdir, quota, success): |
356 | 371 |
with volume_space_patch, cache_size_patch:
|
357 | 372 |
res = cli.run(project=project, args=['workspace', 'list'])
|
358 | 373 |
|
359 |
- if success:
|
|
374 |
+ if err_domain == 'success':
|
|
360 | 375 |
res.assert_success()
|
361 | 376 |
else:
|
362 |
- res.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
|
377 |
+ res.assert_main_error(err_domain, err_reason)
|
|
363 | 378 |
|
364 | 379 |
|
365 | 380 |
@pytest.mark.datafiles(DATA_DIR)
|
... | ... | @@ -403,7 +418,7 @@ def test_extract_expiry(cli, datafiles, tmpdir): |
403 | 418 |
# Now we should have a directory for the cached target2.bst, which
|
404 | 419 |
# replaced target.bst in the cache, we should not have a directory
|
405 | 420 |
# for the target.bst
|
406 |
- refsdir = os.path.join(project, 'cache', 'artifacts', 'cas', 'refs', 'heads')
|
|
421 |
+ refsdir = os.path.join(project, 'cache', 'cas', 'refs', 'heads')
|
|
407 | 422 |
refsdirtest = os.path.join(refsdir, 'test')
|
408 | 423 |
refsdirtarget = os.path.join(refsdirtest, 'target')
|
409 | 424 |
refsdirtarget2 = os.path.join(refsdirtest, 'target2')
|
... | ... | @@ -68,8 +68,8 @@ def test_push_pull(cli, tmpdir, datafiles): |
68 | 68 |
# Now we've pushed, delete the user's local artifact cache
|
69 | 69 |
# directory and try to redownload it from the share
|
70 | 70 |
#
|
71 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
72 |
- shutil.rmtree(artifacts)
|
|
71 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
72 |
+ shutil.rmtree(cas)
|
|
73 | 73 |
|
74 | 74 |
# Assert that nothing is cached locally anymore
|
75 | 75 |
state = cli.get_element_state(project, 'target.bst')
|
... | ... | @@ -56,7 +56,7 @@ def test_pull(cli, tmpdir, datafiles): |
56 | 56 |
# Set up an artifact cache.
|
57 | 57 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
58 | 58 |
# Configure artifact share
|
59 |
- artifact_dir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
59 |
+ cache_dir = os.path.join(str(tmpdir), 'cache')
|
|
60 | 60 |
user_config_file = str(tmpdir.join('buildstream.conf'))
|
61 | 61 |
user_config = {
|
62 | 62 |
'scheduler': {
|
... | ... | @@ -65,7 +65,8 @@ def test_pull(cli, tmpdir, datafiles): |
65 | 65 |
'artifacts': {
|
66 | 66 |
'url': share.repo,
|
67 | 67 |
'push': True,
|
68 |
- }
|
|
68 |
+ },
|
|
69 |
+ 'rootcachedir': cache_dir
|
|
69 | 70 |
}
|
70 | 71 |
|
71 | 72 |
# Write down the user configuration file
|
... | ... | @@ -92,7 +93,6 @@ def test_pull(cli, tmpdir, datafiles): |
92 | 93 |
# Fake minimal context
|
93 | 94 |
context = Context()
|
94 | 95 |
context.load(config=user_config_file)
|
95 |
- context.artifactdir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
96 | 96 |
context.set_message_handler(message_handler)
|
97 | 97 |
|
98 | 98 |
# Load the project and CAS cache
|
... | ... | @@ -102,7 +102,10 @@ def test_pull(cli, tmpdir, datafiles): |
102 | 102 |
|
103 | 103 |
# Assert that the element's artifact is **not** cached
|
104 | 104 |
element = project.load_elements(['target.bst'])[0]
|
105 |
+ print(element)
|
|
105 | 106 |
element_key = cli.get_element_key(project_dir, 'target.bst')
|
107 |
+ print(context.casdir)
|
|
108 |
+ print(cas.get_artifact_fullname(element, element_key))
|
|
106 | 109 |
assert not cas.contains(element, element_key)
|
107 | 110 |
|
108 | 111 |
queue = multiprocessing.Queue()
|
... | ... | @@ -110,7 +113,7 @@ def test_pull(cli, tmpdir, datafiles): |
110 | 113 |
# See https://github.com/grpc/grpc/blob/master/doc/fork_support.md for details
|
111 | 114 |
process = multiprocessing.Process(target=_queue_wrapper,
|
112 | 115 |
args=(_test_pull, queue, user_config_file, project_dir,
|
113 |
- artifact_dir, 'target.bst', element_key))
|
|
116 |
+ cache_dir, 'target.bst', element_key))
|
|
114 | 117 |
|
115 | 118 |
try:
|
116 | 119 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -127,12 +130,14 @@ def test_pull(cli, tmpdir, datafiles): |
127 | 130 |
assert cas.contains(element, element_key)
|
128 | 131 |
|
129 | 132 |
|
130 |
-def _test_pull(user_config_file, project_dir, artifact_dir,
|
|
133 |
+def _test_pull(user_config_file, project_dir, cache_dir,
|
|
131 | 134 |
element_name, element_key, queue):
|
132 | 135 |
# Fake minimal context
|
133 | 136 |
context = Context()
|
134 | 137 |
context.load(config=user_config_file)
|
135 |
- context.artifactdir = artifact_dir
|
|
138 |
+ context.rootcachedir = cache_dir
|
|
139 |
+ context.casdir = os.path.join(cache_dir, 'cas')
|
|
140 |
+ context.tmpdir = os.path.join(cache_dir, 'tmp')
|
|
136 | 141 |
context.set_message_handler(message_handler)
|
137 | 142 |
|
138 | 143 |
# Load the project manually
|
... | ... | @@ -165,7 +170,7 @@ def test_pull_tree(cli, tmpdir, datafiles): |
165 | 170 |
# Set up an artifact cache.
|
166 | 171 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
167 | 172 |
# Configure artifact share
|
168 |
- artifact_dir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
173 |
+ rootcache_dir = os.path.join(str(tmpdir), 'cache')
|
|
169 | 174 |
user_config_file = str(tmpdir.join('buildstream.conf'))
|
170 | 175 |
user_config = {
|
171 | 176 |
'scheduler': {
|
... | ... | @@ -174,7 +179,8 @@ def test_pull_tree(cli, tmpdir, datafiles): |
174 | 179 |
'artifacts': {
|
175 | 180 |
'url': share.repo,
|
176 | 181 |
'push': True,
|
177 |
- }
|
|
182 |
+ },
|
|
183 |
+ 'rootcachedir': rootcache_dir
|
|
178 | 184 |
}
|
179 | 185 |
|
180 | 186 |
# Write down the user configuration file
|
... | ... | @@ -195,7 +201,6 @@ def test_pull_tree(cli, tmpdir, datafiles): |
195 | 201 |
# Fake minimal context
|
196 | 202 |
context = Context()
|
197 | 203 |
context.load(config=user_config_file)
|
198 |
- context.artifactdir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
199 | 204 |
context.set_message_handler(message_handler)
|
200 | 205 |
|
201 | 206 |
# Load the project and CAS cache
|
... | ... | @@ -218,7 +223,7 @@ def test_pull_tree(cli, tmpdir, datafiles): |
218 | 223 |
# See https://github.com/grpc/grpc/blob/master/doc/fork_support.md for details
|
219 | 224 |
process = multiprocessing.Process(target=_queue_wrapper,
|
220 | 225 |
args=(_test_push_tree, queue, user_config_file, project_dir,
|
221 |
- artifact_dir, artifact_digest))
|
|
226 |
+ artifact_digest))
|
|
222 | 227 |
|
223 | 228 |
try:
|
224 | 229 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -246,7 +251,7 @@ def test_pull_tree(cli, tmpdir, datafiles): |
246 | 251 |
# Use subprocess to avoid creation of gRPC threads in main BuildStream process
|
247 | 252 |
process = multiprocessing.Process(target=_queue_wrapper,
|
248 | 253 |
args=(_test_pull_tree, queue, user_config_file, project_dir,
|
249 |
- artifact_dir, tree_digest))
|
|
254 |
+ tree_digest))
|
|
250 | 255 |
|
251 | 256 |
try:
|
252 | 257 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -268,11 +273,10 @@ def test_pull_tree(cli, tmpdir, datafiles): |
268 | 273 |
assert os.path.exists(cas.objpath(directory_digest))
|
269 | 274 |
|
270 | 275 |
|
271 |
-def _test_push_tree(user_config_file, project_dir, artifact_dir, artifact_digest, queue):
|
|
276 |
+def _test_push_tree(user_config_file, project_dir, artifact_digest, queue):
|
|
272 | 277 |
# Fake minimal context
|
273 | 278 |
context = Context()
|
274 | 279 |
context.load(config=user_config_file)
|
275 |
- context.artifactdir = artifact_dir
|
|
276 | 280 |
context.set_message_handler(message_handler)
|
277 | 281 |
|
278 | 282 |
# Load the project manually
|
... | ... | @@ -304,11 +308,10 @@ def _test_push_tree(user_config_file, project_dir, artifact_dir, artifact_digest |
304 | 308 |
queue.put("No remote configured")
|
305 | 309 |
|
306 | 310 |
|
307 |
-def _test_pull_tree(user_config_file, project_dir, artifact_dir, artifact_digest, queue):
|
|
311 |
+def _test_pull_tree(user_config_file, project_dir, artifact_digest, queue):
|
|
308 | 312 |
# Fake minimal context
|
309 | 313 |
context = Context()
|
310 | 314 |
context.load(config=user_config_file)
|
311 |
- context.artifactdir = artifact_dir
|
|
312 | 315 |
context.set_message_handler(message_handler)
|
313 | 316 |
|
314 | 317 |
# Load the project manually
|
... | ... | @@ -51,7 +51,7 @@ def test_push(cli, tmpdir, datafiles): |
51 | 51 |
# Set up an artifact cache.
|
52 | 52 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
53 | 53 |
# Configure artifact share
|
54 |
- artifact_dir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
54 |
+ rootcache_dir = os.path.join(str(tmpdir), 'cache')
|
|
55 | 55 |
user_config_file = str(tmpdir.join('buildstream.conf'))
|
56 | 56 |
user_config = {
|
57 | 57 |
'scheduler': {
|
... | ... | @@ -60,7 +60,8 @@ def test_push(cli, tmpdir, datafiles): |
60 | 60 |
'artifacts': {
|
61 | 61 |
'url': share.repo,
|
62 | 62 |
'push': True,
|
63 |
- }
|
|
63 |
+ },
|
|
64 |
+ 'rootcachedir': rootcache_dir
|
|
64 | 65 |
}
|
65 | 66 |
|
66 | 67 |
# Write down the user configuration file
|
... | ... | @@ -69,7 +70,6 @@ def test_push(cli, tmpdir, datafiles): |
69 | 70 |
# Fake minimal context
|
70 | 71 |
context = Context()
|
71 | 72 |
context.load(config=user_config_file)
|
72 |
- context.artifactdir = artifact_dir
|
|
73 | 73 |
context.set_message_handler(message_handler)
|
74 | 74 |
|
75 | 75 |
# Load the project manually
|
... | ... | @@ -89,7 +89,7 @@ def test_push(cli, tmpdir, datafiles): |
89 | 89 |
# See https://github.com/grpc/grpc/blob/master/doc/fork_support.md for details
|
90 | 90 |
process = multiprocessing.Process(target=_queue_wrapper,
|
91 | 91 |
args=(_test_push, queue, user_config_file, project_dir,
|
92 |
- artifact_dir, 'target.bst', element_key))
|
|
92 |
+ 'target.bst', element_key))
|
|
93 | 93 |
|
94 | 94 |
try:
|
95 | 95 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -106,12 +106,10 @@ def test_push(cli, tmpdir, datafiles): |
106 | 106 |
assert share.has_artifact('test', 'target.bst', element_key)
|
107 | 107 |
|
108 | 108 |
|
109 |
-def _test_push(user_config_file, project_dir, artifact_dir,
|
|
110 |
- element_name, element_key, queue):
|
|
109 |
+def _test_push(user_config_file, project_dir, element_name, element_key, queue):
|
|
111 | 110 |
# Fake minimal context
|
112 | 111 |
context = Context()
|
113 | 112 |
context.load(config=user_config_file)
|
114 |
- context.artifactdir = artifact_dir
|
|
115 | 113 |
context.set_message_handler(message_handler)
|
116 | 114 |
|
117 | 115 |
# Load the project manually
|
... | ... | @@ -152,7 +150,7 @@ def test_push_directory(cli, tmpdir, datafiles): |
152 | 150 |
# Set up an artifact cache.
|
153 | 151 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
154 | 152 |
# Configure artifact share
|
155 |
- artifact_dir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
153 |
+ rootcache_dir = os.path.join(str(tmpdir), 'cache')
|
|
156 | 154 |
user_config_file = str(tmpdir.join('buildstream.conf'))
|
157 | 155 |
user_config = {
|
158 | 156 |
'scheduler': {
|
... | ... | @@ -161,7 +159,8 @@ def test_push_directory(cli, tmpdir, datafiles): |
161 | 159 |
'artifacts': {
|
162 | 160 |
'url': share.repo,
|
163 | 161 |
'push': True,
|
164 |
- }
|
|
162 |
+ },
|
|
163 |
+ 'rootcachedir': rootcache_dir
|
|
165 | 164 |
}
|
166 | 165 |
|
167 | 166 |
# Write down the user configuration file
|
... | ... | @@ -170,7 +169,6 @@ def test_push_directory(cli, tmpdir, datafiles): |
170 | 169 |
# Fake minimal context
|
171 | 170 |
context = Context()
|
172 | 171 |
context.load(config=user_config_file)
|
173 |
- context.artifactdir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
|
174 | 172 |
context.set_message_handler(message_handler)
|
175 | 173 |
|
176 | 174 |
# Load the project and CAS cache
|
... | ... | @@ -182,6 +180,7 @@ def test_push_directory(cli, tmpdir, datafiles): |
182 | 180 |
# Assert that the element's artifact is cached
|
183 | 181 |
element = project.load_elements(['target.bst'])[0]
|
184 | 182 |
element_key = cli.get_element_key(project_dir, 'target.bst')
|
183 |
+ print(context.casdir)
|
|
185 | 184 |
assert artifactcache.contains(element, element_key)
|
186 | 185 |
|
187 | 186 |
# Manually setup the CAS remote
|
... | ... | @@ -198,7 +197,7 @@ def test_push_directory(cli, tmpdir, datafiles): |
198 | 197 |
# See https://github.com/grpc/grpc/blob/master/doc/fork_support.md for details
|
199 | 198 |
process = multiprocessing.Process(target=_queue_wrapper,
|
200 | 199 |
args=(_test_push_directory, queue, user_config_file,
|
201 |
- project_dir, artifact_dir, artifact_digest))
|
|
200 |
+ project_dir, artifact_digest))
|
|
202 | 201 |
|
203 | 202 |
try:
|
204 | 203 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -216,11 +215,10 @@ def test_push_directory(cli, tmpdir, datafiles): |
216 | 215 |
assert share.has_object(artifact_digest)
|
217 | 216 |
|
218 | 217 |
|
219 |
-def _test_push_directory(user_config_file, project_dir, artifact_dir, artifact_digest, queue):
|
|
218 |
+def _test_push_directory(user_config_file, project_dir, artifact_digest, queue):
|
|
220 | 219 |
# Fake minimal context
|
221 | 220 |
context = Context()
|
222 | 221 |
context.load(config=user_config_file)
|
223 |
- context.artifactdir = artifact_dir
|
|
224 | 222 |
context.set_message_handler(message_handler)
|
225 | 223 |
|
226 | 224 |
# Load the project manually
|
... | ... | @@ -254,6 +252,7 @@ def test_push_message(cli, tmpdir, datafiles): |
254 | 252 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
255 | 253 |
# Configure artifact share
|
256 | 254 |
artifact_dir = os.path.join(str(tmpdir), 'cache', 'artifacts')
|
255 |
+ rootcache_dir = os.path.join(str(tmpdir), 'cache')
|
|
257 | 256 |
user_config_file = str(tmpdir.join('buildstream.conf'))
|
258 | 257 |
user_config = {
|
259 | 258 |
'scheduler': {
|
... | ... | @@ -262,7 +261,8 @@ def test_push_message(cli, tmpdir, datafiles): |
262 | 261 |
'artifacts': {
|
263 | 262 |
'url': share.repo,
|
264 | 263 |
'push': True,
|
265 |
- }
|
|
264 |
+ },
|
|
265 |
+ 'rootcachedir': rootcache_dir
|
|
266 | 266 |
}
|
267 | 267 |
|
268 | 268 |
# Write down the user configuration file
|
... | ... | @@ -273,7 +273,7 @@ def test_push_message(cli, tmpdir, datafiles): |
273 | 273 |
# See https://github.com/grpc/grpc/blob/master/doc/fork_support.md for details
|
274 | 274 |
process = multiprocessing.Process(target=_queue_wrapper,
|
275 | 275 |
args=(_test_push_message, queue, user_config_file,
|
276 |
- project_dir, artifact_dir))
|
|
276 |
+ project_dir))
|
|
277 | 277 |
|
278 | 278 |
try:
|
279 | 279 |
# Keep SIGINT blocked in the child process
|
... | ... | @@ -292,11 +292,10 @@ def test_push_message(cli, tmpdir, datafiles): |
292 | 292 |
assert share.has_object(message_digest)
|
293 | 293 |
|
294 | 294 |
|
295 |
-def _test_push_message(user_config_file, project_dir, artifact_dir, queue):
|
|
295 |
+def _test_push_message(user_config_file, project_dir, queue):
|
|
296 | 296 |
# Fake minimal context
|
297 | 297 |
context = Context()
|
298 | 298 |
context.load(config=user_config_file)
|
299 |
- context.artifactdir = artifact_dir
|
|
300 | 299 |
context.set_message_handler(message_handler)
|
301 | 300 |
|
302 | 301 |
# Load the project manually
|
... | ... | @@ -389,8 +389,9 @@ def test_filter_track_multi(datafiles, cli, tmpdir): |
389 | 389 |
_yaml.dump(filter2_config, filter2_file)
|
390 | 390 |
|
391 | 391 |
# Assert that a fetch is needed
|
392 |
- assert cli.get_element_state(project, input_name) == 'no reference'
|
|
393 |
- assert cli.get_element_state(project, input2_name) == 'no reference'
|
|
392 |
+ states = cli.get_element_states(project, [input_name, input2_name])
|
|
393 |
+ assert states[input_name] == 'no reference'
|
|
394 |
+ assert states[input2_name] == 'no reference'
|
|
394 | 395 |
|
395 | 396 |
# Now try to track it
|
396 | 397 |
result = cli.run(project=project, args=["source", "track", "filter1.bst", "filter2.bst"])
|
... | ... | @@ -450,8 +451,9 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir): |
450 | 451 |
_yaml.dump(filter2_config, filter2_file)
|
451 | 452 |
|
452 | 453 |
# Assert that a fetch is needed
|
453 |
- assert cli.get_element_state(project, input_name) == 'no reference'
|
|
454 |
- assert cli.get_element_state(project, input2_name) == 'no reference'
|
|
454 |
+ states = cli.get_element_states(project, [input_name, input2_name])
|
|
455 |
+ assert states[input_name] == 'no reference'
|
|
456 |
+ assert states[input2_name] == 'no reference'
|
|
455 | 457 |
|
456 | 458 |
# Now try to track it
|
457 | 459 |
result = cli.run(project=project, args=["source", "track", "filter1.bst", "filter2.bst", "--except", input_name])
|
... | ... | @@ -62,20 +62,20 @@ def test_push_pull_all(cli, tmpdir, datafiles): |
62 | 62 |
# Now we've pushed, delete the user's local artifact cache
|
63 | 63 |
# directory and try to redownload it from the share
|
64 | 64 |
#
|
65 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
66 |
- shutil.rmtree(artifacts)
|
|
65 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
66 |
+ shutil.rmtree(cas)
|
|
67 | 67 |
|
68 | 68 |
# Assert that nothing is cached locally anymore
|
69 |
- for element_name in all_elements:
|
|
70 |
- assert cli.get_element_state(project, element_name) != 'cached'
|
|
69 |
+ states = cli.get_element_states(project, all_elements)
|
|
70 |
+ assert not any(states[e] == 'cached' for e in all_elements)
|
|
71 | 71 |
|
72 | 72 |
# Now try bst pull
|
73 | 73 |
result = cli.run(project=project, args=['artifact', 'pull', '--deps', 'all', 'target.bst'])
|
74 | 74 |
result.assert_success()
|
75 | 75 |
|
76 | 76 |
# And assert that it's again in the local cache, without having built
|
77 |
- for element_name in all_elements:
|
|
78 |
- assert cli.get_element_state(project, element_name) == 'cached'
|
|
77 |
+ states = cli.get_element_states(project, all_elements)
|
|
78 |
+ assert not any(states[e] != 'cached' for e in all_elements)
|
|
79 | 79 |
|
80 | 80 |
|
81 | 81 |
# Tests that:
|
... | ... | @@ -104,8 +104,8 @@ def test_pull_secondary_cache(cli, tmpdir, datafiles): |
104 | 104 |
assert_shared(cli, share2, project, 'target.bst')
|
105 | 105 |
|
106 | 106 |
# Delete the user's local artifact cache.
|
107 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
108 |
- shutil.rmtree(artifacts)
|
|
107 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
108 |
+ shutil.rmtree(cas)
|
|
109 | 109 |
|
110 | 110 |
# Assert that the element is not cached anymore.
|
111 | 111 |
assert cli.get_element_state(project, 'target.bst') != 'cached'
|
... | ... | @@ -158,8 +158,8 @@ def test_push_pull_specific_remote(cli, tmpdir, datafiles): |
158 | 158 |
# Now we've pushed, delete the user's local artifact cache
|
159 | 159 |
# directory and try to redownload it from the good_share.
|
160 | 160 |
#
|
161 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
162 |
- shutil.rmtree(artifacts)
|
|
161 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
162 |
+ shutil.rmtree(cas)
|
|
163 | 163 |
|
164 | 164 |
result = cli.run(project=project, args=['artifact', 'pull', 'target.bst', '--remote',
|
165 | 165 |
good_share.repo])
|
... | ... | @@ -199,8 +199,8 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles): |
199 | 199 |
# Now we've pushed, delete the user's local artifact cache
|
200 | 200 |
# directory and try to redownload it from the share
|
201 | 201 |
#
|
202 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
203 |
- shutil.rmtree(artifacts)
|
|
202 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
203 |
+ shutil.rmtree(cas)
|
|
204 | 204 |
|
205 | 205 |
# Assert that nothing is cached locally anymore
|
206 | 206 |
for element_name in all_elements:
|
... | ... | @@ -249,8 +249,8 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles): |
249 | 249 |
# Now we've pushed, delete the user's local artifact cache
|
250 | 250 |
# directory and try to redownload it from the share
|
251 | 251 |
#
|
252 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
253 |
- shutil.rmtree(artifacts)
|
|
252 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
253 |
+ shutil.rmtree(cas)
|
|
254 | 254 |
|
255 | 255 |
# Assert that nothing is cached locally anymore
|
256 | 256 |
for element_name in all_elements:
|
... | ... | @@ -285,7 +285,7 @@ def test_push_pull_cross_junction(cli, tmpdir, datafiles): |
285 | 285 |
result.assert_success()
|
286 | 286 |
assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'cached'
|
287 | 287 |
|
288 |
- cache_dir = os.path.join(project, 'cache', 'artifacts')
|
|
288 |
+ cache_dir = os.path.join(project, 'cache', 'cas')
|
|
289 | 289 |
shutil.rmtree(cache_dir)
|
290 | 290 |
|
291 | 291 |
assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'buildable'
|
... | ... | @@ -320,8 +320,8 @@ def test_pull_missing_blob(cli, tmpdir, datafiles): |
320 | 320 |
# Now we've pushed, delete the user's local artifact cache
|
321 | 321 |
# directory and try to redownload it from the share
|
322 | 322 |
#
|
323 |
- artifacts = os.path.join(cli.directory, 'artifacts')
|
|
324 |
- shutil.rmtree(artifacts)
|
|
323 |
+ cas = os.path.join(cli.directory, 'cas')
|
|
324 |
+ shutil.rmtree(cas)
|
|
325 | 325 |
|
326 | 326 |
# Assert that nothing is cached locally anymore
|
327 | 327 |
for element_name in all_elements:
|
... | ... | @@ -250,9 +250,10 @@ def test_artifact_expires(cli, datafiles, tmpdir): |
250 | 250 |
result.assert_success()
|
251 | 251 |
|
252 | 252 |
# check that element's 1 and 2 are cached both locally and remotely
|
253 |
- assert cli.get_element_state(project, 'element1.bst') == 'cached'
|
|
253 |
+ states = cli.get_element_states(project, ['element1.bst', 'element2.bst'])
|
|
254 |
+ assert states['element1.bst'] == 'cached'
|
|
255 |
+ assert states['element2.bst'] == 'cached'
|
|
254 | 256 |
assert_shared(cli, share, project, 'element1.bst')
|
255 |
- assert cli.get_element_state(project, 'element2.bst') == 'cached'
|
|
256 | 257 |
assert_shared(cli, share, project, 'element2.bst')
|
257 | 258 |
|
258 | 259 |
# Create and build another element of 5 MB (This will exceed the free disk space available)
|
... | ... | @@ -298,11 +299,12 @@ def test_artifact_too_large(cli, datafiles, tmpdir): |
298 | 299 |
result.assert_success()
|
299 | 300 |
|
300 | 301 |
# Ensure that the small artifact is still in the share
|
301 |
- assert cli.get_element_state(project, 'small_element.bst') == 'cached'
|
|
302 |
+ states = cli.get_element_states(project, ['small_element.bst', 'large_element.bst'])
|
|
303 |
+ states['small_element.bst'] == 'cached'
|
|
302 | 304 |
assert_shared(cli, share, project, 'small_element.bst')
|
303 | 305 |
|
304 | 306 |
# Ensure that the artifact is cached locally but NOT remotely
|
305 |
- assert cli.get_element_state(project, 'large_element.bst') == 'cached'
|
|
307 |
+ states['large_element.bst'] == 'cached'
|
|
306 | 308 |
assert_not_shared(cli, share, project, 'large_element.bst')
|
307 | 309 |
|
308 | 310 |
|
... | ... | @@ -334,8 +336,9 @@ def test_recently_pulled_artifact_does_not_expire(cli, datafiles, tmpdir): |
334 | 336 |
result.assert_success()
|
335 | 337 |
|
336 | 338 |
# Ensure they are cached locally
|
337 |
- assert cli.get_element_state(project, 'element1.bst') == 'cached'
|
|
338 |
- assert cli.get_element_state(project, 'element2.bst') == 'cached'
|
|
339 |
+ states = cli.get_element_states(project, ['element1.bst', 'element2.bst'])
|
|
340 |
+ assert states['element1.bst'] == 'cached'
|
|
341 |
+ assert states['element2.bst'] == 'cached'
|
|
339 | 342 |
|
340 | 343 |
# Ensure that they have been pushed to the cache
|
341 | 344 |
assert_shared(cli, share, project, 'element1.bst')
|
... | ... | @@ -123,7 +123,7 @@ def test_track_recurse(cli, tmpdir, datafiles, kind, amount): |
123 | 123 |
last_element_name = element_name
|
124 | 124 |
|
125 | 125 |
# Assert that a fetch is needed
|
126 |
- states = cli.get_element_states(project, last_element_name)
|
|
126 |
+ states = cli.get_element_states(project, [last_element_name])
|
|
127 | 127 |
for element_name in element_names:
|
128 | 128 |
assert states[element_name] == 'no reference'
|
129 | 129 |
|
... | ... | @@ -143,7 +143,7 @@ def test_track_recurse(cli, tmpdir, datafiles, kind, amount): |
143 | 143 |
result.assert_success()
|
144 | 144 |
|
145 | 145 |
# Assert that the base is buildable and the rest are waiting
|
146 |
- states = cli.get_element_states(project, last_element_name)
|
|
146 |
+ states = cli.get_element_states(project, [last_element_name])
|
|
147 | 147 |
for element_name in element_names:
|
148 | 148 |
if element_name == element_names[0]:
|
149 | 149 |
assert states[element_name] == 'buildable'
|
... | ... | @@ -171,8 +171,9 @@ def test_track_single(cli, tmpdir, datafiles): |
171 | 171 |
dep_name=element_dep_name)
|
172 | 172 |
|
173 | 173 |
# Assert that tracking is needed for both elements
|
174 |
- assert cli.get_element_state(project, element_dep_name) == 'no reference'
|
|
175 |
- assert cli.get_element_state(project, element_target_name) == 'no reference'
|
|
174 |
+ states = cli.get_element_states(project, [element_target_name])
|
|
175 |
+ assert states[element_dep_name] == 'no reference'
|
|
176 |
+ assert states[element_target_name] == 'no reference'
|
|
176 | 177 |
|
177 | 178 |
# Now first try to track only one element
|
178 | 179 |
result = cli.run(project=project, args=[
|
... | ... | @@ -187,8 +188,9 @@ def test_track_single(cli, tmpdir, datafiles): |
187 | 188 |
result.assert_success()
|
188 | 189 |
|
189 | 190 |
# Assert that the dependency is waiting and the target has still never been tracked
|
190 |
- assert cli.get_element_state(project, element_dep_name) == 'no reference'
|
|
191 |
- assert cli.get_element_state(project, element_target_name) == 'waiting'
|
|
191 |
+ states = cli.get_element_states(project, [element_target_name])
|
|
192 |
+ assert states[element_dep_name] == 'no reference'
|
|
193 |
+ assert states[element_target_name] == 'waiting'
|
|
192 | 194 |
|
193 | 195 |
|
194 | 196 |
@pytest.mark.datafiles(DATA_DIR)
|
... | ... | @@ -212,8 +214,9 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): |
212 | 214 |
dep_name=element_dep_name)
|
213 | 215 |
|
214 | 216 |
# Assert that a fetch is needed
|
215 |
- assert cli.get_element_state(project, element_dep_name) == 'no reference'
|
|
216 |
- assert cli.get_element_state(project, element_target_name) == 'no reference'
|
|
217 |
+ states = cli.get_element_states(project, [element_target_name])
|
|
218 |
+ assert states[element_dep_name] == 'no reference'
|
|
219 |
+ assert states[element_target_name] == 'no reference'
|
|
217 | 220 |
|
218 | 221 |
# Now first try to track it
|
219 | 222 |
result = cli.run(project=project, args=[
|
... | ... | @@ -231,8 +234,9 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): |
231 | 234 |
result.assert_success()
|
232 | 235 |
|
233 | 236 |
# Assert that the dependency is buildable and the target is waiting
|
234 |
- assert cli.get_element_state(project, element_dep_name) == 'no reference'
|
|
235 |
- assert cli.get_element_state(project, element_target_name) == 'waiting'
|
|
237 |
+ states = cli.get_element_states(project, [element_target_name])
|
|
238 |
+ assert states[element_dep_name] == 'no reference'
|
|
239 |
+ assert states[element_target_name] == 'waiting'
|
|
236 | 240 |
|
237 | 241 |
|
238 | 242 |
@pytest.mark.datafiles(os.path.join(TOP_DIR))
|
... | ... | @@ -672,21 +676,20 @@ def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind): |
672 | 676 |
|
673 | 677 |
|
674 | 678 |
@pytest.mark.datafiles(DATA_DIR)
|
675 |
-@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
|
|
676 |
-def test_track_error_cannot_write_file(cli, tmpdir, datafiles, kind):
|
|
679 |
+def test_track_error_cannot_write_file(cli, tmpdir, datafiles):
|
|
677 | 680 |
if os.geteuid() == 0:
|
678 | 681 |
pytest.skip("This is not testable with root permissions")
|
679 | 682 |
|
680 | 683 |
project = str(datafiles)
|
681 | 684 |
dev_files_path = os.path.join(project, 'files', 'dev-files')
|
682 | 685 |
element_path = os.path.join(project, 'elements')
|
683 |
- element_name = 'track-test-{}.bst'.format(kind)
|
|
686 |
+ element_name = 'track-test.bst'
|
|
684 | 687 |
|
685 | 688 |
configure_project(project, {
|
686 | 689 |
'ref-storage': 'inline'
|
687 | 690 |
})
|
688 | 691 |
|
689 |
- repo = create_repo(kind, str(tmpdir))
|
|
692 |
+ repo = create_repo('git', str(tmpdir))
|
|
690 | 693 |
ref = repo.create(dev_files_path)
|
691 | 694 |
|
692 | 695 |
element_full_path = os.path.join(element_path, element_name)
|
... | ... | @@ -107,15 +107,17 @@ class WorkspaceCreater(): |
107 | 107 |
element_name, element_path, workspace_dir = \
|
108 | 108 |
self.create_workspace_element(kind, track, suffix, workspace_dir_usr,
|
109 | 109 |
element_attrs)
|
110 |
- |
|
111 |
- # Assert that there is no reference, a track & fetch is needed
|
|
112 |
- state = self.cli.get_element_state(self.project_path, element_name)
|
|
113 |
- if track:
|
|
114 |
- assert state == 'no reference'
|
|
115 |
- else:
|
|
116 |
- assert state == 'fetch needed'
|
|
117 | 110 |
element_tuples.append((element_name, workspace_dir))
|
118 | 111 |
|
112 |
+ # Assert that there is no reference, a track & fetch is needed
|
|
113 |
+ states = self.cli.get_element_states(self.project_path, [
|
|
114 |
+ e for e, _ in element_tuples
|
|
115 |
+ ])
|
|
116 |
+ if track:
|
|
117 |
+ assert not any(states[e] != 'no reference' for e, _ in element_tuples)
|
|
118 |
+ else:
|
|
119 |
+ assert not any(states[e] != 'fetch needed' for e, _ in element_tuples)
|
|
120 |
+ |
|
119 | 121 |
return element_tuples
|
120 | 122 |
|
121 | 123 |
def open_workspaces(self, kinds, track, suffixs=None, workspace_dir=None,
|
... | ... | @@ -140,12 +142,14 @@ class WorkspaceCreater(): |
140 | 142 |
|
141 | 143 |
result.assert_success()
|
142 | 144 |
|
143 |
- for element_name, workspace_dir in element_tuples:
|
|
144 |
- # Assert that we are now buildable because the source is
|
|
145 |
- # now cached.
|
|
146 |
- assert self.cli.get_element_state(self.project_path, element_name) == 'buildable'
|
|
145 |
+ # Assert that we are now buildable because the source is now cached.
|
|
146 |
+ states = self.cli.get_element_states(self.project_path, [
|
|
147 |
+ e for e, _ in element_tuples
|
|
148 |
+ ])
|
|
149 |
+ assert not any(states[e] != 'buildable' for e, _ in element_tuples)
|
|
147 | 150 |
|
148 |
- # Check that the executable hello file is found in the workspace
|
|
151 |
+ # Check that the executable hello file is found in each workspace
|
|
152 |
+ for element_name, workspace_dir in element_tuples:
|
|
149 | 153 |
filename = os.path.join(workspace_dir, 'usr', 'bin', 'hello')
|
150 | 154 |
assert os.path.exists(filename)
|
151 | 155 |
|
... | ... | @@ -158,10 +158,8 @@ def test_buildtree_options(cli, tmpdir, datafiles): |
158 | 158 |
assert cli.get_element_state(project, element_name) == 'cached'
|
159 | 159 |
|
160 | 160 |
# Discard the cache
|
161 |
- cli.configure({
|
|
162 |
- 'artifacts': {'url': share.repo, 'push': True},
|
|
163 |
- 'artifactdir': os.path.join(cli.directory, 'artifacts2')
|
|
164 |
- })
|
|
161 |
+ shutil.rmtree(str(os.path.join(str(tmpdir), 'cache', 'artifacts')))
|
|
162 |
+ shutil.rmtree(str(os.path.join(str(tmpdir), 'cache', 'cas')))
|
|
165 | 163 |
assert cli.get_element_state(project, element_name) != 'cached'
|
166 | 164 |
|
167 | 165 |
# Pull from cache, but do not include buildtrees.
|
... | ... | @@ -160,7 +160,6 @@ def test_push_cached_fail(cli, tmpdir, datafiles, on_error): |
160 | 160 |
|
161 | 161 |
# This element should have failed
|
162 | 162 |
assert cli.get_element_state(project, 'element.bst') == 'failed'
|
163 |
- # This element should have been pushed to the remote
|
|
164 | 163 |
assert share.has_artifact('test', 'element.bst', cli.get_element_key(project, 'element.bst'))
|
165 | 164 |
|
166 | 165 |
|
... | ... | @@ -40,7 +40,7 @@ DATA_DIR = os.path.join( |
40 | 40 |
@pytest.mark.integration
|
41 | 41 |
@pytest.mark.datafiles(DATA_DIR)
|
42 | 42 |
@pytest.mark.skipif(IS_LINUX and not HAVE_BWRAP, reason='Only available with bubblewrap on Linux')
|
43 |
-def test_disable_message_lines(cli, tmpdir, datafiles):
|
|
43 |
+def test_disable_message_lines(cli, tmpdir, datafiles, integration_cache):
|
|
44 | 44 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
45 | 45 |
element_path = os.path.join(project, 'elements')
|
46 | 46 |
element_name = 'message.bst'
|
... | ... | @@ -66,7 +66,7 @@ def test_disable_message_lines(cli, tmpdir, datafiles): |
66 | 66 |
assert 'echo "Silly message"' in result.stderr
|
67 | 67 |
|
68 | 68 |
# Let's now build it again, but with --message-lines 0
|
69 |
- cli.remove_artifact_from_cache(project, element_name)
|
|
69 |
+ cli.remove_artifact_from_cache(project, element_name, cache_dir=integration_cache.root)
|
|
70 | 70 |
result = cli.run(project=project, args=["--message-lines", "0",
|
71 | 71 |
"build", element_name])
|
72 | 72 |
result.assert_success()
|
... | ... | @@ -76,7 +76,7 @@ def test_disable_message_lines(cli, tmpdir, datafiles): |
76 | 76 |
@pytest.mark.integration
|
77 | 77 |
@pytest.mark.datafiles(DATA_DIR)
|
78 | 78 |
@pytest.mark.skipif(IS_LINUX and not HAVE_BWRAP, reason='Only available with bubblewrap on Linux')
|
79 |
-def test_disable_error_lines(cli, tmpdir, datafiles):
|
|
79 |
+def test_disable_error_lines(cli, tmpdir, datafiles, integration_cache):
|
|
80 | 80 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
81 | 81 |
element_path = os.path.join(project, 'elements')
|
82 | 82 |
element_name = 'message.bst'
|
... | ... | @@ -103,7 +103,7 @@ def test_disable_error_lines(cli, tmpdir, datafiles): |
103 | 103 |
assert "This is a syntax error" in result.stderr
|
104 | 104 |
|
105 | 105 |
# Let's now build it again, but with --error-lines 0
|
106 |
- cli.remove_artifact_from_cache(project, element_name)
|
|
106 |
+ cli.remove_artifact_from_cache(project, element_name, cache_dir=integration_cache.root)
|
|
107 | 107 |
result = cli.run(project=project, args=["--error-lines", "0",
|
108 | 108 |
"build", element_name])
|
109 | 109 |
result.assert_main_error(ErrorDomain.STREAM, None)
|
... | ... | @@ -19,9 +19,10 @@ DATA_DIR = os.path.join( |
19 | 19 |
# cleared as just forcefully removing the refpath leaves dangling objects.
|
20 | 20 |
def default_state(cli, tmpdir, share):
|
21 | 21 |
shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
|
22 |
+ shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
|
|
22 | 23 |
cli.configure({
|
23 | 24 |
'artifacts': {'url': share.repo, 'push': False},
|
24 |
- 'artifactdir': os.path.join(str(tmpdir), 'artifacts'),
|
|
25 |
+ 'rootcachedir': str(tmpdir),
|
|
25 | 26 |
'cache': {'pull-buildtrees': False},
|
26 | 27 |
})
|
27 | 28 |
|
... | ... | @@ -42,7 +43,7 @@ def test_pullbuildtrees(cli2, tmpdir, datafiles): |
42 | 43 |
create_artifact_share(os.path.join(str(tmpdir), 'share3')) as share3:
|
43 | 44 |
cli2.configure({
|
44 | 45 |
'artifacts': {'url': share1.repo, 'push': True},
|
45 |
- 'artifactdir': os.path.join(str(tmpdir), 'artifacts')
|
|
46 |
+ 'rootcachedir': str(tmpdir),
|
|
46 | 47 |
})
|
47 | 48 |
|
48 | 49 |
# Build autotools element, checked pushed, delete local
|
... | ... | @@ -79,7 +80,7 @@ def test_pullbuildtrees(cli2, tmpdir, datafiles): |
79 | 80 |
assert os.path.isdir(buildtreedir)
|
80 | 81 |
default_state(cli2, tmpdir, share1)
|
81 | 82 |
|
82 |
- # Pull artifact with pullbuildtrees set in user config, then assert
|
|
83 |
+ # Pull artifact with pullbuildtrees set in user onfig, then assert
|
|
83 | 84 |
# that pulling with the same user config doesn't creates a pull job,
|
84 | 85 |
# or when buildtrees cli flag is set.
|
85 | 86 |
cli2.configure({'cache': {'pull-buildtrees': True}})
|
... | ... | @@ -94,9 +94,7 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind, integration_ca |
94 | 94 |
return f.read()
|
95 | 95 |
finally:
|
96 | 96 |
os.umask(old_umask)
|
97 |
- cache_dir = integration_cache.artifacts
|
|
98 |
- cli.remove_artifact_from_cache(project, element_name,
|
|
99 |
- cache_dir=cache_dir)
|
|
97 |
+ cli.remove_artifact_from_cache(project, element_name, cache_dir=integration_cache.root)
|
|
100 | 98 |
|
101 | 99 |
assert get_value_for_umask(0o022) == get_value_for_umask(0o077)
|
102 | 100 |
|
... | ... | @@ -156,8 +154,6 @@ def test_deterministic_source_local(cli, tmpdir, datafiles, integration_cache): |
156 | 154 |
with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f:
|
157 | 155 |
return f.read()
|
158 | 156 |
finally:
|
159 |
- cache_dir = integration_cache.artifacts
|
|
160 |
- cli.remove_artifact_from_cache(project, element_name,
|
|
161 |
- cache_dir=cache_dir)
|
|
157 |
+ cli.remove_artifact_from_cache(project, element_name, cache_dir=integration_cache.root)
|
|
162 | 158 |
|
163 | 159 |
assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700)
|
1 |
-import os
|
|
2 |
-from unittest import mock
|
|
3 |
- |
|
4 |
-from buildstream import _yaml
|
|
5 |
- |
|
6 |
-from ..testutils.runcli import cli
|
|
7 |
- |
|
8 |
- |
|
9 |
-KiB = 1024
|
|
10 |
-MiB = (KiB * 1024)
|
|
11 |
-GiB = (MiB * 1024)
|
|
12 |
-TiB = (GiB * 1024)
|
|
13 |
- |
|
14 |
- |
|
15 |
-def test_parse_size_over_1024T(cli, tmpdir):
|
|
16 |
- cli.configure({
|
|
17 |
- 'cache': {
|
|
18 |
- 'quota': 2048 * TiB
|
|
19 |
- }
|
|
20 |
- })
|
|
21 |
- project = tmpdir.join("main")
|
|
22 |
- os.makedirs(str(project))
|
|
23 |
- _yaml.dump({'name': 'main'}, str(project.join("project.conf")))
|
|
24 |
- |
|
25 |
- volume_space_patch = mock.patch(
|
|
26 |
- "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for",
|
|
27 |
- autospec=True,
|
|
28 |
- return_value=(1025 * TiB, 1025 * TiB)
|
|
29 |
- )
|
|
30 |
- |
|
31 |
- with volume_space_patch:
|
|
32 |
- result = cli.run(project, args=["build", "file.bst"])
|
|
33 |
- failure_msg = 'Your system does not have enough available space to support the cache quota specified.'
|
|
34 |
- assert failure_msg in result.stderr
|
... | ... | @@ -136,18 +136,25 @@ def test_unique_key(cli, tmpdir, datafiles): |
136 | 136 |
'''
|
137 | 137 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
138 | 138 |
generate_project(project, tmpdir)
|
139 |
- assert cli.get_element_state(project, 'target.bst') == "fetch needed"
|
|
140 |
- assert cli.get_element_state(project, 'target-custom.bst') == "fetch needed"
|
|
141 |
- assert cli.get_element_state(project, 'target-custom-executable.bst') == "fetch needed"
|
|
139 |
+ states = cli.get_element_states(project, [
|
|
140 |
+ 'target.bst', 'target-custom.bst', 'target-custom-executable.bst'
|
|
141 |
+ ])
|
|
142 |
+ assert states['target.bst'] == "fetch needed"
|
|
143 |
+ assert states['target-custom.bst'] == "fetch needed"
|
|
144 |
+ assert states['target-custom-executable.bst'] == "fetch needed"
|
|
145 |
+ |
|
142 | 146 |
# Try to fetch it
|
143 | 147 |
result = cli.run(project=project, args=[
|
144 | 148 |
'source', 'fetch', 'target.bst'
|
145 | 149 |
])
|
146 | 150 |
|
147 | 151 |
# We should download the file only once
|
148 |
- assert cli.get_element_state(project, 'target.bst') == 'buildable'
|
|
149 |
- assert cli.get_element_state(project, 'target-custom.bst') == 'buildable'
|
|
150 |
- assert cli.get_element_state(project, 'target-custom-executable.bst') == 'buildable'
|
|
152 |
+ states = cli.get_element_states(project, [
|
|
153 |
+ 'target.bst', 'target-custom.bst', 'target-custom-executable.bst'
|
|
154 |
+ ])
|
|
155 |
+ assert states['target.bst'] == 'buildable'
|
|
156 |
+ assert states['target-custom.bst'] == 'buildable'
|
|
157 |
+ assert states['target-custom-executable.bst'] == 'buildable'
|
|
151 | 158 |
|
152 | 159 |
# But the cache key is different because the 'filename' is different.
|
153 | 160 |
assert cli.get_element_key(project, 'target.bst') != \
|
... | ... | @@ -247,15 +247,13 @@ class Cli(): |
247 | 247 |
*, cache_dir=None):
|
248 | 248 |
# Read configuration to figure out where artifacts are stored
|
249 | 249 |
if not cache_dir:
|
250 |
- default = os.path.join(project, 'cache', 'artifacts')
|
|
251 |
- |
|
252 |
- if self.config is not None:
|
|
253 |
- cache_dir = self.config.get('artifactdir', default)
|
|
254 |
- else:
|
|
255 |
- cache_dir = default
|
|
250 |
+ cache_dir = os.path.join(project, 'cache')
|
|
256 | 251 |
|
257 | 252 |
cache_dir = os.path.join(cache_dir, 'cas', 'refs', 'heads')
|
258 | 253 |
|
254 |
+ # replace forward slashes
|
|
255 |
+ element_name = element_name.replace('/', '-')
|
|
256 |
+ |
|
259 | 257 |
cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0]
|
260 | 258 |
shutil.rmtree(cache_dir)
|
261 | 259 |
|
... | ... | @@ -398,13 +396,12 @@ class Cli(): |
398 | 396 |
#
|
399 | 397 |
# Returns a dictionary with the element names as keys
|
400 | 398 |
#
|
401 |
- def get_element_states(self, project, target, deps='all'):
|
|
399 |
+ def get_element_states(self, project, targets, deps='all'):
|
|
402 | 400 |
result = self.run(project=project, silent=True, args=[
|
403 | 401 |
'show',
|
404 | 402 |
'--deps', deps,
|
405 | 403 |
'--format', '%{name}||%{state}',
|
406 |
- target
|
|
407 |
- ])
|
|
404 |
+ ] + targets)
|
|
408 | 405 |
result.assert_success()
|
409 | 406 |
lines = result.output.splitlines()
|
410 | 407 |
states = {}
|
... | ... | @@ -553,11 +550,21 @@ def cli_integration(tmpdir, integration_cache): |
553 | 550 |
# We want to cache sources for integration tests more permanently,
|
554 | 551 |
# to avoid downloading the huge base-sdk repeatedly
|
555 | 552 |
fixture.configure({
|
553 |
+ 'rootcachedir': integration_cache.root,
|
|
556 | 554 |
'sourcedir': integration_cache.sources,
|
557 |
- 'artifactdir': integration_cache.artifacts
|
|
558 | 555 |
})
|
559 | 556 |
|
560 |
- return fixture
|
|
557 |
+ yield fixture
|
|
558 |
+ |
|
559 |
+ # remove following folders if necessary
|
|
560 |
+ try:
|
|
561 |
+ shutil.rmtree(os.path.join(integration_cache.root, 'build'))
|
|
562 |
+ except FileNotFoundError:
|
|
563 |
+ pass
|
|
564 |
+ try:
|
|
565 |
+ shutil.rmtree(os.path.join(integration_cache.root, 'tmp'))
|
|
566 |
+ except FileNotFoundError:
|
|
567 |
+ pass
|
|
561 | 568 |
|
562 | 569 |
|
563 | 570 |
@contextmanager
|
... | ... | @@ -597,10 +604,8 @@ def configured(directory, config=None): |
597 | 604 |
|
598 | 605 |
if not config.get('sourcedir', False):
|
599 | 606 |
config['sourcedir'] = os.path.join(directory, 'sources')
|
600 |
- if not config.get('builddir', False):
|
|
601 |
- config['builddir'] = os.path.join(directory, 'build')
|
|
602 |
- if not config.get('artifactdir', False):
|
|
603 |
- config['artifactdir'] = os.path.join(directory, 'artifacts')
|
|
607 |
+ if not config.get('rootcachedir', False):
|
|
608 |
+ config['rootcachedir'] = directory
|
|
604 | 609 |
if not config.get('logdir', False):
|
605 | 610 |
config['logdir'] = os.path.join(directory, 'logs')
|
606 | 611 |
|