]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: update librbd tests to handle blacklisting
authorJason Dillaman <dillaman@redhat.com>
Fri, 6 Feb 2015 08:58:33 +0000 (03:58 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 6 Feb 2015 12:27:53 +0000 (07:27 -0500)
The break lock unit test was updated to use a different
librados client to prevent blacklisting itself when breaking
the lock of a "dead" client.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_fixture.cc

index 3354fa87b774a7d55b7fc733c95db76d5474ceb3..265b15f7baa86617f23b7921c14e73cb5ece35e0 100644 (file)
@@ -282,15 +282,26 @@ TEST_F(TestImageWatcher, TryLockNotifyAnnounceLocked) {
 TEST_F(TestImageWatcher, TryLockWithTimedOutOwner) {
   REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK);
 
-  librbd::ImageCtx *ictx;
-  ASSERT_EQ(0, open_image(m_image_name, &ictx));
-
+  // use new Rados connection due to blacklisting
+  librados::Rados rados;
+  ASSERT_EQ("", connect_cluster_pp(rados));
+
+  librados::IoCtx io_ctx;
+  ASSERT_EQ(0, rados.ioctx_create(_pool_name.c_str(), io_ctx));
+  librbd::ImageCtx *ictx = new librbd::ImageCtx(m_image_name.c_str(), "", NULL,
+                                               io_ctx, false);
+  ASSERT_EQ(0, librbd::open_image(ictx));
   ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "auto 1234"));
+  librbd::close_image(ictx);
+  io_ctx.close();
 
   // no watcher on the locked image means we can break the lock
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
   RWLock::WLocker l(ictx->owner_lock);
   ASSERT_EQ(0, ictx->image_watcher->try_lock());
   ASSERT_TRUE(ictx->image_watcher->is_lock_owner());
+
+  rados.test_blacklist_self(false);
 }
 
 TEST_F(TestImageWatcher, TryLockWithUserExclusiveLock) {
index 0c584b0e230f93679c74584e57eda7e8cddc175b..9e47125489971a662b1ed8674b2964388b47aa48 100644 (file)
@@ -89,7 +89,7 @@ void TestFixture::close_image(librbd::ImageCtx *ictx) {
 
 int TestFixture::lock_image(librbd::ImageCtx &ictx, ClsLockType lock_type,
                            const std::string &cookie) {
-  int r = rados::cls::lock::lock(&m_ioctx, ictx.header_oid, RBD_LOCK_NAME,
+  int r = rados::cls::lock::lock(&ictx.md_ctx, ictx.header_oid, RBD_LOCK_NAME,
                           lock_type, cookie, "internal", "", utime_t(),
                           0);
   if (r == 0) {