summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-10-17 11:02:49 +0100
committerJürg Billeter <j@bitron.ch>2018-11-05 17:18:12 +0000
commit626d20aefb52d25d987c61f377cc1ce3172da8c3 (patch)
tree5a451d29e9c793ba86ded6a5867c1f3911bfd662 /tests
parente398f877ab2cb41e7fa531fd71ad9b503fbbedac (diff)
downloadbuildstream-626d20aefb52d25d987c61f377cc1ce3172da8c3.tar.gz
Split up artifact cache and CAS cache
This changes CASCache from a subclass to a delegate object of ArtifactCache. As the lower layer, CASCache no longer deals with elements or projects. Fixes #659.
Diffstat (limited to 'tests')
-rw-r--r--tests/artifactcache/pull.py16
-rw-r--r--tests/artifactcache/push.py13
-rw-r--r--tests/testutils/artifactshare.py6
3 files changed, 19 insertions, 16 deletions
diff --git a/tests/artifactcache/pull.py b/tests/artifactcache/pull.py
index 3e936fc70..dde451a8c 100644
--- a/tests/artifactcache/pull.py
+++ b/tests/artifactcache/pull.py
@@ -190,15 +190,16 @@ def test_pull_tree(cli, tmpdir, datafiles):
# Load the project and CAS cache
project = Project(project_dir, context)
project.ensure_fully_loaded()
- cas = context.artifactcache
+ artifactcache = context.artifactcache
+ cas = artifactcache.cas
# Assert that the element's artifact is cached
element = project.load_elements(['target.bst'])[0]
element_key = cli.get_element_key(project_dir, 'target.bst')
- assert cas.contains(element, element_key)
+ assert artifactcache.contains(element, element_key)
# Retrieve the Directory object from the cached artifact
- artifact_ref = cas.get_artifact_fullname(element, element_key)
+ artifact_ref = artifactcache.get_artifact_fullname(element, element_key)
artifact_digest = cas.resolve_ref(artifact_ref)
queue = multiprocessing.Queue()
@@ -268,12 +269,13 @@ def _test_push_tree(user_config_file, project_dir, artifact_dir, artifact_digest
project.ensure_fully_loaded()
# Create a local CAS cache handle
- cas = context.artifactcache
+ artifactcache = context.artifactcache
+ cas = artifactcache.cas
# Manually setup the CAS remote
- cas.setup_remotes(use_config=True)
+ artifactcache.setup_remotes(use_config=True)
- if cas.has_push_remotes():
+ if artifactcache.has_push_remotes():
directory = remote_execution_pb2.Directory()
with open(cas.objpath(artifact_digest), 'rb') as f:
@@ -284,7 +286,7 @@ def _test_push_tree(user_config_file, project_dir, artifact_dir, artifact_digest
tree_maker(cas, tree, directory)
# Push the Tree as a regular message
- tree_digest = cas.push_message(project, tree)
+ tree_digest = artifactcache.push_message(project, tree)
queue.put((tree_digest.hash, tree_digest.size_bytes))
else:
diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py
index ca8cbd241..be6293cf4 100644
--- a/tests/artifactcache/push.py
+++ b/tests/artifactcache/push.py
@@ -165,20 +165,21 @@ def test_push_directory(cli, tmpdir, datafiles):
# Load the project and CAS cache
project = Project(project_dir, context)
project.ensure_fully_loaded()
- cas = context.artifactcache
+ artifactcache = context.artifactcache
+ cas = artifactcache.cas
# Assert that the element's artifact is cached
element = project.load_elements(['target.bst'])[0]
element_key = cli.get_element_key(project_dir, 'target.bst')
- assert cas.contains(element, element_key)
+ assert artifactcache.contains(element, element_key)
# Manually setup the CAS remote
- cas.setup_remotes(use_config=True)
- cas.initialize_remotes()
- assert cas.has_push_remotes(element=element)
+ artifactcache.setup_remotes(use_config=True)
+ artifactcache.initialize_remotes()
+ assert artifactcache.has_push_remotes(element=element)
# Recreate the CasBasedDirectory object from the cached artifact
- artifact_ref = cas.get_artifact_fullname(element, element_key)
+ artifact_ref = artifactcache.get_artifact_fullname(element, element_key)
artifact_digest = cas.resolve_ref(artifact_ref)
queue = multiprocessing.Queue()
diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py
index a8af59905..02f76de90 100644
--- a/tests/testutils/artifactshare.py
+++ b/tests/testutils/artifactshare.py
@@ -13,7 +13,7 @@ import pytest_cov
from buildstream import _yaml
from buildstream._artifactcache.casserver import create_server
from buildstream._context import Context
-from buildstream._exceptions import ArtifactError
+from buildstream._exceptions import CASError
from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
@@ -48,7 +48,7 @@ class ArtifactShare():
context = Context()
context.artifactdir = self.repodir
- self.cas = context.artifactcache
+ self.cas = context.artifactcache.cas
self.total_space = total_space
self.free_space = free_space
@@ -135,7 +135,7 @@ class ArtifactShare():
try:
tree = self.cas.resolve_ref(artifact_key)
return True
- except ArtifactError:
+ except CASError:
return False
# close():