[ARVADOS] updated: 184dabe069040d4ab210407de695563400da781e

git at public.curoverse.com git at public.curoverse.com
Mon May 11 11:15:00 EDT 2015


Summary of changes:
 services/fuse/arvados_fuse/__init__.py |  4 +-
 services/fuse/arvados_fuse/fusedir.py  |  3 ++
 services/fuse/tests/test_inodes.py     | 71 +++++++++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 7 deletions(-)

       via  184dabe069040d4ab210407de695563400da781e (commit)
      from  0c01dc225cf57ec886b952440abd0764a85c7a67 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 184dabe069040d4ab210407de695563400da781e
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon May 11 11:14:56 2015 -0400

    3198: Fix Operation(inode_cache) init.  Break up tests into a few smaller
    tests.  Added comment about how collection size is calculated.

diff --git a/services/fuse/arvados_fuse/__init__.py b/services/fuse/arvados_fuse/__init__.py
index 2387c69..8d04848 100644
--- a/services/fuse/arvados_fuse/__init__.py
+++ b/services/fuse/arvados_fuse/__init__.py
@@ -156,9 +156,11 @@ class Operations(llfuse.Operations):
 
     """
 
-    def __init__(self, uid, gid, encoding="utf-8", inode_cache=InodeCache(cap=256*1024*1024)):
+    def __init__(self, uid, gid, encoding="utf-8", inode_cache=None):
         super(Operations, self).__init__()
 
+        if not inode_cache:
+            inode_cache = InodeCache(cap=256*1024*1024)
         self.inodes = Inodes(inode_cache)
         self.uid = uid
         self.gid = gid
diff --git a/services/fuse/arvados_fuse/fusedir.py b/services/fuse/arvados_fuse/fusedir.py
index 77e8dde..2757091 100644
--- a/services/fuse/arvados_fuse/fusedir.py
+++ b/services/fuse/arvados_fuse/fusedir.py
@@ -286,6 +286,9 @@ class CollectionDirectory(Directory):
         return (self.collection_locator is not None)
 
     def objsize(self):
+        # This is an empirically-derived heuristic to estimate the memory used
+        # to store this collection's metadata.  Calculating the memory
+        # footprint directly would be more accurate, but also more complicated.
         return self._manifest_size * 128
 
 class MagicDirectory(Directory):
diff --git a/services/fuse/tests/test_inodes.py b/services/fuse/tests/test_inodes.py
index 82bb716..61a365f 100644
--- a/services/fuse/tests/test_inodes.py
+++ b/services/fuse/tests/test_inodes.py
@@ -3,13 +3,13 @@ import mock
 import unittest
 
 class InodeTests(unittest.TestCase):
-    def test_inodes(self):
+    def test_inodes_basic(self):
         cache = arvados_fuse.InodeCache(1000, 4)
         inodes = arvados_fuse.Inodes(cache)
 
         # Check that ent1 gets added to inodes
         ent1 = mock.MagicMock()
-        ent1.return_value.in_use = False
+        ent1.in_use.return_value = False
         ent1.persisted.return_value = True
         ent1.clear.return_value = True
         ent1.objsize.return_value = 500
@@ -18,18 +18,41 @@ class InodeTests(unittest.TestCase):
         self.assertIs(inodes[ent1.inode], ent1)
         self.assertEqual(500, cache.total())
 
+    def test_inodes_not_persisted(self):
+        cache = arvados_fuse.InodeCache(1000, 4)
+        inodes = arvados_fuse.Inodes(cache)
+
+        ent1 = mock.MagicMock()
+        ent1.in_use.return_value = False
+        ent1.persisted.return_value = True
+        ent1.clear.return_value = True
+        ent1.objsize.return_value = 500
+        inodes.add_entry(ent1)
+
         # ent2 is not persisted, so it doesn't
         # affect the cache total
         ent2 = mock.MagicMock()
-        ent2.return_value.in_use = False
+        ent2.in_use.return_value = False
         ent2.persisted.return_value = False
         ent2.objsize.return_value = 600
         inodes.add_entry(ent2)
         self.assertEqual(500, cache.total())
 
+    def test_inode_cleared(self):
+        cache = arvados_fuse.InodeCache(1000, 4)
+        inodes = arvados_fuse.Inodes(cache)
+
+        # Check that ent1 gets added to inodes
+        ent1 = mock.MagicMock()
+        ent1.in_use.return_value = False
+        ent1.persisted.return_value = True
+        ent1.clear.return_value = True
+        ent1.objsize.return_value = 500
+        inodes.add_entry(ent1)
+
         # ent3 is persisted, adding it should cause ent1 to get cleared
         ent3 = mock.MagicMock()
-        ent3.return_value.in_use = False
+        ent3.in_use.return_value = False
         ent3.persisted.return_value = True
         ent3.objsize.return_value = 600
         ent3.clear.return_value = True
@@ -54,6 +77,26 @@ class InodeTests(unittest.TestCase):
         self.assertTrue(ent3.clear.called)
         self.assertEqual(500, cache.total())
 
+    def test_clear_false(self):
+        cache = arvados_fuse.InodeCache(1000, 4)
+        inodes = arvados_fuse.Inodes(cache)
+
+        ent1 = mock.MagicMock()
+        ent1.in_use.return_value = False
+        ent1.persisted.return_value = True
+        ent1.clear.return_value = True
+        ent1.objsize.return_value = 500
+        inodes.add_entry(ent1)
+
+        ent3 = mock.MagicMock()
+        ent3.in_use.return_value = False
+        ent3.persisted.return_value = True
+        ent3.objsize.return_value = 600
+        ent3.clear.return_value = True
+        inodes.add_entry(ent3)
+
+        cache.min_entries = 1
+
         # ent1, ent3 clear return false, can't be cleared
         ent1.clear.return_value = False
         ent3.clear.return_value = False
@@ -72,14 +115,30 @@ class InodeTests(unittest.TestCase):
         ent3.clear.return_value = True
         ent1.clear.called = False
         ent3.clear.called = False
-        self.assertFalse(ent1.clear.called)
-        self.assertFalse(ent3.clear.called)
         cache.touch(ent3)
         self.assertTrue(ent1.clear.called)
         self.assertTrue(ent3.clear.called)
         self.assertEqual(500, cache.total())
 
+    def test_delete(self):
+        cache = arvados_fuse.InodeCache(1000, 4)
+        inodes = arvados_fuse.Inodes(cache)
+
+        ent1 = mock.MagicMock()
+        ent1.in_use.return_value = False
+        ent1.persisted.return_value = True
+        ent1.clear.return_value = True
+        ent1.objsize.return_value = 500
+        inodes.add_entry(ent1)
+
+        ent3 = mock.MagicMock()
+        ent3.in_use.return_value = False
+        ent3.persisted.return_value = True
+        ent3.objsize.return_value = 600
+        ent3.clear.return_value = True
+
         # Delete ent1
+        self.assertEqual(500, cache.total())
         ent1.clear.return_value = True
         inodes.del_entry(ent1)
         self.assertEqual(0, cache.total())

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list