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

Unified Diff: client/tests/isolateserver_test.py

Issue 2610273002: Make isolate cache resilient to unexpectedly deleted items. (Closed)
Patch Set: Created 3 years, 11 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/isolateserver.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/isolateserver_test.py
diff --git a/client/tests/isolateserver_test.py b/client/tests/isolateserver_test.py
index d17848833879af07121b8fb6d8b8aceeec005435..e4799a4d5904a32d85e80e65588ce95ae7bd01de 100755
--- a/client/tests/isolateserver_test.py
+++ b/client/tests/isolateserver_test.py
@@ -6,7 +6,6 @@
# pylint: disable=W0212,W0223,W0231,W0613
import base64
-import collections
import hashlib
import json
import logging
@@ -17,7 +16,6 @@ import sys
import tarfile
import tempfile
import unittest
-import urllib
import zlib
# net_utils adjusts sys.path.
@@ -28,7 +26,6 @@ import isolated_format
import isolateserver
import isolate_storage
import test_utils
-from depot_tools import auto_stub
from depot_tools import fix_encoding
from utils import file_path
from utils import fs
@@ -1446,6 +1443,27 @@ class DiskCacheTest(TestCase):
self.assertEqual(2, cache.initial_number_items)
self.assertEqual(100, cache.initial_size)
+ def test_some_file_brutally_deleted(self):
+ h_a = self.to_hash('a')[0]
+
+ self._free_disk = 1100
+ with self.get_cache() as cache:
+ cache.write(h_a, 'a')
+ self.assertTrue(cache.touch(h_a, isolateserver.UNKNOWN_FILE_SIZE))
+ self.assertTrue(cache.touch(h_a, 1))
+
+ os.remove(os.path.join(self.tempdir, h_a))
+
+ with self.get_cache() as cache:
+ # 'Ghost' entry loaded with state.json is still there.
+ self.assertEqual({h_a}, cache.cached_set())
+ # 'touch' detects the file is missing by returning False.
+ self.assertFalse(cache.touch(h_a, isolateserver.UNKNOWN_FILE_SIZE))
+ self.assertFalse(cache.touch(h_a, 1))
+ # Evicting it still works, kills the 'ghost' entry.
+ cache.evict(h_a)
+ self.assertEqual(set(), cache.cached_set())
+
def clear_env_vars():
for e in ('ISOLATE_DEBUG', 'ISOLATE_SERVER'):
« no previous file with comments | « client/isolateserver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698