From 4b851ce0fa534ca043aca835057b9d68660971a4 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 10 Nov 2017 16:26:19 -0500 Subject: [PATCH] test/librados_test_stub: simulate set_alloc_hint creating a non-existent file Signed-off-by: Jason Dillaman --- .../librados_test_stub/LibradosTestStub.cc | 2 +- src/test/librados_test_stub/TestIoCtxImpl.cc | 3 ++- src/test/librados_test_stub/TestIoCtxImpl.h | 3 ++- .../librados_test_stub/TestMemIoCtxImpl.cc | 18 ++++++++++++++++++ src/test/librados_test_stub/TestMemIoCtxImpl.h | 3 +++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index d4ce8b20a6a..f4c7f8bef48 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -886,7 +886,7 @@ void ObjectWriteOperation::set_alloc_hint(uint64_t expected_object_size, uint64_t expected_write_size) { TestObjectOperationImpl *o = reinterpret_cast(impl); o->ops.push_back(boost::bind(&TestIoCtxImpl::set_alloc_hint, _1, _2, - expected_object_size, expected_write_size)); + expected_object_size, expected_write_size, _4)); } diff --git a/src/test/librados_test_stub/TestIoCtxImpl.cc b/src/test/librados_test_stub/TestIoCtxImpl.cc index d5de8b54aa6..56ce88690b4 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestIoCtxImpl.cc @@ -248,7 +248,8 @@ int TestIoCtxImpl::selfmanaged_snap_set_write_ctx(snap_t seq, int TestIoCtxImpl::set_alloc_hint(const std::string& oid, uint64_t expected_object_size, - uint64_t expected_write_size) { + uint64_t expected_write_size, + const SnapContext &snapc) { return 0; } diff --git a/src/test/librados_test_stub/TestIoCtxImpl.h b/src/test/librados_test_stub/TestIoCtxImpl.h index 7712e773070..87053085e99 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.h +++ b/src/test/librados_test_stub/TestIoCtxImpl.h @@ -135,7 +135,8 @@ public: std::vector& snaps); virtual int set_alloc_hint(const std::string& oid, uint64_t expected_object_size, - uint64_t expected_write_size); + uint64_t expected_write_size, + const SnapContext &snapc); virtual void set_snap_read(snap_t seq); virtual int sparse_read(const std::string& oid, uint64_t off, uint64_t len, std::map *m, diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index 1ab891419fa..cc99b1ee710 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -411,6 +411,24 @@ int TestMemIoCtxImpl::selfmanaged_snap_rollback(const std::string& oid, return 0; } +int TestMemIoCtxImpl::set_alloc_hint(const std::string& oid, + uint64_t expected_object_size, + uint64_t expected_write_size, + const SnapContext &snapc) { + if (get_snap_read() != CEPH_NOSNAP) { + return -EROFS; + } else if (m_client->is_blacklisted()) { + return -EBLACKLISTED; + } + + { + RWLock::WLocker l(m_pool->file_lock); + get_file(oid, true, snapc); + } + + return 0; +} + int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off, uint64_t len, std::map *m, diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.h b/src/test/librados_test_stub/TestMemIoCtxImpl.h index e6082bbfa69..e15eee56135 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.h @@ -52,6 +52,9 @@ public: int selfmanaged_snap_remove(uint64_t snapid) override; int selfmanaged_snap_rollback(const std::string& oid, uint64_t snapid) override; + int set_alloc_hint(const std::string& oid, uint64_t expected_object_size, + uint64_t expected_write_size, + const SnapContext &snapc) override; int sparse_read(const std::string& oid, uint64_t off, uint64_t len, std::map *m, bufferlist *data_bl) override; int stat(const std::string& oid, uint64_t *psize, time_t *pmtime) override; -- 2.39.5