X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a9b9c6ff05e0268570b829bd62a6f683cf9f1d19..32030bce1b67218c91a8ed2a0287ec973221c5f7:/services/fuse/tests/test_mount.py diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py index 82e5c441eb..ece316193d 100644 --- a/services/fuse/tests/test_mount.py +++ b/services/fuse/tests/test_mount.py @@ -15,6 +15,7 @@ import os import subprocess import time import unittest +import tempfile import arvados import arvados_fuse as fuse @@ -788,10 +789,15 @@ class FuseDeleteProjectEventTest(MountTestBase): attempt(self.assertEqual, [], llfuse.listdir(os.path.join(self.mounttmp, "aproject"))) -def fuseFileConflictTestHelper(mounttmp): +def fuseFileConflictTestHelper(mounttmp, uuid, keeptmp, settings): class Test(unittest.TestCase): def runTest(self): + os.environ['KEEP_LOCAL_STORE'] = keeptmp + with open(os.path.join(mounttmp, "file1.txt"), "w") as f: + with arvados.collection.Collection(uuid, api_client=arvados.api_from_config('v1', apiconfig=settings)) as collection2: + with collection2.open("file1.txt", "w") as f2: + f2.write("foo") f.write("bar") d1 = sorted(llfuse.listdir(os.path.join(mounttmp))) @@ -820,12 +826,8 @@ class FuseFileConflictTest(MountTestBase): d1 = llfuse.listdir(os.path.join(self.mounttmp)) self.assertEqual([], sorted(d1)) - with arvados.collection.Collection(collection.manifest_locator(), api_client=self.api) as collection2: - with collection2.open("file1.txt", "w") as f: - f.write("foo") - # See note in MountTestBase.setUp - self.pool.apply(fuseFileConflictTestHelper, (self.mounttmp,)) + self.pool.apply(fuseFileConflictTestHelper, (self.mounttmp, collection.manifest_locator(), self.keeptmp, arvados.config.settings())) def fuseUnlinkOpenFileTest(mounttmp): @@ -1111,7 +1113,7 @@ class MagicDirApiError(FuseMagicTest): class SanitizeFilenameTest(MountTestBase): def test_sanitize_filename(self): - pdir = fuse.ProjectDirectory(1, {}, self.api, 0, project_object=self.api.users().current().execute()) + pdir = fuse.ProjectDirectory(1, {}, self.api, 0, False, project_object=self.api.users().current().execute()) acceptable = [ "foo.txt", ".foo", @@ -1291,3 +1293,25 @@ class StorageClassesTest(IntegrationTest): @staticmethod def _test_collection_custom_storage_classes(self, coll): self.assertEqual(storage_classes_desired(coll), ['foo']) + +def _readonlyCollectionTestHelper(mounttmp): + f = open(os.path.join(mounttmp, 'thing1.txt'), 'rt') + # Testing that close() doesn't raise an error. + f.close() + +class ReadonlyCollectionTest(MountTestBase): + def setUp(self): + super(ReadonlyCollectionTest, self).setUp() + cw = arvados.collection.Collection() + with cw.open('thing1.txt', 'wt') as f: + f.write("data 1") + cw.save_new(owner_uuid=run_test_server.fixture("groups")["aproject"]["uuid"]) + self.testcollection = cw.api_response() + + def runTest(self): + settings = arvados.config.settings().copy() + settings["ARVADOS_API_TOKEN"] = run_test_server.fixture("api_client_authorizations")["project_viewer"]["api_token"] + self.api = arvados.safeapi.ThreadSafeApiCache(settings) + self.make_mount(fuse.CollectionDirectory, collection_record=self.testcollection, enable_write=False) + + self.pool.apply(_readonlyCollectionTestHelper, (self.mounttmp,))