X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ba8df2612ce43c906f181721695644ead5355e93..8dedd02357a95a0ae2c7961c8f1d0896b6311b3b:/services/fuse/tests/test_mount.py diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py index 2d775c0608..f5f61baeb3 100644 --- a/services/fuse/tests/test_mount.py +++ b/services/fuse/tests/test_mount.py @@ -2,12 +2,6 @@ # # SPDX-License-Identifier: AGPL-3.0 -from __future__ import absolute_import -from future.utils import viewitems -from builtins import str -from builtins import object -from pathlib import Path -from six import assertRegex import errno import json import llfuse @@ -17,22 +11,23 @@ import subprocess import time import unittest import tempfile -import parameterized +from pathlib import Path from unittest import mock import arvados import arvados_fuse as fuse +import parameterized + from arvados_fuse import fusedir -from . import run_test_server +from . import run_test_server from .integration_test import IntegrationTest from .mount_test_base import MountTestBase from .test_tmp_collection import storage_classes_desired logger = logging.getLogger('arvados.arv-mount') - class AssertWithTimeout(object): """Allow some time for an assertion to pass.""" @@ -125,7 +120,7 @@ class FuseMountTest(MountTestBase): 'dir2/dir3/thing7.txt': 'data 7', 'dir2/dir3/thing8.txt': 'data 8'} - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode()) @@ -190,7 +185,7 @@ class FuseMagicTest(MountTestBase): files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode()) @@ -313,7 +308,7 @@ class FuseHomeTest(MountTestBase): 'anonymously_accessible_project'] found_in = 0 found_not_in = 0 - for name, item in viewitems(run_test_server.fixture('collections')): + for name, item in run_test_server.fixture('collections').items(): if 'name' not in item: pass elif item['owner_uuid'] == public_project['uuid']: @@ -452,7 +447,7 @@ class FuseCreateFileTest(MountTestBase): self.assertEqual(["file1.txt"], d1) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:file1\.txt$') @@ -495,7 +490,7 @@ class FuseWriteFileTest(MountTestBase): self.assertEqual(12, self.operations.read_counter.get()) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -534,7 +529,7 @@ class FuseUpdateFileTest(MountTestBase): self.pool.apply(fuseUpdateFileTestHelper, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. daaef200ebb921e011e3ae922dd3266b\+11\+A\S+ 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:11:file1\.txt 22:1:file1\.txt$') @@ -574,7 +569,7 @@ class FuseMkdirTest(MountTestBase): self.pool.apply(fuseMkdirTestHelper, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -641,13 +636,13 @@ class FuseRmTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') self.pool.apply(fuseRmTestHelperDeleteFile, (self.mounttmp,)) # Empty directories are represented by an empty file named "." collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'./testdir d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:\\056\n') self.pool.apply(fuseRmTestHelperRmdir, (self.mounttmp,)) @@ -698,13 +693,13 @@ class FuseMvFileTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') self.pool.apply(fuseMvFileTestHelperMoveFile, (self.mounttmp,)) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt\n\./testdir d41d8cd98f00b204e9800998ecf8427e\+0\+A\S+ 0:0:\\056\n') @@ -732,7 +727,7 @@ class FuseRenameTest(MountTestBase): # Starting manifest collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') d1 = llfuse.listdir(os.path.join(self.mounttmp)) @@ -748,7 +743,7 @@ class FuseRenameTest(MountTestBase): self.assertEqual(["file1.txt"], d1) collection2 = self.api.collections().get(uuid=collection.manifest_locator()).execute() - assertRegex(self, collection2["manifest_text"], + self.assertRegex(collection2["manifest_text"], r'\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$') @@ -819,7 +814,7 @@ def fuseFileConflictTestHelper(mounttmp, uuid, keeptmp, settings): with open(os.path.join(mounttmp, "file1.txt"), "r") as f: self.assertEqual(f.read(), "bar") - assertRegex(self, d1[1], + self.assertRegex(d1[1], r'file1\.txt~\d\d\d\d\d\d\d\d-\d\d\d\d\d\d~conflict~') with open(os.path.join(mounttmp, d1[1]), "r") as f: @@ -924,7 +919,7 @@ class FuseMvFileBetweenCollectionsTest(MountTestBase): collection1.update() collection2.update() - assertRegex(self, collection1.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection1.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") self.assertEqual(collection2.manifest_text(), "") self.pool.apply(fuseMvFileBetweenCollectionsTest2, (self.mounttmp, @@ -935,7 +930,7 @@ class FuseMvFileBetweenCollectionsTest(MountTestBase): collection2.update() self.assertEqual(collection1.manifest_text(), "") - assertRegex(self, collection2.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file2\.txt$") + self.assertRegex(collection2.manifest_text(), r"\. 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file2\.txt$") collection1.stop_threads() collection2.stop_threads() @@ -995,7 +990,7 @@ class FuseMvDirBetweenCollectionsTest(MountTestBase): collection1.update() collection2.update() - assertRegex(self, collection1.manifest_text(), r"\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection1.manifest_text(), r"\./testdir 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") self.assertEqual(collection2.manifest_text(), "") self.pool.apply(fuseMvDirBetweenCollectionsTest2, (self.mounttmp, @@ -1006,7 +1001,7 @@ class FuseMvDirBetweenCollectionsTest(MountTestBase): collection2.update() self.assertEqual(collection1.manifest_text(), "") - assertRegex(self, collection2.manifest_text(), r"\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") + self.assertRegex(collection2.manifest_text(), r"\./testdir2 86fb269d190d2c85f6e0468ceca42a20\+12\+A\S+ 0:12:file1\.txt$") collection1.stop_threads() collection2.stop_threads() @@ -1201,7 +1196,7 @@ class FuseMagicTestPDHOnly(MountTestBase): files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' - for k, v in viewitems(files): + for k, v in files.items(): with open(os.path.join(self.mounttmp, k), 'rb') as f: self.assertEqual(v, f.read().decode())