diff options
-rw-r--r-- | buildstream/_artifactcache/artifactcache.py | 7 | ||||
-rw-r--r-- | buildstream/_artifactcache/cascache.py | 13 | ||||
-rw-r--r-- | buildstream/_artifactcache/casserver.py | 4 | ||||
-rw-r--r-- | buildstream/_context.py | 9 | ||||
-rw-r--r-- | buildstream/_frontend/app.py | 7 | ||||
-rw-r--r-- | buildstream/_loader/loader.py | 4 | ||||
-rw-r--r-- | buildstream/_platform/linux.py | 32 | ||||
-rw-r--r-- | buildstream/_platform/platform.py | 28 | ||||
-rw-r--r-- | buildstream/_platform/unix.py | 20 | ||||
-rw-r--r-- | buildstream/_scheduler/jobs/cachesizejob.py | 5 | ||||
-rw-r--r-- | buildstream/_scheduler/jobs/cleanupjob.py | 5 | ||||
-rw-r--r-- | buildstream/_scheduler/queues/buildqueue.py | 5 | ||||
-rw-r--r-- | buildstream/_scheduler/scheduler.py | 5 | ||||
-rw-r--r-- | buildstream/_stream.py | 4 | ||||
-rw-r--r-- | buildstream/element.py | 34 | ||||
-rw-r--r-- | buildstream/sandbox/_sandboxremote.py | 13 | ||||
-rw-r--r-- | buildstream/storage/_casbaseddirectory.py | 3 | ||||
-rw-r--r-- | tests/artifactcache/pull.py | 11 | ||||
-rw-r--r-- | tests/artifactcache/push.py | 11 | ||||
-rw-r--r-- | tests/testutils/artifactshare.py | 3 |
20 files changed, 124 insertions, 99 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index f4157c7ef..6a9b57f2c 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -383,6 +383,13 @@ class ArtifactCache(): # Abstract methods for subclasses to implement # ################################################ + # preflight(): + # + # Preflight check. + # + def preflight(self): + pass + # update_atime() # # Update the atime of an artifact. diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index 56c70ba9b..936cb780b 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -54,7 +54,6 @@ _MAX_PAYLOAD_BYTES = 1024 * 1024 # # Args: # context (Context): The BuildStream context -# enable_push (bool): Whether pushing is allowed by the platform # # Pushing is explicitly disabled by the platform in some cases, # like when we are falling back to functioning without using @@ -62,7 +61,7 @@ _MAX_PAYLOAD_BYTES = 1024 * 1024 # class CASCache(ArtifactCache): - def __init__(self, context, *, enable_push=True): + def __init__(self, context): super().__init__(context) self.casdir = os.path.join(context.artifactdir, 'cas') @@ -71,8 +70,6 @@ class CASCache(ArtifactCache): self._calculate_cache_quota() - self._enable_push = enable_push - # Per-project list of _CASRemote instances. self._remotes = {} @@ -83,6 +80,12 @@ class CASCache(ArtifactCache): # Implementation of abstract methods # ################################################ + def preflight(self): + if (not os.path.isdir(os.path.join(self.casdir, 'refs', 'heads')) or + not os.path.isdir(os.path.join(self.casdir, 'objects'))): + raise ArtifactError("CAS repository check failed for '{}'" + .format(self.casdir)) + def contains(self, element, key): refpath = self._refpath(self.get_artifact_fullname(element, key)) @@ -214,7 +217,7 @@ class CASCache(ArtifactCache): return bool(remotes_for_project) def has_push_remotes(self, *, element=None): - if not self._has_push_remotes or not self._enable_push: + if not self._has_push_remotes: # No project has push remotes return False elif element is None: diff --git a/buildstream/_artifactcache/casserver.py b/buildstream/_artifactcache/casserver.py index d833878d5..b51572755 100644 --- a/buildstream/_artifactcache/casserver.py +++ b/buildstream/_artifactcache/casserver.py @@ -35,8 +35,6 @@ from .._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc from .._exceptions import ArtifactError from .._context import Context -from .cascache import CASCache - # The default limit for gRPC messages is 4 MiB. # Limit payload to 1 MiB to leave sufficient headroom for metadata. @@ -60,7 +58,7 @@ def create_server(repo, *, enable_push): context = Context() context.artifactdir = os.path.abspath(repo) - artifactcache = CASCache(context) + artifactcache = context.artifactcache # Use max_workers default from Python 3.5+ max_workers = (os.cpu_count() or 1) * 5 diff --git a/buildstream/_context.py b/buildstream/_context.py index 8b8b01b17..cb29968a4 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -30,6 +30,7 @@ from ._exceptions import LoadError, LoadErrorReason, BstError from ._message import Message, MessageType from ._profile import Topics, profile_start, profile_end from ._artifactcache import ArtifactCache +from ._artifactcache.cascache import CASCache from ._workspaces import Workspaces from .plugin import _plugin_lookup @@ -113,6 +114,7 @@ class Context(): self._cache_key = None self._message_handler = None self._message_depth = deque() + self._artifactcache = None self._projects = [] self._project_overrides = {} self._workspaces = None @@ -227,6 +229,13 @@ class Context(): "{}: on-error should be one of: {}".format( provenance, ", ".join(valid_actions))) + @property + def artifactcache(self): + if not self._artifactcache: + self._artifactcache = CASCache(self) + + return self._artifactcache + # add_project(): # # Add a project to the context. diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index ccdbb2d5d..a1afee478 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -198,10 +198,15 @@ class App(): if option_value is not None: setattr(self.context, context_attr, option_value) try: - Platform.create_instance(self.context) + Platform.get_platform() except BstError as e: self._error_exit(e, "Error instantiating platform") + try: + self.context.artifactcache.preflight() + except BstError as e: + self._error_exit(e, "Error instantiating artifact cache") + # Create the logger right before setting the message handler self.logger = LogLine(self.context, self._content_profile, diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index 8553bc6dd..1b27d9d55 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -28,7 +28,6 @@ from .. import Consistency from .. import _yaml from ..element import Element from .._profile import Topics, profile_start, profile_end -from .._platform import Platform from .._includes import Includes from .types import Symbol, Dependency @@ -518,8 +517,7 @@ class Loader(): raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Expected junction but element kind is {}".format(filename, meta_element.kind)) - platform = Platform.get_platform() - element = Element._new_from_meta(meta_element, platform.artifactcache) + element = Element._new_from_meta(meta_element, self._context.artifactcache) element._preflight() sources = list(element.sources()) diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index a5fd0d687..7af1a2283 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -17,11 +17,11 @@ # Authors: # Tristan Maat <tristan.maat@codethink.co.uk> +import os import subprocess from .. import _site from .. import utils -from .._artifactcache.cascache import CASCache from .._message import Message, MessageType from ..sandbox import SandboxBwrap @@ -30,17 +30,15 @@ from . import Platform class Linux(Platform): - def __init__(self, context): + def __init__(self): - super().__init__(context) + super().__init__() - self._die_with_parent_available = _site.check_bwrap_version(0, 1, 8) - self._user_ns_available = self._check_user_ns_available(context) - self._artifact_cache = CASCache(context, enable_push=self._user_ns_available) + self._uid = os.geteuid() + self._gid = os.getegid() - @property - def artifactcache(self): - return self._artifact_cache + self._die_with_parent_available = _site.check_bwrap_version(0, 1, 8) + self._user_ns_available = self._check_user_ns_available() def create_sandbox(self, *args, **kwargs): # Inform the bubblewrap sandbox as to whether it can use user namespaces or not @@ -48,10 +46,19 @@ class Linux(Platform): kwargs['die_with_parent_available'] = self._die_with_parent_available return SandboxBwrap(*args, **kwargs) + def check_sandbox_config(self, config): + if self._user_ns_available: + # User namespace support allows arbitrary build UID/GID settings. + return True + else: + # Without user namespace support, the UID/GID in the sandbox + # will match the host UID/GID. + return config.build_uid == self._uid and config.build_gid == self._gid + ################################################ # Private Methods # ################################################ - def _check_user_ns_available(self, context): + def _check_user_ns_available(self): # Here, lets check if bwrap is able to create user namespaces, # issue a warning if it's not available, and save the state @@ -75,9 +82,4 @@ class Linux(Platform): return True else: - context.message( - Message(None, MessageType.WARN, - "Unable to create user namespaces with bubblewrap, resorting to fallback", - detail="Some builds may not function due to lack of uid / gid 0, " + - "artifacts created will not be trusted for push purposes.")) return False diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index 8a074eb62..b37964986 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -29,17 +29,13 @@ class Platform(): # Platform() # # A class to manage platform-specific details. Currently holds the - # sandbox factory, the artifact cache and staging operations, as - # well as platform helpers. + # sandbox factory as well as platform helpers. # - # Args: - # context (context): The project context - # - def __init__(self, context): - self.context = context + def __init__(self): + pass @classmethod - def create_instance(cls, *args, **kwargs): + def _create_instance(cls): if sys.platform.startswith('linux'): backend = 'linux' else: @@ -58,23 +54,15 @@ class Platform(): else: raise PlatformError("No such platform: '{}'".format(backend)) - cls._instance = PlatformImpl(*args, **kwargs) + cls._instance = PlatformImpl() @classmethod def get_platform(cls): if not cls._instance: - raise PlatformError("Platform needs to be initialized first") + cls._create_instance() return cls._instance ################################################################## - # Platform properties # - ################################################################## - @property - def artifactcache(self): - raise ImplError("Platform {platform} does not implement an artifactcache" - .format(platform=type(self).__name__)) - - ################################################################## # Sandbox functions # ################################################################## @@ -92,3 +80,7 @@ class Platform(): def create_sandbox(self, *args, **kwargs): raise ImplError("Platform {platform} does not implement create_sandbox()" .format(platform=type(self).__name__)) + + def check_sandbox_config(self, config): + raise ImplError("Platform {platform} does not implement check_sandbox_config()" + .format(platform=type(self).__name__)) diff --git a/buildstream/_platform/unix.py b/buildstream/_platform/unix.py index 0306a4ac5..7aa8cbc0d 100644 --- a/buildstream/_platform/unix.py +++ b/buildstream/_platform/unix.py @@ -19,7 +19,6 @@ import os -from .._artifactcache.cascache import CASCache from .._exceptions import PlatformError from ..sandbox import SandboxChroot @@ -28,18 +27,21 @@ from . import Platform class Unix(Platform): - def __init__(self, context): + def __init__(self): - super().__init__(context) - self._artifact_cache = CASCache(context) + super().__init__() + + self._uid = os.geteuid() + self._gid = os.getegid() # Not necessarily 100% reliable, but we want to fail early. - if os.geteuid() != 0: + if self._uid != 0: raise PlatformError("Root privileges are required to run without bubblewrap.") - @property - def artifactcache(self): - return self._artifact_cache - def create_sandbox(self, *args, **kwargs): return SandboxChroot(*args, **kwargs) + + def check_sandbox_config(self, config): + # With the chroot sandbox, the UID/GID in the sandbox + # will match the host UID/GID (typically 0/0). + return config.build_uid == self._uid and config.build_gid == self._gid diff --git a/buildstream/_scheduler/jobs/cachesizejob.py b/buildstream/_scheduler/jobs/cachesizejob.py index 68cd91331..d46fd4c16 100644 --- a/buildstream/_scheduler/jobs/cachesizejob.py +++ b/buildstream/_scheduler/jobs/cachesizejob.py @@ -17,7 +17,6 @@ # Tristan Daniël Maat <tristan.maat@codethink.co.uk> # from .job import Job -from ..._platform import Platform class CacheSizeJob(Job): @@ -25,8 +24,8 @@ class CacheSizeJob(Job): super().__init__(*args, **kwargs) self._complete_cb = complete_cb - platform = Platform.get_platform() - self._artifacts = platform.artifactcache + context = self._scheduler.context + self._artifacts = context.artifactcache def child_process(self): return self._artifacts.compute_cache_size() diff --git a/buildstream/_scheduler/jobs/cleanupjob.py b/buildstream/_scheduler/jobs/cleanupjob.py index 399435ad9..8bdbba0ed 100644 --- a/buildstream/_scheduler/jobs/cleanupjob.py +++ b/buildstream/_scheduler/jobs/cleanupjob.py @@ -17,15 +17,14 @@ # Tristan Daniël Maat <tristan.maat@codethink.co.uk> # from .job import Job -from ..._platform import Platform class CleanupJob(Job): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - platform = Platform.get_platform() - self._artifacts = platform.artifactcache + context = self._scheduler.context + self._artifacts = context.artifactcache def child_process(self): return self._artifacts.clean() diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py index 39ed83a32..984a5457a 100644 --- a/buildstream/_scheduler/queues/buildqueue.py +++ b/buildstream/_scheduler/queues/buildqueue.py @@ -24,7 +24,6 @@ from . import Queue, QueueStatus from ..jobs import ElementJob from ..resources import ResourceType from ..._message import MessageType -from ..._platform import Platform # A queue which assembles elements @@ -94,8 +93,8 @@ class BuildQueue(Queue): # as returned from Element._assemble() to the estimated # artifact cache size # - platform = Platform.get_platform() - artifacts = platform.artifactcache + context = self._scheduler.context + artifacts = context.artifactcache artifacts.add_artifact_size(artifact_size) diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py index 8faf58e65..090d490ba 100644 --- a/buildstream/_scheduler/scheduler.py +++ b/buildstream/_scheduler/scheduler.py @@ -29,7 +29,6 @@ from contextlib import contextmanager # Local imports from .resources import Resources, ResourceType from .jobs import CacheSizeJob, CleanupJob -from .._platform import Platform # A decent return code for Scheduler.run() @@ -348,8 +347,8 @@ class Scheduler(): # which will report the calculated cache size. # def _run_cleanup(self, cache_size): - platform = Platform.get_platform() - artifacts = platform.artifactcache + context = self.context + artifacts = context.artifactcache if not artifacts.has_quota_exceeded(): return diff --git a/buildstream/_stream.py b/buildstream/_stream.py index f4661cc2a..e7a71978b 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -32,7 +32,6 @@ from ._exceptions import StreamError, ImplError, BstError, set_last_task_error from ._message import Message, MessageType from ._scheduler import Scheduler, SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue from ._pipeline import Pipeline, PipelineSelection -from ._platform import Platform from . import utils, _yaml, _site from . import Scope, Consistency @@ -71,8 +70,7 @@ class Stream(): # # Private members # - self._platform = Platform.get_platform() - self._artifacts = self._platform.artifactcache + self._artifacts = context.artifactcache self._context = context self._project = project self._pipeline = Pipeline(context, project, self._artifacts) diff --git a/buildstream/element.py b/buildstream/element.py index 74deda384..320ba7a8a 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -246,15 +246,23 @@ class Element(Plugin): self.__config = self.__extract_config(meta) self._configure(self.__config) - # Extract Sandbox config - self.__sandbox_config = self.__extract_sandbox_config(meta) - # Extract remote execution URL if not self.__is_junction: self.__remote_execution_url = project.remote_execution_url else: self.__remote_execution_url = None + # Extract Sandbox config + self.__sandbox_config = self.__extract_sandbox_config(meta) + + self.__sandbox_config_supported = True + if not self.__use_remote_execution(): + platform = Platform.get_platform() + if not platform.check_sandbox_config(self.__sandbox_config): + # Local sandbox does not fully support specified sandbox config. + # This will taint the artifact, disable pushing. + self.__sandbox_config_supported = False + def __lt__(self, other): return self.name < other.name @@ -1521,6 +1529,11 @@ class Element(Plugin): context = self._get_context() with self._output_file() as output_file: + if not self.__sandbox_config_supported: + self.warn("Sandbox configuration is not supported by the platform.", + detail="Falling back to UID {} GID {}. Artifact will not be pushed." + .format(self.__sandbox_config.build_uid, self.__sandbox_config.build_gid)) + # Explicitly clean it up, keep the build dir around if exceptions are raised os.makedirs(context.builddir, exist_ok=True) rootdir = tempfile.mkdtemp(prefix="{}-".format(self.normal_name), dir=context.builddir) @@ -2110,10 +2123,19 @@ class Element(Plugin): workspaced_dependencies = self.__get_artifact_metadata_workspaced_dependencies() # Other conditions should be or-ed - self.__tainted = workspaced or workspaced_dependencies + self.__tainted = (workspaced or workspaced_dependencies or + not self.__sandbox_config_supported) return self.__tainted + # __use_remote_execution(): + # + # Returns True if remote execution is configured and the element plugin + # supports it. + # + def __use_remote_execution(self): + return self.__remote_execution_url and self.BST_VIRTUAL_DIRECTORY + # __sandbox(): # # A context manager to prepare a Sandbox object at the specified directory, @@ -2135,9 +2157,7 @@ class Element(Plugin): project = self._get_project() platform = Platform.get_platform() - if (directory is not None and - self.__remote_execution_url and - self.BST_VIRTUAL_DIRECTORY): + if directory is not None and self.__use_remote_execution(): self.info("Using a remote sandbox for artifact {} with directory '{}'".format(self.name, directory)) diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py index 6a49ec4bb..d934832bb 100644 --- a/buildstream/sandbox/_sandboxremote.py +++ b/buildstream/sandbox/_sandboxremote.py @@ -28,7 +28,6 @@ from ..storage._filebaseddirectory import FileBasedDirectory from ..storage._casbaseddirectory import CasBasedDirectory from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc from .._protos.google.rpc import code_pb2 -from .._platform import Platform class SandboxError(Exception): @@ -72,8 +71,8 @@ class SandboxRemote(Sandbox): output_files=[], output_directories=[self._output_directory], platform=None) - platform = Platform.get_platform() - cascache = platform.artifactcache + context = self._get_context() + cascache = context.artifactcache # Upload the Command message to the remote CAS server command_digest = cascache.push_message(self._get_project(), remote_command) if not command_digest or not cascache.verify_digest_pushed(self._get_project(), command_digest): @@ -135,8 +134,8 @@ class SandboxRemote(Sandbox): if tree_digest is None or not tree_digest.hash: raise SandboxError("Output directory structure had no digest attached.") - platform = Platform.get_platform() - cascache = platform.artifactcache + context = self._get_context() + cascache = context.artifactcache # Now do a pull to ensure we have the necessary parts. dir_digest = cascache.pull_tree(self._get_project(), tree_digest) if dir_digest is None or not dir_digest.hash or not dir_digest.size_bytes: @@ -171,8 +170,8 @@ class SandboxRemote(Sandbox): upload_vdir.recalculate_hash() - platform = Platform.get_platform() - cascache = platform.artifactcache + context = self._get_context() + cascache = context.artifactcache # Now, push that key (without necessarily needing a ref) to the remote. cascache.push_directory(self._get_project(), upload_vdir) if not cascache.verify_digest_pushed(self._get_project(), upload_vdir.ref): diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py index d580635c1..07fd206ed 100644 --- a/buildstream/storage/_casbaseddirectory.py +++ b/buildstream/storage/_casbaseddirectory.py @@ -38,7 +38,6 @@ from .._exceptions import BstError from .directory import Directory, VirtualDirectoryError from ._filebaseddirectory import FileBasedDirectory from ..utils import FileListResult, safe_copy, list_relative_paths -from .._artifactcache.cascache import CASCache class IndexEntry(): @@ -80,7 +79,7 @@ class CasBasedDirectory(Directory): self.filename = filename self.common_name = common_name self.pb2_directory = remote_execution_pb2.Directory() - self.cas_cache = CASCache(context) + self.cas_cache = context.artifactcache if ref: with open(self.cas_cache.objpath(ref), 'rb') as f: self.pb2_directory.ParseFromString(f.read()) diff --git a/tests/artifactcache/pull.py b/tests/artifactcache/pull.py index 45560aabf..e76dc5ca7 100644 --- a/tests/artifactcache/pull.py +++ b/tests/artifactcache/pull.py @@ -6,7 +6,6 @@ import signal import pytest from buildstream import _yaml, _signals, utils -from buildstream._artifactcache.cascache import CASCache from buildstream._context import Context from buildstream._project import Project from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 @@ -88,7 +87,7 @@ def test_pull(cli, tmpdir, datafiles): # Load the project and CAS cache project = Project(project_dir, context) project.ensure_fully_loaded() - cas = CASCache(context) + cas = context.artifactcache # Assert that the element's artifact is **not** cached element = project.load_elements(['target.bst'], cas)[0] @@ -130,7 +129,7 @@ def _test_pull(user_config_file, project_dir, artifact_dir, project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Load the target element element = project.load_elements([element_name], cas)[0] @@ -191,7 +190,7 @@ def test_pull_tree(cli, tmpdir, datafiles): # Load the project and CAS cache project = Project(project_dir, context) project.ensure_fully_loaded() - cas = CASCache(context) + cas = context.artifactcache # Assert that the element's artifact is cached element = project.load_elements(['target.bst'], cas)[0] @@ -269,7 +268,7 @@ def _test_push_tree(user_config_file, project_dir, artifact_dir, artifact_digest project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Manually setup the CAS remote cas.setup_remotes(use_config=True) @@ -304,7 +303,7 @@ def _test_pull_tree(user_config_file, project_dir, artifact_dir, artifact_digest project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Manually setup the CAS remote cas.setup_remotes(use_config=True) diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py index faf6a6980..c95aac3ef 100644 --- a/tests/artifactcache/push.py +++ b/tests/artifactcache/push.py @@ -6,7 +6,6 @@ import pytest from pluginbase import PluginBase from buildstream import _yaml, _signals, utils -from buildstream._artifactcache.cascache import CASCache from buildstream._context import Context from buildstream._project import Project from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 @@ -67,7 +66,7 @@ def test_push(cli, tmpdir, datafiles): project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Assert that the element's artifact is cached element = project.load_elements(['target.bst'], cas)[0] @@ -109,7 +108,7 @@ def _test_push(user_config_file, project_dir, artifact_dir, project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Load the target element element = project.load_elements([element_name], cas)[0] @@ -166,7 +165,7 @@ def test_push_directory(cli, tmpdir, datafiles): # Load the project and CAS cache project = Project(project_dir, context) project.ensure_fully_loaded() - cas = CASCache(context) + cas = context.artifactcache # Assert that the element's artifact is cached element = project.load_elements(['target.bst'], cas)[0] @@ -217,7 +216,7 @@ def _test_push_directory(user_config_file, project_dir, artifact_dir, artifact_d project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Manually setup the CAS remote cas.setup_remotes(use_config=True) @@ -292,7 +291,7 @@ def _test_push_message(user_config_file, project_dir, artifact_dir, queue): project.ensure_fully_loaded() # Create a local CAS cache handle - cas = CASCache(context) + cas = context.artifactcache # Manually setup the CAS remote cas.setup_remotes(use_config=True) diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py index e3f709b0a..d95667227 100644 --- a/tests/testutils/artifactshare.py +++ b/tests/testutils/artifactshare.py @@ -11,7 +11,6 @@ from multiprocessing import Process, Queue import pytest_cov from buildstream import _yaml -from buildstream._artifactcache.cascache import CASCache from buildstream._artifactcache.casserver import create_server from buildstream._context import Context from buildstream._exceptions import ArtifactError @@ -49,7 +48,7 @@ class ArtifactShare(): context = Context() context.artifactdir = self.repodir - self.cas = CASCache(context) + self.cas = context.artifactcache self.total_space = total_space self.free_space = free_space |