]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: added support for append op
authorJason Dillaman <dillaman@redhat.com>
Thu, 11 Jun 2015 21:32:40 +0000 (17:32 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 6 Nov 2015 01:42:40 +0000 (20:42 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/TestIoCtxImpl.h
src/test/librados_test_stub/TestMemIoCtxImpl.cc
src/test/librados_test_stub/TestMemIoCtxImpl.h

index 80690897af1acd8d7f7d95970fd873d4b484716e..75f7fde46fe607181a842fdbd50dafaeb09abfda 100644 (file)
@@ -90,6 +90,9 @@ TestRadosClientPtr get_rados_client() {
     cct->_conf->apply_changes(NULL);
     client->reset(new librados::TestMemRadosClient(cct),
                   &librados::TestRadosClient::Deallocate);
+    if (g_ceph_context == NULL) {
+      g_ceph_context = cct;
+    }
     cct->put();
   }
   (*client)->get();
@@ -695,6 +698,11 @@ void ObjectReadOperation::sparse_read(uint64_t off, uint64_t len,
   o->ops.push_back(op);
 }
 
+void ObjectWriteOperation::append(const bufferlist &bl) {
+  TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
+  o->ops.push_back(boost::bind(&TestIoCtxImpl::append, _1, _2, bl, _4));
+}
+
 void ObjectWriteOperation::create(bool exclusive) {
   TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
   o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive));
index 4d924f4988381f6d6ffb0c1eba6b8c619bfa4161..37094adcc0f6f96b56f030c04e2151f3cce037eb 100644 (file)
@@ -82,6 +82,8 @@ public:
                                bufferlist *pbl);
   virtual int aio_remove(const std::string& oid, AioCompletionImpl *c) = 0;
 
+  virtual int append(const std::string& oid, const bufferlist &bl,
+                     const SnapContext &snapc) = 0;
   virtual int assert_exists(const std::string &oid) = 0;
 
   virtual int create(const std::string& oid, bool exclusive) = 0;
index 6b124ed13a6805380a377ea71720d9c92305f983..9b95c502f15c341d98505d46b3818be8df834dae 100644 (file)
@@ -51,6 +51,23 @@ int TestMemIoCtxImpl::aio_remove(const std::string& oid, AioCompletionImpl *c) {
   return 0;
 }
 
+int TestMemIoCtxImpl::append(const std::string& oid, const bufferlist &bl,
+                             const SnapContext &snapc) {
+  if (get_snap_read() != CEPH_NOSNAP) {
+    return -EROFS;
+  }
+
+  TestMemRadosClient::SharedFile file;
+  {
+    RWLock::WLocker l(m_pool->file_lock);
+    file = get_file(oid, true, snapc);
+  }
+
+  RWLock::WLocker l(file->lock);
+  file->data.append(bl);
+  return 0;
+}
+
 int TestMemIoCtxImpl::assert_exists(const std::string &oid) {
   RWLock::RLocker l(m_pool->file_lock);
   TestMemRadosClient::SharedFile file = get_file(oid, false,
index aa6541530b5de125d87dd0d979829977f0ed6582..6556c9c723ef8711c8166adae969c11033be1a00 100644 (file)
@@ -21,6 +21,8 @@ public:
 
   virtual int aio_remove(const std::string& oid, AioCompletionImpl *c);
 
+  virtual int append(const std::string& oid, const bufferlist &bl,
+                     const SnapContext &snapc);
   virtual int assert_exists(const std::string &oid);
 
   virtual int create(const std::string& oid, bool exclusive);