[ARVADOS] created: cf9874c59fa5a73d395743aaf71555b441161e3e
Git user
git at public.curoverse.com
Mon Jun 19 13:13:52 EDT 2017
at cf9874c59fa5a73d395743aaf71555b441161e3e (commit)
commit cf9874c59fa5a73d395743aaf71555b441161e3e
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Jun 19 14:12:41 2017 -0300
11778: Added explicit test that checks directory references upload behavior.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at curoverse.com>
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index dd002c1..3e9c945 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -841,6 +841,23 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
c = arv_put.api_client.collections().get(uuid=updated_col['uuid']).execute()
self.assertRegex(c['manifest_text'], r'^\..* .*:44:file2\n')
+ def test_upload_directory_reference_as_subcollection(self):
+ tmpdir1 = self.make_tmpdir()
+ tmpdir2 = self.make_tmpdir()
+ with open(os.path.join(tmpdir1, 'foo'), 'w') as f:
+ f.write('This is foo')
+ with open(os.path.join(tmpdir2, 'bar'), 'w') as f:
+ f.write('This is not foo')
+ # Upload one directory and one file
+ col = self.run_and_find_collection("", ['--no-progress',
+ tmpdir1,
+ os.path.join(tmpdir2, 'bar')])
+ self.assertNotEqual(None, col['uuid'])
+ c = arv_put.api_client.collections().get(uuid=col['uuid']).execute()
+ # Check that 'foo' was written inside a subcollection
+ # OTOH, 'bar' should have been directly uploaded on the root collection
+ self.assertRegex(c['manifest_text'], r'^\. .*:15:bar\n\./.+ .*:11:foo\n')
+
def test_put_collection_with_high_redundancy(self):
# Write empty data: we're not testing CollectionWriter, just
# making sure collections.create tells the API server what our
commit 62a1c9045b8313cc7e1b6be16ab922e3eff1bcfd
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Jun 19 13:49:21 2017 -0300
11788: Simple fix to upload directory references as subcollections instead of
uploading their contents directly on the collection's root.
Updated tests.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at curoverse.com>
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 12f9329..73842c9 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -439,8 +439,11 @@ class ArvPutUploadJob(object):
# Use absolute paths on cache index so CWD doesn't interfere
# with the caching logic.
prefixdir = path = os.path.abspath(path)
- if prefixdir != '/':
- prefixdir += '/'
+
+ if prefixdir[-1:] == '/':
+ prefixdir = prefixdir[:-1]
+ prefixdir = os.path.dirname(prefixdir) + '/'
+
for root, dirs, files in os.walk(path, followlinks=self.follow_links):
# Make os.walk()'s dir traversing order deterministic
dirs.sort()
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 6d10352..dd002c1 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -791,7 +791,8 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
datadir = self.make_tmpdir()
with open(os.path.join(datadir, "foo"), "w") as f:
f.write("The quick brown fox jumped over the lazy dog")
- p = subprocess.Popen([sys.executable, arv_put.__file__, datadir],
+ p = subprocess.Popen([sys.executable, arv_put.__file__,
+ os.path.join(datadir, 'foo')],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=self.ENVIRON)
@@ -838,7 +839,7 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
self.assertEqual(col['uuid'], updated_col['uuid'])
# Get the manifest and check that the new file is being included
c = arv_put.api_client.collections().get(uuid=updated_col['uuid']).execute()
- self.assertRegex(c['manifest_text'], r'^\. .*:44:file2\n')
+ self.assertRegex(c['manifest_text'], r'^\..* .*:44:file2\n')
def test_put_collection_with_high_redundancy(self):
# Write empty data: we're not testing CollectionWriter, just
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list