summaryrefslogtreecommitdiff
path: root/tests/sources
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-11-28 10:59:52 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2020-01-16 16:33:19 +0000
commit3be6d07753599ef54b9e80ac066571632e217ce2 (patch)
treee14db9bba2d32ddb2840ab5513afde5b1ece2055 /tests/sources
parent4a47af24fca8aeb6c0c0fe6bd754712ecce5211d (diff)
downloadbuildstream-3be6d07753599ef54b9e80ac066571632e217ce2.tar.gz
source.py: Remove the reliance on consistency to get whether a source is cached
This removes the need to use consistency in Sources, by asking explicitely whether the source is cached or not. This introduces a new public method on source: `is_cached` that needs implementation and that should return whether the source has a local copy or not. - On fetch, also reset whether the source was cached or set if as cached when we know it was. - Validate the cache's source after fetching it This doesn't need to be run in the scheduler's process and can be offloaded to the child, which will allow better multiprocessing
Diffstat (limited to 'tests/sources')
-rw-r--r--tests/sources/no-fetch-cached/plugins/sources/always_cached.py3
-rw-r--r--tests/sources/previous_source_access/plugins/sources/foo_transform.py3
-rw-r--r--tests/sources/project_key_test/plugins/sources/key-test.py3
3 files changed, 9 insertions, 0 deletions
diff --git a/tests/sources/no-fetch-cached/plugins/sources/always_cached.py b/tests/sources/no-fetch-cached/plugins/sources/always_cached.py
index 5f05b592b..6267a99eb 100644
--- a/tests/sources/no-fetch-cached/plugins/sources/always_cached.py
+++ b/tests/sources/no-fetch-cached/plugins/sources/always_cached.py
@@ -23,6 +23,9 @@ class AlwaysCachedSource(Source):
def is_resolved(self):
return True
+ def is_cached(self):
+ return True
+
def get_consistency(self):
return Consistency.CACHED
diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
index 906a8f6be..c59c81e63 100644
--- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py
+++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
@@ -39,6 +39,9 @@ class FooTransformSource(Source):
def get_unique_key(self):
return (self.ref,)
+ def is_cached(self):
+ return self.get_consistency() == Consistency.CACHED
+
def get_consistency(self):
if self.ref is None:
return Consistency.INCONSISTENT
diff --git a/tests/sources/project_key_test/plugins/sources/key-test.py b/tests/sources/project_key_test/plugins/sources/key-test.py
index 30256929c..98dd380ef 100644
--- a/tests/sources/project_key_test/plugins/sources/key-test.py
+++ b/tests/sources/project_key_test/plugins/sources/key-test.py
@@ -20,6 +20,9 @@ class KeyTest(Source):
assert self.ref
return "abcdefg"
+ def is_cached(self):
+ return False
+
def get_consistency(self):
if self.ref:
return Consistency.RESOLVED