import os
import bz2
import sys
+import subprocess
class KeepLocalStoreTest(unittest.TestCase):
def setUp(self):
cw.set_current_file_name('baz.txt')
hash = cw.finish()
self.assertEqual(hash,
- 'a4d26dddc10ad8b5eb39347c916de16c+112',
+ '23ca013983d6239e98931cc779e68426+114',
'resulting manifest hash is not what I expected')
class LocalCollectionReaderTest(unittest.TestCase):
os.environ['KEEP_LOCAL_STORE'] = '/tmp'
LocalCollectionWriterTest().runTest()
def runTest(self):
- cr = arvados.CollectionReader('a4d26dddc10ad8b5eb39347c916de16c+112')
+ cr = arvados.CollectionReader('23ca013983d6239e98931cc779e68426+114')
got = []
for s in cr.all_streams():
for f in s.all_files():
got += [[f.size(), f.stream_name(), f.name(), f.read(2**26)]]
expected = [[3, '.', 'foo.txt', 'foo'],
[3, '.', 'bar.txt', 'bar'],
- [3, 'baz', 'baz.txt', 'baz']]
+ [3, './baz', 'baz.txt', 'baz']]
self.assertEqual(got,
expected,
'resulting file list is not what I expected')
os.environ['KEEP_LOCAL_STORE'] = '/tmp'
LocalCollectionWriterTest().runTest()
def runTest(self):
- self._runTest('a4d26dddc10ad8b5eb39347c916de16c+112',
+ self._runTest('23ca013983d6239e98931cc779e68426+114',
[[3, '.', 'foo.txt', 'foo'],
[3, '.', 'bar.txt', 'bar'],
- [3, 'baz', 'baz.txt', 'baz']])
+ [3, './baz', 'baz.txt', 'baz']])
self._runTest((". %s %s 0:3:foo.txt 3:3:bar.txt\n" %
(arvados.Keep.put("foo"),
arvados.Keep.put("bar"))),
self.assertEqual(got,
n_lines_in,
"decompression returned %d lines instead of %d" % (got, n_lines_in))
+
+class LocalCollectionGzipDecompressionTest(unittest.TestCase):
+ def setUp(self):
+ os.environ['KEEP_LOCAL_STORE'] = '/tmp'
+ def runTest(self):
+ n_lines_in = 2**18
+ data_in = "abc\n"
+ for x in xrange(0, 18):
+ data_in += data_in
+ p = subprocess.Popen(["gzip", "-1cn"],
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=False, close_fds=True)
+ compressed_data_in, stderrdata = p.communicate(data_in)
+
+ cw = arvados.CollectionWriter()
+ cw.start_new_file('test.gz')
+ cw.write(compressed_data_in)
+ gzip_manifest = cw.manifest_text()
+
+ cr = arvados.CollectionReader(gzip_manifest)
+ got = 0
+ for x in list(cr.all_files())[0].readlines():
+ self.assertEqual(x, "abc\n", "decompression returned wrong data: %s" % x)
+ got += 1
+ self.assertEqual(got,
+ n_lines_in,
+ "decompression returned %d lines instead of %d" % (got, n_lines_in))