summaryrefslogtreecommitdiffstats
path: root/src/test/cls_lock
diff options
context:
space:
mode:
authorJason Dillaman <dillaman@redhat.com>2016-08-15 22:50:43 +0200
committerJason Dillaman <dillaman@redhat.com>2016-08-23 18:23:07 +0200
commit377f57652f8ddae53f44c59f21e89c51b2bf0f7b (patch)
tree531ebde4027cb0b754adbe952c2ceb07f96e27d0 /src/test/cls_lock
parentMerge pull request #10743 from cbodley/wip-rgw-meta-sync-assert (diff)
downloadceph-377f57652f8ddae53f44c59f21e89c51b2bf0f7b.tar.xz
ceph-377f57652f8ddae53f44c59f21e89c51b2bf0f7b.zip
cls_lock: support updating the lock cookie without releasing the lock
Fixes: http://tracker.ceph.com/issues/17015 Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Diffstat (limited to 'src/test/cls_lock')
-rw-r--r--src/test/cls_lock/test_cls_lock.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/cls_lock/test_cls_lock.cc b/src/test/cls_lock/test_cls_lock.cc
index 72dbb8ecad0..104081559e1 100644
--- a/src/test/cls_lock/test_cls_lock.cc
+++ b/src/test/cls_lock/test_cls_lock.cc
@@ -338,3 +338,54 @@ TEST(ClsLock, TestAssertLocked) {
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
}
+
+TEST(ClsLock, TestSetCookie) {
+ Rados cluster;
+ std::string pool_name = get_temp_pool_name();
+ ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+ IoCtx ioctx;
+ cluster.ioctx_create(pool_name.c_str(), ioctx);
+
+ string oid = "foo";
+ string name = "name";
+ string tag = "tag";
+ string cookie = "cookie";
+ string new_cookie = "new cookie";
+ librados::ObjectWriteOperation op1;
+ set_cookie(&op1, name, LOCK_SHARED, cookie, tag, new_cookie);
+ ASSERT_EQ(-ENOENT, ioctx.operate(oid, &op1));
+
+ librados::ObjectWriteOperation op2;
+ lock(&op2, name, LOCK_SHARED, cookie, tag, "", utime_t{}, 0);
+ ASSERT_EQ(0, ioctx.operate(oid, &op2));
+
+ librados::ObjectWriteOperation op3;
+ lock(&op3, name, LOCK_SHARED, "cookie 2", tag, "", utime_t{}, 0);
+ ASSERT_EQ(0, ioctx.operate(oid, &op3));
+
+ librados::ObjectWriteOperation op4;
+ set_cookie(&op4, name, LOCK_SHARED, cookie, tag, cookie);
+ ASSERT_EQ(-EBUSY, ioctx.operate(oid, &op4));
+
+ librados::ObjectWriteOperation op5;
+ set_cookie(&op5, name, LOCK_SHARED, cookie, "wrong tag", new_cookie);
+ ASSERT_EQ(-EBUSY, ioctx.operate(oid, &op5));
+
+ librados::ObjectWriteOperation op6;
+ set_cookie(&op6, name, LOCK_SHARED, "wrong cookie", tag, new_cookie);
+ ASSERT_EQ(-EBUSY, ioctx.operate(oid, &op6));
+
+ librados::ObjectWriteOperation op7;
+ set_cookie(&op7, name, LOCK_EXCLUSIVE, cookie, tag, new_cookie);
+ ASSERT_EQ(-EBUSY, ioctx.operate(oid, &op7));
+
+ librados::ObjectWriteOperation op8;
+ set_cookie(&op8, name, LOCK_SHARED, cookie, tag, "cookie 2");
+ ASSERT_EQ(-EBUSY, ioctx.operate(oid, &op8));
+
+ librados::ObjectWriteOperation op9;
+ set_cookie(&op9, name, LOCK_SHARED, cookie, tag, new_cookie);
+ ASSERT_EQ(0, ioctx.operate(oid, &op9));
+
+ ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}