7661: added test with only_pdh (not working yet)
authorradhika <radhika@curoverse.com>
Tue, 10 Nov 2015 15:52:35 +0000 (10:52 -0500)
committerradhika <radhika@curoverse.com>
Tue, 10 Nov 2015 15:52:35 +0000 (10:52 -0500)
services/fuse/bin/arv-mount
services/fuse/tests/test_mount.py

index 81f8ca6cd03f707733f5f989e57761b292a5fa5d..d15553456a2238fcee7d32d926517ada43d05785 100755 (executable)
@@ -108,6 +108,7 @@ with "--".
         if args.by_id or args.by_pdh:
             # Set up the request handler with the 'magic directory' at the root
             dir_class = MagicDirectory
+            dir_args.append(args.by_pdh)
         elif args.by_tag:
             dir_class = TagsDirectory
         elif args.shared:
@@ -132,7 +133,7 @@ with "--".
             e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE, operations.inodes))
             dir_args[0] = e.inode
 
-            e._entries['by_id'] = operations.inodes.add_entry(MagicDirectory(*dir_args, pdh_only=True if args.by_pdh else False))
+            e._entries['by_id'] = operations.inodes.add_entry(MagicDirectory(*dir_args))
 
             e._entries['by_tag'] = operations.inodes.add_entry(TagsDirectory(*dir_args))
 
index ff8883714512c8a8f6b6a0196a19cb128204d317..b91b1410f281f0dd24b2acc584890afa8bd5dd49 100644 (file)
@@ -1060,3 +1060,50 @@ class FuseUnitTest(unittest.TestCase):
         self.assertEqual("_", fuse.sanitize_filename(""))
         self.assertEqual("_", fuse.sanitize_filename("."))
         self.assertEqual("__", fuse.sanitize_filename(".."))
+
+
+class FuseMagicTestPDHOnly(MountTestBase):
+    def setUp(self, api=None):
+        super(FuseMagicTestPDHOnly, self).setUp(api=api)
+
+        cw = arvados.CollectionWriter()
+
+        cw.start_new_file('thing1.txt')
+        cw.write("data 1")
+
+        self.testcollection = cw.finish()
+        self.test_manifest = cw.manifest_text()
+        created = self.api.collections().create(body={"manifest_text":self.test_manifest}).execute()
+        self.testcollectionuuid = str(created['uuid'])
+
+    def runTest(self):
+        self.make_mount(fuse.MagicDirectory, pdh_only=True)
+
+        mount_ls = llfuse.listdir(self.mounttmp)
+        self.assertIn('README', mount_ls)
+        self.assertFalse(any(arvados.util.keep_locator_pattern.match(fn) or
+                             arvados.util.uuid_pattern.match(fn)
+                             for fn in mount_ls),
+                         "new FUSE MagicDirectory lists Collection")
+
+        # look up using pdh should succeed
+        self.assertDirContents(self.testcollection, ['thing1.txt'])
+        self.assertDirContents(os.path.join('by_id', self.testcollection),
+                               ['thing1.txt'])
+        mount_ls = llfuse.listdir(self.mounttmp)
+        self.assertIn('README', mount_ls)
+        self.assertIn(self.testcollection, mount_ls)
+        self.assertIn(self.testcollection,
+                      llfuse.listdir(os.path.join(self.mounttmp, 'by_id')))
+
+        files = {}
+        files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1'
+
+        for k, v in files.items():
+            with open(os.path.join(self.mounttmp, k)) as f:
+                self.assertEqual(v, f.read())
+
+        # look up using uuid should fail
+        with self.assertRaises(OSError):
+            self.assertDirContents(os.path.join('by_id', self.testcollectionuuid),
+                               ['thing1.txt'])