diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-11-16 15:25:12 +0100 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-11-28 15:29:52 +0100 |
commit | 353b90dda760f320ec5b97c0bb56dce2ed7ea68f (patch) | |
tree | 48d34cce0a7da082cb1aa1ca9061413046a15503 /tests | |
parent | a64f667db8cc8123b7a77c9871143fbe8d008aaf (diff) | |
download | buildstream-353b90dda760f320ec5b97c0bb56dce2ed7ea68f.tar.gz |
Cleanup cache in cas server more agressively
When there is less than 2GB left, it cleans up have 10GB available.
These values are configurable.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/push.py | 4 | ||||
-rw-r--r-- | tests/testutils/artifactshare.py | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/frontend/push.py b/tests/frontend/push.py index f2d6814d6..153d43340 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -230,6 +230,8 @@ def test_artifact_expires(cli, datafiles, tmpdir): # Create an artifact share (remote artifact cache) in the tmpdir/artifactshare # Mock a file system with 12 MB free disk space with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'), + min_head_size=int(2e9), + max_head_size=int(2e9), total_space=int(10e9), free_space=(int(12e6) + int(2e9))) as share: # Configure bst to push to the cache @@ -313,6 +315,8 @@ def test_recently_pulled_artifact_does_not_expire(cli, datafiles, tmpdir): # Create an artifact share (remote cache) in tmpdir/artifactshare # Mock a file system with 12 MB free disk space with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'), + min_head_size=int(2e9), + max_head_size=int(2e9), total_space=int(10e9), free_space=(int(12e6) + int(2e9))) as share: # Configure bst to push to the cache diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py index c1ddc2c46..38c54a947 100644 --- a/tests/testutils/artifactshare.py +++ b/tests/testutils/artifactshare.py @@ -29,7 +29,11 @@ from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution # class ArtifactShare(): - def __init__(self, directory, *, total_space=None, free_space=None): + def __init__(self, directory, *, + total_space=None, + free_space=None, + min_head_size=int(2e9), + max_head_size=int(10e9)): # The working directory for the artifact share (in case it # needs to do something outside of its backend's storage folder). @@ -50,6 +54,9 @@ class ArtifactShare(): self.total_space = total_space self.free_space = free_space + self.max_head_size = max_head_size + self.min_head_size = min_head_size + q = Queue() self.process = Process(target=self.run, args=(q,)) @@ -74,7 +81,10 @@ class ArtifactShare(): self.free_space = self.total_space os.statvfs = self._mock_statvfs - server = create_server(self.repodir, enable_push=True) + server = create_server(self.repodir, + max_head_size=self.max_head_size, + min_head_size=self.min_head_size, + enable_push=True) port = server.add_insecure_port('localhost:0') server.start() @@ -176,8 +186,11 @@ class ArtifactShare(): # Create an ArtifactShare for use in a test case # @contextmanager -def create_artifact_share(directory, *, total_space=None, free_space=None): - share = ArtifactShare(directory, total_space=total_space, free_space=free_space) +def create_artifact_share(directory, *, total_space=None, free_space=None, + min_head_size=int(2e9), + max_head_size=int(10e9)): + share = ArtifactShare(directory, total_space=total_space, free_space=free_space, + min_head_size=min_head_size, max_head_size=max_head_size) try: yield share finally: |