]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librados_test_stub: pass snap context to "create" method
authorMykola Golub <mgolub@suse.com>
Tue, 7 May 2019 05:34:47 +0000 (06:34 +0100)
committerMykola Golub <mgolub@suse.com>
Thu, 9 May 2019 17:11:46 +0000 (18:11 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/MockTestMemIoCtxImpl.h
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestIoCtxImpl.h
src/test/librados_test_stub/TestMemIoCtxImpl.cc
src/test/librados_test_stub/TestMemIoCtxImpl.h
src/test/librbd/io/test_mock_ObjectRequest.cc
src/test/rbd_mirror/image_deleter/test_mock_TrashWatcher.cc

index 2b3cce60652d648874bdcbc7883ddeb9a23ffbc1..11db4308b1b64a9f22e6003342112c117473fbd0 100644 (file)
@@ -510,7 +510,8 @@ void IoCtx::close() {
 int IoCtx::create(const std::string& oid, bool exclusive) {
   TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
   return ctx->execute_operation(
-    oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive));
+    oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive,
+                     ctx->get_snap_context()));
 }
 
 void IoCtx::dup(const IoCtx& rhs) {
@@ -914,7 +915,7 @@ void ObjectWriteOperation::append(const bufferlist &bl) {
 
 void ObjectWriteOperation::create(bool exclusive) {
   TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
-  o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive));
+  o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive, _4));
 }
 
 void ObjectWriteOperation::omap_set(const std::map<std::string, bufferlist> &map) {
@@ -1204,7 +1205,7 @@ WatchCtx2::~WatchCtx2() {
 int cls_cxx_create(cls_method_context_t hctx, bool exclusive) {
   librados::TestClassHandler::MethodContext *ctx =
     reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
-  return ctx->io_ctx_impl->create(ctx->oid, exclusive);
+  return ctx->io_ctx_impl->create(ctx->oid, exclusive, ctx->snapc);
 }
 
 int cls_cxx_remove(cls_method_context_t hctx) {
index 0ef52d3863fef1c4668e8f006b3d13c651e19f34..e9d2bcabe499002ae1f21871412effc5b347ca16 100644 (file)
@@ -61,9 +61,10 @@ public:
     return TestMemIoCtxImpl::assert_exists(oid);
   }
 
-  MOCK_METHOD2(create, int(const std::string&, bool));
-  int do_create(const std::string& oid, bool exclusive) {
-    return TestMemIoCtxImpl::create(oid, exclusive);
+  MOCK_METHOD3(create, int(const std::string&, bool, const SnapContext &));
+  int do_create(const std::string& oid, bool exclusive,
+                const SnapContext &snapc) {
+    return TestMemIoCtxImpl::create(oid, exclusive, snapc);
   }
 
   MOCK_METHOD3(cmpext, int(const std::string&, uint64_t, bufferlist&));
@@ -200,7 +201,7 @@ public:
     ON_CALL(*this, aio_watch(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_watch));
     ON_CALL(*this, aio_unwatch(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_unwatch));
     ON_CALL(*this, assert_exists(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_assert_exists));
-    ON_CALL(*this, create(_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create));
+    ON_CALL(*this, create(_, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create));
     ON_CALL(*this, cmpext(_,_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_cmpext));
     ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec));
     ON_CALL(*this, get_instance_id()).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_get_instance_id));
index 0788d9f5b30aae8a685c1192e645b66788b68c4e..aa6f0dcce2fb41ea5f71420b41c1f1dfcb8b344c 100644 (file)
@@ -278,7 +278,7 @@ int TestIoCtxImpl::tmap_update(const std::string& oid, bufferlist& cmdbl) {
   uint64_t size = 0;
   int r = stat(oid, &size, NULL);
   if (r == -ENOENT) {
-    r = create(oid, false);
+    r = create(oid, false, m_snapc);
   }
   if (r < 0) {
     return r;
index e92d7dfa505f669f4dfdc89e249bbe99298a9346..ad79a2986c75c52f11e155c71e672182a95d03ae 100644 (file)
@@ -99,7 +99,8 @@ public:
                      const SnapContext &snapc) = 0;
   virtual int assert_exists(const std::string &oid) = 0;
 
-  virtual int create(const std::string& oid, bool exclusive) = 0;
+  virtual int create(const std::string& oid, bool exclusive,
+                     const SnapContext &snapc) = 0;
   virtual int exec(const std::string& oid, TestClassHandler *handler,
                    const char *cls, const char *method,
                    bufferlist& inbl, bufferlist* outbl,
index 4f60e435987f44465d40a1375c017507b4208f0f..3f135954394ddc9c1003b930362f533cc3586639 100644 (file)
@@ -99,7 +99,8 @@ int TestMemIoCtxImpl::assert_exists(const std::string &oid) {
   return 0;
 }
 
-int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive) {
+int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive,
+                             const SnapContext &snapc) {
   if (get_snap_read() != CEPH_NOSNAP) {
     return -EROFS;
   } else if (m_client->is_blacklisted()) {
@@ -107,7 +108,7 @@ int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive) {
   }
 
   RWLock::WLocker l(m_pool->file_lock);
-  get_file(oid, true, get_snap_context());
+  get_file(oid, true, snapc);
   return 0;
 }
 
index f083230c89ebd04dd372be5c7ea3c31d30b21a9d..22e4fc7eb88fe7ea077782ffa4128939a3fd5f42 100644 (file)
@@ -28,7 +28,8 @@ public:
 
   int assert_exists(const std::string &oid) override;
 
-  int create(const std::string& oid, bool exclusive) override;
+  int create(const std::string& oid, bool exclusive,
+             const SnapContext &snapc) override;
   int list_snaps(const std::string& o, snap_set_t *out_snaps) override;
   int omap_get_vals(const std::string& oid,
                     const std::string& start_after,
index 2f1d8777e0b9f6a9cc288a464e5a3799accbec9e..3459ac49c418b9ab02a86f18665b63b729854fd7 100644 (file)
@@ -273,7 +273,7 @@ struct TestMockIoObjectRequest : public TestMockFixture {
   }
 
   void expect_create(MockTestImageCtx &mock_image_ctx, bool exclusive) {
-    EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive))
+    EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive, _))
       .Times(1);
   }
 
@@ -998,7 +998,8 @@ TEST_F(TestMockIoObjectRequest, DiscardTruncateAssertExists) {
   expect_assert_exists(mock_image_ctx, 0);
   expect_truncate(mock_image_ctx, 0, 0);
 
-  EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0);
+  EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _))
+    .Times(0);
 
   C_SaferCond ctx;
   auto req = MockObjectDiscardRequest::create_discard(
@@ -1033,7 +1034,8 @@ TEST_F(TestMockIoObjectRequest, DiscardTruncate) {
   expect_object_map_update(mock_image_ctx, 0, 1, OBJECT_EXISTS, {}, false, 0);
   expect_truncate(mock_image_ctx, 1, 0);
 
-  EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0);
+  EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _))
+    .Times(0);
 
   C_SaferCond ctx;
   auto req = MockObjectDiscardRequest::create_discard(
index 034c3e5497dae1eb02d31f2fd5f007f5a7d94a88..df78edd2db3d7ae2844d8712339ebc23c42ad39e 100644 (file)
@@ -151,7 +151,7 @@ public:
   }
 
   void expect_create_trash(librados::IoCtx &io_ctx, int r) {
-    EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false))
+    EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false, _))
       .WillOnce(Return(r));
   }