You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2021/10/25 13:49:13 UTC

[buildstream] 01/01: testing: Use integration cache only for sources

This is an automated email from the ASF dual-hosted git repository.

juergbi pushed a commit to branch juerg/integration-cache
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 1fb916fe64eb609d62c290933fb15269709ca4c9
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Mon Oct 25 08:03:01 2021 +0200

    testing: Use integration cache only for sources
    
    The main purpose of the integration cache is to avoid redownloading
    sources. Keeping the complete CAS cache across the whole test session
    can result in excessive disk usage, breaking CI on shared runners.
    
    	FAILURE Cache too full
    
    This restricts the integration cache to sources and uses the per-test
    temp directory for the CAS cache, same as for non-integration tests.
---
 src/buildstream/testing/integration.py | 22 +---------------------
 src/buildstream/testing/runcli.py      | 14 ++------------
 2 files changed, 3 insertions(+), 33 deletions(-)

diff --git a/src/buildstream/testing/integration.py b/src/buildstream/testing/integration.py
index 269b3d3..fbef08f 100644
--- a/src/buildstream/testing/integration.py
+++ b/src/buildstream/testing/integration.py
@@ -78,15 +78,6 @@ class IntegrationCache:
         # Use the same sources every time
         self.sources = os.path.join(self.root, "sources")
 
-        # Create a temp directory for the duration of the test for
-        # the artifacts directory
-        try:
-            self.cachedir = tempfile.mkdtemp(dir=self.root, prefix="cache-")
-            # Apply mode allowed by umask
-            os.chmod(self.cachedir, 0o777 & ~utils.get_umask())
-        except OSError as e:
-            raise AssertionError("Unable to create test directory !") from e
-
 
 @pytest.fixture(scope="session")
 def integration_cache(request):
@@ -99,15 +90,4 @@ def integration_cache(request):
 
     cache = IntegrationCache(cache_dir)
 
-    yield cache
-
-    # Clean up the artifacts after each test session - we only want to
-    # cache sources between tests
-    try:
-        shutil.rmtree(cache.cachedir)
-    except FileNotFoundError:
-        pass
-    try:
-        shutil.rmtree(os.path.join(cache.root, "cas"))
-    except FileNotFoundError:
-        pass
+    return cache
diff --git a/src/buildstream/testing/runcli.py b/src/buildstream/testing/runcli.py
index 088c2a8..9dc2b4c 100644
--- a/src/buildstream/testing/runcli.py
+++ b/src/buildstream/testing/runcli.py
@@ -753,20 +753,10 @@ def cli_integration(tmpdir, integration_cache):
     # We want to cache sources for integration tests more permanently,
     # to avoid downloading the huge base-sdk repeatedly
     fixture.configure(
-        {"cachedir": integration_cache.cachedir, "sourcedir": integration_cache.sources,}
+        {"sourcedir": integration_cache.sources,}
     )
 
-    yield fixture
-
-    # remove following folders if necessary
-    try:
-        shutil.rmtree(os.path.join(integration_cache.cachedir, "build"))
-    except FileNotFoundError:
-        pass
-    try:
-        shutil.rmtree(os.path.join(integration_cache.cachedir, "tmp"))
-    except FileNotFoundError:
-        pass
+    return fixture
 
 
 # A variant of the main fixture that is configured for remote-execution.