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

Unified Diff: chrome/common/extensions/docs/server2/caching_file_system_test.py

Issue 660383002: Docserver: Persist stat cache for versioned file systems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
Index: chrome/common/extensions/docs/server2/caching_file_system_test.py
diff --git a/chrome/common/extensions/docs/server2/caching_file_system_test.py b/chrome/common/extensions/docs/server2/caching_file_system_test.py
index f80ac8c70f7875d83c3a91c452e0c1762d87b016..45ce024c84aeafb450c77e57707d82ba3520b09d 100755
--- a/chrome/common/extensions/docs/server2/caching_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/caching_file_system_test.py
@@ -292,5 +292,26 @@ class CachingFileSystemTest(unittest.TestCase):
# TODO(ahernandez): Test with a new instance CachingFileSystem so a
# different object store is utilized.
+ def testVersionedStat(self):
+ test_fs = TestFileSystem({
+ 'bob': {
+ 'bob0': 'bob/bob0 contents',
+ 'bob1': 'bob/bob1 contents'
+ }
+ })
+
+ # Create a versioned FileSystem and verify that multiple CachingFileSystem
+ # instances wrapping it will share the same stat cache.
+ mock_fs = MockFileSystem(test_fs)
+ mock_fs.SetVersion('abcdefg')
+
+ def run_and_expect_stat_count(paths, stat_count=0):
+ file_system = self._CreateCachingFileSystem(mock_fs, start_empty=True)
+ [file_system.Stat(path) for path in paths]
+ self.assertTrue(*mock_fs.CheckAndReset(stat_count=stat_count))
+
+ run_and_expect_stat_count(['bob/', 'bob/bob0', 'bob/bob1'], stat_count=1)
+ run_and_expect_stat_count(['bob/', 'bob/bob0', 'bob/bob1'], stat_count=0)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « chrome/common/extensions/docs/server2/caching_file_system.py ('k') | chrome/common/extensions/docs/server2/commit_tracker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698