diff --git a/swift_ceph_backend/rados_diskfile.py b/swift_ceph_backend/rados_diskfile.py index c3656e5..f567c91 100644 --- a/swift_ceph_backend/rados_diskfile.py +++ b/swift_ceph_backend/rados_diskfile.py @@ -100,11 +100,12 @@ class RadosFileSystem(object): def write(self, obj, offset, data): try: - return self._ioctx.write(obj, data, offset) + self._ioctx.write(obj, data, offset) except self._fs.RADOS.NoSpace: raise DiskFileNoSpace() except Exception: raise DiskFileError() + return len(data) def read(self, obj, off): return self._ioctx.read(obj, offset=off) @@ -163,6 +164,9 @@ class DiskFileWriter(object): metadata['name'] = self._name self._fs.put_object(self._name, metadata) + def commit(self, timestamp): + pass + class DiskFileReader(object): """ diff --git a/swift_ceph_backend/rados_server.py b/swift_ceph_backend/rados_server.py index 770d66d..a64b739 100644 --- a/swift_ceph_backend/rados_server.py +++ b/swift_ceph_backend/rados_server.py @@ -51,7 +51,8 @@ class ObjectController(server.ObjectController): container, obj, **kwargs) def async_update(self, op, account, container, obj, host, partition, - contdevice, headers_out, objdevice): + contdevice, headers_out, objdevice, policy, + logger_thread_locals=None): """ Sends or saves an async update. @@ -66,7 +67,7 @@ class ObjectController(server.ObjectController): request :param objdevice: device name that the object is in """ - headers_out['user-agent'] = 'obj-server %s' % os.getpid() + headers_out['user-agent'] = 'object-server %s' % os.getpid() full_path = '/%s/%s/%s' % (account, container, obj) if all([host, partition, contdevice]): try: diff --git a/tests/test_rados_diskfile.py b/tests/test_rados_diskfile.py index 6194558..3d54b99 100644 --- a/tests/test_rados_diskfile.py +++ b/tests/test_rados_diskfile.py @@ -14,7 +14,7 @@ # under the License. import mock -from mock import call +from mock import call, patch import cPickle as pickle import unittest from hashlib import md5 @@ -397,23 +397,24 @@ class TestRadosDiskFile(unittest.TestCase): writes = [] - def ioctx_write(obj, data, offset): + def mock_write(self, obj, offset, data): writes.append((data, offset)) return 2 - self.ioctx.write = ioctx_write - with self.df.create() as writer: - assert(writer.write(fcont) == len(fcont)) + with patch('swift_ceph_backend.rados_diskfile.' + 'RadosFileSystem._radosfs.write', mock_write): + with self.df.create() as writer: + assert(writer.write(fcont) == len(fcont)) - check_list = [ - (fcont, 0), - (fcont[2:], 2), - (fcont[4:], 4), - (fcont[6:], 6), - (fcont[8:], 8)] - assert(writes == check_list) - self._assert_if_rados_not_opened() - self._assert_if_rados_not_closed() + check_list = [ + (fcont, 0), + (fcont[2:], 2), + (fcont[4:], 4), + (fcont[6:], 6), + (fcont[8:], 8)] + assert(writes == check_list) + self._assert_if_rados_not_opened() + self._assert_if_rados_not_closed() def test_df_writer_put(self): meta = {'Content-Length': 0,