Merge pull request #16 from thiagol11/GET_failure
fix issue with GET on large object
This commit is contained in:
commit
466d38a28a
@ -509,7 +509,7 @@ class DiskFileReader(object):
|
||||
bytes_read += len(chunk)
|
||||
diff = bytes_read - dropped_cache
|
||||
if diff > (1024 * 1024):
|
||||
self._drop_cache(self._fd, dropped_cache, diff)
|
||||
self._drop_cache(dropped_cache, diff)
|
||||
dropped_cache = bytes_read
|
||||
yield chunk
|
||||
if self._iter_hook:
|
||||
|
@ -58,6 +58,14 @@ class TestFile(Base):
|
||||
data_read = file.read()
|
||||
self.assertEquals(data,data_read)
|
||||
|
||||
def test_PUT_large_object(self):
|
||||
file_item = self.env.container.file(Utils.create_name())
|
||||
data = File.random_data(1024 * 1024 * 2)
|
||||
self.assertTrue(file_item.write(data))
|
||||
self.assert_status(201)
|
||||
self.assertTrue(data == file_item.read())
|
||||
self.assert_status(200)
|
||||
|
||||
def testInvalidHeadersPUT(self):
|
||||
#TODO: Although we now support x-delete-at and x-delete-after,
|
||||
#retained this test case as we may add some other header to
|
||||
|
@ -285,7 +285,7 @@ class TestDiskFile(unittest.TestCase):
|
||||
assert gdf._data_file == the_dir
|
||||
assert gdf._metadata == exp_md
|
||||
|
||||
def _create_and_get_diskfile(self, dev, par, acc, con, obj):
|
||||
def _create_and_get_diskfile(self, dev, par, acc, con, obj, fsize=256):
|
||||
# FIXME: assumes account === volume
|
||||
the_path = os.path.join(self.td, dev, con)
|
||||
the_file = os.path.join(the_path, obj)
|
||||
@ -293,7 +293,7 @@ class TestDiskFile(unittest.TestCase):
|
||||
base_dir = os.path.dirname(the_file)
|
||||
os.makedirs(base_dir)
|
||||
with open(the_file, "wb") as fd:
|
||||
fd.write("y" * 256)
|
||||
fd.write("y" * fsize)
|
||||
gdf = self._get_diskfile(dev, par, acc, con, obj)
|
||||
assert gdf._obj == base_obj
|
||||
assert not gdf._is_dir
|
||||
@ -353,6 +353,26 @@ class TestDiskFile(unittest.TestCase):
|
||||
assert len(chunks) == 1, repr(chunks)
|
||||
assert called[0] == 1, called
|
||||
|
||||
def test_reader_larger_file(self):
|
||||
closed = [False]
|
||||
fd = [-1]
|
||||
|
||||
def mock_close(*args, **kwargs):
|
||||
closed[0] = True
|
||||
os.close(fd[0])
|
||||
|
||||
with mock.patch("gluster.swift.obj.diskfile.do_close", mock_close):
|
||||
gdf = self._create_and_get_diskfile("vol0", "p57", "ufo47", "bar", "z", fsize=1024*1024*2)
|
||||
with gdf.open():
|
||||
assert gdf._fd is not None
|
||||
assert gdf._data_file == os.path.join(self.td, "vol0", "bar", "z")
|
||||
reader = gdf.reader()
|
||||
assert reader._fd is not None
|
||||
fd[0] = reader._fd
|
||||
chunks = [ck for ck in reader]
|
||||
assert reader._fd is None
|
||||
assert closed[0]
|
||||
|
||||
def test_reader_dir_object(self):
|
||||
called = [False]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user