summaryrefslogtreecommitdiffstats
path: root/src/test/librbd/test_mock_ManagedLock.cc
diff options
context:
space:
mode:
authorMykola Golub <mgolub@mirantis.com>2017-01-13 14:51:16 +0100
committerMykola Golub <mgolub@mirantis.com>2017-01-16 23:12:29 +0100
commit91b72f0a2d8edbbe94a82aafab6f759ac228db73 (patch)
tree72e757d8c596c25761d0f5e8fa018fda4ca75461 /src/test/librbd/test_mock_ManagedLock.cc
parentMerge pull request #12798 from wjwithagen/wip-wjw-krbd-optional (diff)
downloadceph-91b72f0a2d8edbbe94a82aafab6f759ac228db73.tar.xz
ceph-91b72f0a2d8edbbe94a82aafab6f759ac228db73.zip
librbd: managed_lock: make AcquireRequest use GetLockRequest and BreakRequest
Initially this was implemented for exclusive_lock (03533b9, 23f60fe) but was lost when merging managed_lock refactoring. Signed-off-by: Mykola Golub <mgolub@mirantis.com>
Diffstat (limited to 'src/test/librbd/test_mock_ManagedLock.cc')
-rw-r--r--src/test/librbd/test_mock_ManagedLock.cc53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/test/librbd/test_mock_ManagedLock.cc b/src/test/librbd/test_mock_ManagedLock.cc
index cd38e58034a..6b7b5228e61 100644
--- a/src/test/librbd/test_mock_ManagedLock.cc
+++ b/src/test/librbd/test_mock_ManagedLock.cc
@@ -51,6 +51,16 @@ std::list<T *> BaseRequest<T>::s_requests;
template <>
struct AcquireRequest<MockManagedLockImageCtx> : public BaseRequest<AcquireRequest<MockManagedLockImageCtx> > {
+ static AcquireRequest* create(librados::IoCtx& ioctx,
+ MockImageWatcher *watcher,
+ ContextWQ *work_queue, const std::string& oid,
+ const std::string& cookie,
+ bool blacklist_on_break_lock,
+ uint32_t blacklist_expire_seconds,
+ Context *on_finish) {
+ return BaseRequest::create(ioctx, watcher, work_queue, oid, cookie, on_finish);
+ }
+
MOCK_METHOD0(send, void());
};
@@ -174,7 +184,8 @@ TEST_F(TestMockManagedLock, StateTransitions) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest request_lock_acquire1;
@@ -204,8 +215,8 @@ TEST_F(TestMockManagedLock, AcquireLockLockedState) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest try_lock_acquire;
@@ -224,8 +235,8 @@ TEST_F(TestMockManagedLock, AcquireLockAlreadyLocked) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest try_lock_acquire;
@@ -242,8 +253,8 @@ TEST_F(TestMockManagedLock, AcquireLockBusy) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest try_lock_acquire;
@@ -260,8 +271,8 @@ TEST_F(TestMockManagedLock, AcquireLockError) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest try_lock_acquire;
@@ -279,8 +290,8 @@ TEST_F(TestMockManagedLock, AcquireLockBlacklist) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
// will abort after seeing blacklist error (avoid infinite request loop)
@@ -298,8 +309,8 @@ TEST_F(TestMockManagedLock, ReleaseLockUnlockedState) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
ASSERT_EQ(0, when_release_lock(managed_lock));
@@ -313,8 +324,8 @@ TEST_F(TestMockManagedLock, ReleaseLockError) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest try_lock_acquire;
@@ -339,8 +350,8 @@ TEST_F(TestMockManagedLock, ConcurrentRequests) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
expect_get_watch_handle(*mock_image_ctx.image_watcher);
@@ -396,8 +407,8 @@ TEST_F(TestMockManagedLock, ReacquireLock) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest request_lock_acquire;
@@ -423,8 +434,8 @@ TEST_F(TestMockManagedLock, ReacquireLockError) {
MockManagedLockImageCtx mock_image_ctx(*ictx);
MockManagedLock managed_lock(ictx->md_ctx, ictx->op_work_queue,
- ictx->header_oid, mock_image_ctx.image_watcher);
-
+ ictx->header_oid, mock_image_ctx.image_watcher,
+ true, 0);
InSequence seq;
MockAcquireRequest request_lock_acquire;