Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: client/run_isolated.py

Issue 2853413002: Add unit test to clean_caches() (Closed)
Patch Set: os.path.relpath Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/named_cache.py ('k') | client/tests/isolateserver_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/run_isolated.py
diff --git a/client/run_isolated.py b/client/run_isolated.py
index 72dcfff85af9dffeccf53253580f691fb3d8082d..ff4397fe2e3277933db8265bf4464f868d720dcc 100755
--- a/client/run_isolated.py
+++ b/client/run_isolated.py
@@ -824,8 +824,13 @@ def install_client_and_packages(
def clean_caches(options, isolate_cache, named_cache_manager):
- """Trims isolated and named caches."""
- # Which cache to trim first? Which of caches was used least recently?
+ """Trims isolated and named caches.
+
+ The goal here is to coherently trim both caches, deleting older items
+ independent of which container they belong to.
+ """
+ # TODO(maruel): Trim CIPD cache the same way.
+ total = 0
with named_cache_manager.open():
oldest_isolated = isolate_cache.get_oldest()
oldest_named = named_cache_manager.get_oldest()
@@ -840,9 +845,13 @@ def clean_caches(options, isolate_cache, named_cache_manager):
),
]
trimmers.sort(key=lambda (_, ts): ts)
+ # TODO(maruel): This is incorrect, we want to trim 'items' that are strictly
+ # the oldest independent of in which cache they live in. Right now, the
+ # cache with the oldest item pays the price.
for trim, _ in trimmers:
- trim()
+ total += trim()
isolate_cache.cleanup()
+ return total
def create_option_parser():
« no previous file with comments | « client/named_cache.py ('k') | client/tests/isolateserver_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698